178189Sbrian/*- 2330449Seadler * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3330449Seadler * 478189Sbrian * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 578189Sbrian * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 678189Sbrian * Internet Initiative Japan, Inc (IIJ) 778189Sbrian * All rights reserved. 86059Samurai * 978189Sbrian * Redistribution and use in source and binary forms, with or without 1078189Sbrian * modification, are permitted provided that the following conditions 1178189Sbrian * are met: 1278189Sbrian * 1. Redistributions of source code must retain the above copyright 1378189Sbrian * notice, this list of conditions and the following disclaimer. 1478189Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1578189Sbrian * notice, this list of conditions and the following disclaimer in the 1678189Sbrian * documentation and/or other materials provided with the distribution. 176059Samurai * 1878189Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1978189Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2078189Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2178189Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2278189Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2378189Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2478189Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2578189Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2678189Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2778189Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2878189Sbrian * SUCH DAMAGE. 296059Samurai * 3050479Speter * $FreeBSD: stable/11/usr.sbin/ppp/ipcp.h 330449 2018-03-05 07:26:05Z eadler $ 316059Samurai */ 326059Samurai 336059Samurai#define IPCP_MAXCODE CODE_CODEREJ 346059Samurai 356059Samurai#define TY_IPADDRS 1 366059Samurai#define TY_COMPPROTO 2 376059Samurai#define TY_IPADDR 3 386059Samurai 3936285Sbrian/* Domain NameServer and NetBIOS NameServer options */ 4018752Sjkh 4118752Sjkh#define TY_PRIMARY_DNS 129 4218752Sjkh#define TY_PRIMARY_NBNS 130 4318752Sjkh#define TY_SECONDARY_DNS 131 4418752Sjkh#define TY_SECONDARY_NBNS 132 4536285Sbrian#define TY_ADJUST_NS 119 /* subtract from NS val for REJECT bit */ 4630715Sbrian 4736285Sbrianstruct ipcp { 4836285Sbrian struct fsm fsm; /* The finite state machine */ 496059Samurai 5036285Sbrian struct { 5136285Sbrian struct { 5236285Sbrian int slots; /* Maximum VJ slots */ 5336285Sbrian unsigned slotcomp : 1; /* Slot compression */ 5436285Sbrian unsigned neg : 2; /* VJ negotiation */ 5536285Sbrian } vj; 5636285Sbrian 5781634Sbrian struct ncprange my_range; /* MYADDR spec */ 5843313Sbrian struct in_addr netmask; /* Iface netmask (unused by most OSs) */ 5981634Sbrian struct ncprange peer_range; /* HISADDR spec */ 6036285Sbrian struct iplist peer_list; /* Ranges of HISADDR values */ 6136285Sbrian 6236285Sbrian struct in_addr TriggerAddress; /* Address to suggest in REQ */ 6336285Sbrian unsigned HaveTriggerAddress : 1; /* Trigger address specified */ 6436285Sbrian 6536285Sbrian struct { 6636285Sbrian struct in_addr dns[2]; /* DNS addresses offered */ 6736285Sbrian unsigned dns_neg : 2; /* dns negotiation */ 6836285Sbrian struct in_addr nbns[2]; /* NetBIOS NS addresses offered */ 6936285Sbrian } ns; 7036285Sbrian 7181634Sbrian struct fsm_retry fsm; /* frequency to resend requests */ 7236285Sbrian } cfg; 7336285Sbrian 7436285Sbrian struct { 7536285Sbrian struct slcompress cslc; /* VJ state */ 7636285Sbrian struct slstat slstat; /* VJ statistics */ 7736285Sbrian } vj; 7836285Sbrian 7958044Sbrian struct { 8058044Sbrian unsigned resolver : 1; /* Found resolv.conf ? */ 8158044Sbrian unsigned writable : 1; /* Can write resolv.conf ? */ 8258044Sbrian struct in_addr dns[2]; /* Current DNS addresses */ 8358044Sbrian char *resolv; /* Contents of resolv.conf */ 8458044Sbrian char *resolv_nons; /* Contents of resolv.conf without ns */ 8558044Sbrian } ns; 8658044Sbrian 8736285Sbrian unsigned heis1172 : 1; /* True if he is speaking rfc1172 */ 8836285Sbrian 8980476Sbrian unsigned peer_req : 1; /* Any TY_IPADDR REQs from the peer ? */ 9036285Sbrian struct in_addr peer_ip; /* IP address he's willing to use */ 9136285Sbrian u_int32_t peer_compproto; /* VJ params he's willing to use */ 9236285Sbrian 9343313Sbrian struct in_addr ifmask; /* Interface netmask */ 9443313Sbrian 9536285Sbrian struct in_addr my_ip; /* IP address I'm willing to use */ 9636285Sbrian u_int32_t my_compproto; /* VJ params I'm willing to use */ 9736285Sbrian 9836285Sbrian u_int32_t peer_reject; /* Request codes rejected by peer */ 9936285Sbrian u_int32_t my_reject; /* Request codes I have rejected */ 10036285Sbrian 10136285Sbrian struct pppThroughput throughput; /* throughput statistics */ 10251062Sbrian struct mqueue Queue[3]; /* Output packet queues */ 10336285Sbrian}; 10436285Sbrian 10536285Sbrian#define fsm2ipcp(fp) (fp->proto == PROTO_IPCP ? (struct ipcp *)fp : NULL) 10650867Sbrian#define IPCP_QUEUES(ipcp) (sizeof ipcp->Queue / sizeof ipcp->Queue[0]) 10736285Sbrian 10836285Sbrianstruct bundle; 10936285Sbrianstruct link; 11036285Sbrianstruct cmdargs; 11181634Sbrianstruct iface_addr; 11236285Sbrian 11336285Sbrianextern void ipcp_Init(struct ipcp *, struct bundle *, struct link *, 11436285Sbrian const struct fsm_parent *); 11550867Sbrianextern void ipcp_Destroy(struct ipcp *); 11643313Sbrianextern void ipcp_Setup(struct ipcp *, u_int32_t); 11736285Sbrianextern void ipcp_SetLink(struct ipcp *, struct link *); 11836285Sbrian 11936285Sbrianextern int ipcp_Show(struct cmdargs const *); 12046686Sbrianextern struct mbuf *ipcp_Input(struct bundle *, struct link *, struct mbuf *); 12136285Sbrianextern void ipcp_AddInOctets(struct ipcp *, int); 12236285Sbrianextern void ipcp_AddOutOctets(struct ipcp *, int); 12343313Sbrianextern int ipcp_UseHisIPaddr(struct bundle *, struct in_addr); 12436285Sbrianextern int ipcp_UseHisaddr(struct bundle *, const char *, int); 12536285Sbrianextern int ipcp_vjset(struct cmdargs const *); 12681634Sbrianextern void ipcp_IfaceAddrAdded(struct ipcp *, const struct iface_addr *); 12781634Sbrianextern void ipcp_IfaceAddrDeleted(struct ipcp *, const struct iface_addr *); 12836285Sbrianextern int ipcp_InterfaceUp(struct ipcp *); 12944455Sbrianextern struct in_addr addr2mask(struct in_addr); 13058044Sbrianextern int ipcp_WriteDNS(struct ipcp *); 13158044Sbrianextern void ipcp_RestoreDNS(struct ipcp *); 13258044Sbrianextern void ipcp_LoadDNS(struct ipcp *); 13381634Sbrianextern size_t ipcp_QueueLen(struct ipcp *); 13481634Sbrianextern int ipcp_PushPacket(struct ipcp *, struct link *); 135