xref: /freebsd/usr.sbin/ppp/iface.h (revision dc744e1949e9681ad8d60a1d9a093e7f2e5992ee)
18fa6ebe4SBrian Somers /*-
28fa6ebe4SBrian Somers  * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
38fa6ebe4SBrian Somers  * All rights reserved.
48fa6ebe4SBrian Somers  *
58fa6ebe4SBrian Somers  * Redistribution and use in source and binary forms, with or without
68fa6ebe4SBrian Somers  * modification, are permitted provided that the following conditions
78fa6ebe4SBrian Somers  * are met:
88fa6ebe4SBrian Somers  * 1. Redistributions of source code must retain the above copyright
98fa6ebe4SBrian Somers  *    notice, this list of conditions and the following disclaimer.
108fa6ebe4SBrian Somers  * 2. Redistributions in binary form must reproduce the above copyright
118fa6ebe4SBrian Somers  *    notice, this list of conditions and the following disclaimer in the
128fa6ebe4SBrian Somers  *    documentation and/or other materials provided with the distribution.
138fa6ebe4SBrian Somers  *
148fa6ebe4SBrian Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
158fa6ebe4SBrian Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
168fa6ebe4SBrian Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
178fa6ebe4SBrian Somers  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
188fa6ebe4SBrian Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
198fa6ebe4SBrian Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
208fa6ebe4SBrian Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
218fa6ebe4SBrian Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
228fa6ebe4SBrian Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
238fa6ebe4SBrian Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
248fa6ebe4SBrian Somers  * SUCH DAMAGE.
258fa6ebe4SBrian Somers  *
2697d92980SPeter Wemm  * $FreeBSD$
278fa6ebe4SBrian Somers  */
288fa6ebe4SBrian Somers 
296b457978SBrian Somers struct ifa_msghdr;
306b457978SBrian Somers 
318fa6ebe4SBrian Somers struct iface_addr {
328fa6ebe4SBrian Somers   struct in_addr ifa;		/* local address */
338fa6ebe4SBrian Somers   struct in_addr mask;		/* netmask */
348fa6ebe4SBrian Somers   int bits;			/* netmask bits - -1 if not contiguous */
358fa6ebe4SBrian Somers   struct in_addr brd;		/* peer address */
368fa6ebe4SBrian Somers };
378fa6ebe4SBrian Somers 
388fa6ebe4SBrian Somers struct iface {
398fa6ebe4SBrian Somers   char *name;			/* Interface name (malloc'd) */
408fa6ebe4SBrian Somers   int index;			/* Interface index */
418fa6ebe4SBrian Somers   int flags;			/* Interface flags (IFF_*) */
428fa6ebe4SBrian Somers 
438fa6ebe4SBrian Somers   int in_addrs;			/* How many in_addr's */
448fa6ebe4SBrian Somers   struct iface_addr *in_addr;	/* Array of addresses (malloc'd) */
458fa6ebe4SBrian Somers };
468fa6ebe4SBrian Somers 
478fa6ebe4SBrian Somers #define IFACE_CLEAR_ALL		0	/* Nuke 'em all */
488fa6ebe4SBrian Somers #define IFACE_CLEAR_ALIASES	1	/* Leave the IPCP address */
498fa6ebe4SBrian Somers 
508fa6ebe4SBrian Somers #define IFACE_ADD_LAST		0	/* Just another alias */
518fa6ebe4SBrian Somers #define IFACE_ADD_FIRST		1	/* The IPCP address */
528fa6ebe4SBrian Somers #define IFACE_FORCE_ADD		2	/* OR'd with IFACE_ADD_{FIRST,LAST} */
538fa6ebe4SBrian Somers 
548fa6ebe4SBrian Somers #define iface_Clear iface_inClear	/* Same for now */
558fa6ebe4SBrian Somers 
568fa6ebe4SBrian Somers extern struct iface *iface_Create(const char *name);
578fa6ebe4SBrian Somers extern void iface_inClear(struct iface *, int);
588fa6ebe4SBrian Somers extern int iface_inAdd(struct iface *, struct in_addr, struct in_addr,
598fa6ebe4SBrian Somers                      struct in_addr, int);
608fa6ebe4SBrian Somers extern int iface_inDelete(struct iface *, struct in_addr);
618fa6ebe4SBrian Somers extern int iface_Show(struct cmdargs const *);
62dc744e19SBrian Somers extern int iface_SetFlags(const char *, int);
63dc744e19SBrian Somers extern int iface_ClearFlags(const char *, int);
648fa6ebe4SBrian Somers extern void iface_Destroy(struct iface *);
656b457978SBrian Somers extern void iface_ParseHdr(struct ifa_msghdr *, struct sockaddr *[RTAX_MAX]);
66