18fa6ebe4SBrian Somers /*- 2*1de7b4b8SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*1de7b4b8SPedro F. Giffuni * 48fa6ebe4SBrian Somers * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 58fa6ebe4SBrian Somers * All rights reserved. 68fa6ebe4SBrian Somers * 78fa6ebe4SBrian Somers * Redistribution and use in source and binary forms, with or without 88fa6ebe4SBrian Somers * modification, are permitted provided that the following conditions 98fa6ebe4SBrian Somers * are met: 108fa6ebe4SBrian Somers * 1. Redistributions of source code must retain the above copyright 118fa6ebe4SBrian Somers * notice, this list of conditions and the following disclaimer. 128fa6ebe4SBrian Somers * 2. Redistributions in binary form must reproduce the above copyright 138fa6ebe4SBrian Somers * notice, this list of conditions and the following disclaimer in the 148fa6ebe4SBrian Somers * documentation and/or other materials provided with the distribution. 158fa6ebe4SBrian Somers * 168fa6ebe4SBrian Somers * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 178fa6ebe4SBrian Somers * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 188fa6ebe4SBrian Somers * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 198fa6ebe4SBrian Somers * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 208fa6ebe4SBrian Somers * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 218fa6ebe4SBrian Somers * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 228fa6ebe4SBrian Somers * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 238fa6ebe4SBrian Somers * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 248fa6ebe4SBrian Somers * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 258fa6ebe4SBrian Somers * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 268fa6ebe4SBrian Somers * SUCH DAMAGE. 278fa6ebe4SBrian Somers * 2897d92980SPeter Wemm * $FreeBSD$ 298fa6ebe4SBrian Somers */ 308fa6ebe4SBrian Somers 316b457978SBrian Somers struct ifa_msghdr; 326b457978SBrian Somers 338fa6ebe4SBrian Somers struct iface_addr { 3430949fd4SBrian Somers unsigned system : 1; /* System alias ? */ 3530949fd4SBrian Somers struct ncprange ifa; /* local address/mask */ 3630949fd4SBrian Somers struct ncpaddr peer; /* peer address */ 378fa6ebe4SBrian Somers }; 388fa6ebe4SBrian Somers 398fa6ebe4SBrian Somers struct iface { 408fa6ebe4SBrian Somers char *name; /* Interface name (malloc'd) */ 41f2f5156fSBrian Somers char *descr; /* Interface description (malloc'd) */ 428fa6ebe4SBrian Somers int index; /* Interface index */ 438fa6ebe4SBrian Somers int flags; /* Interface flags (IFF_*) */ 44057f1760SBrian Somers unsigned long mtu; /* struct tuninfo MTU */ 458fa6ebe4SBrian Somers 46057f1760SBrian Somers unsigned addrs; /* How many in_addr's */ 4730949fd4SBrian Somers struct iface_addr *addr; /* Array of addresses (malloc'd) */ 488fa6ebe4SBrian Somers }; 498fa6ebe4SBrian Somers 508fa6ebe4SBrian Somers #define IFACE_CLEAR_ALL 0 /* Nuke 'em all */ 5130949fd4SBrian Somers #define IFACE_CLEAR_ALIASES 1 /* Leave the NCP address */ 528fa6ebe4SBrian Somers 538fa6ebe4SBrian Somers #define IFACE_ADD_LAST 0 /* Just another alias */ 548fa6ebe4SBrian Somers #define IFACE_ADD_FIRST 1 /* The IPCP address */ 558fa6ebe4SBrian Somers #define IFACE_FORCE_ADD 2 /* OR'd with IFACE_ADD_{FIRST,LAST} */ 568fa6ebe4SBrian Somers 5730949fd4SBrian Somers #define IFACE_SYSTEM 4 /* Set/clear SYSTEM entries */ 588fa6ebe4SBrian Somers 598fa6ebe4SBrian Somers extern struct iface *iface_Create(const char *name); 6030949fd4SBrian Somers extern void iface_Clear(struct iface *, struct ncp *, int, int); 61f2f5156fSBrian Somers extern int iface_Name(struct iface *, const char *); 62f2f5156fSBrian Somers extern int iface_Descr(struct cmdargs const *); 6330949fd4SBrian Somers extern int iface_Add(struct iface *, struct ncp *, const struct ncprange *, 6430949fd4SBrian Somers const struct ncpaddr *, int); 6530949fd4SBrian Somers extern int iface_Delete(struct iface *, struct ncp *, const struct ncpaddr *); 668fa6ebe4SBrian Somers extern int iface_Show(struct cmdargs const *); 67dc744e19SBrian Somers extern int iface_SetFlags(const char *, int); 68dc744e19SBrian Somers extern int iface_ClearFlags(const char *, int); 69f2f5156fSBrian Somers extern void iface_Free(struct iface *); 708fa6ebe4SBrian Somers extern void iface_Destroy(struct iface *); 716b457978SBrian Somers extern void iface_ParseHdr(struct ifa_msghdr *, struct sockaddr *[RTAX_MAX]); 72