iface.h revision 40561
140561Sbrian/*- 240561Sbrian * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 340561Sbrian * All rights reserved. 440561Sbrian * 540561Sbrian * Redistribution and use in source and binary forms, with or without 640561Sbrian * modification, are permitted provided that the following conditions 740561Sbrian * are met: 840561Sbrian * 1. Redistributions of source code must retain the above copyright 940561Sbrian * notice, this list of conditions and the following disclaimer. 1040561Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1140561Sbrian * notice, this list of conditions and the following disclaimer in the 1240561Sbrian * documentation and/or other materials provided with the distribution. 1340561Sbrian * 1440561Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1540561Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1640561Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1740561Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1840561Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1940561Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2040561Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2140561Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2240561Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2340561Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2440561Sbrian * SUCH DAMAGE. 2540561Sbrian * 2640561Sbrian * $Id:$ 2740561Sbrian */ 2840561Sbrian 2940561Sbrianstruct iface_addr { 3040561Sbrian struct in_addr ifa; /* local address */ 3140561Sbrian struct in_addr mask; /* netmask */ 3240561Sbrian int bits; /* netmask bits - -1 if not contiguous */ 3340561Sbrian struct in_addr brd; /* peer address */ 3440561Sbrian}; 3540561Sbrian 3640561Sbrianstruct iface { 3740561Sbrian char *name; /* Interface name (malloc'd) */ 3840561Sbrian int index; /* Interface index */ 3940561Sbrian int flags; /* Interface flags (IFF_*) */ 4040561Sbrian 4140561Sbrian int in_addrs; /* How many in_addr's */ 4240561Sbrian struct iface_addr *in_addr; /* Array of addresses (malloc'd) */ 4340561Sbrian}; 4440561Sbrian 4540561Sbrian#define IFACE_CLEAR_ALL 0 /* Nuke 'em all */ 4640561Sbrian#define IFACE_CLEAR_ALIASES 1 /* Leave the IPCP address */ 4740561Sbrian 4840561Sbrian#define IFACE_ADD_LAST 0 /* Just another alias */ 4940561Sbrian#define IFACE_ADD_FIRST 1 /* The IPCP address */ 5040561Sbrian#define IFACE_FORCE_ADD 2 /* OR'd with IFACE_ADD_{FIRST,LAST} */ 5140561Sbrian 5240561Sbrian#define iface_Clear iface_inClear /* Same for now */ 5340561Sbrian 5440561Sbrianextern struct iface *iface_Create(const char *name); 5540561Sbrianextern void iface_inClear(struct iface *, int); 5640561Sbrianextern int iface_inAdd(struct iface *, struct in_addr, struct in_addr, 5740561Sbrian struct in_addr, int); 5840561Sbrianextern int iface_inDelete(struct iface *, struct in_addr); 5940561Sbrianextern int iface_Show(struct cmdargs const *); 6040561Sbrianextern void iface_Destroy(struct iface *); 61