178189Sbrian/*- 278189Sbrian * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 378189Sbrian * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 478189Sbrian * Internet Initiative Japan, Inc (IIJ) 578189Sbrian * All rights reserved. 66059Samurai * 778189Sbrian * Redistribution and use in source and binary forms, with or without 878189Sbrian * modification, are permitted provided that the following conditions 978189Sbrian * are met: 1078189Sbrian * 1. Redistributions of source code must retain the above copyright 1178189Sbrian * notice, this list of conditions and the following disclaimer. 1278189Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1378189Sbrian * notice, this list of conditions and the following disclaimer in the 1478189Sbrian * documentation and/or other materials provided with the distribution. 156059Samurai * 1678189Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1778189Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1878189Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1978189Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2078189Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2178189Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2278189Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2378189Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2478189Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2578189Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2678189Sbrian * SUCH DAMAGE. 276059Samurai * 2850479Speter * $FreeBSD$ 296059Samurai */ 306059Samurai 316059Samurai#define IPCP_MAXCODE CODE_CODEREJ 326059Samurai 336059Samurai#define TY_IPADDRS 1 346059Samurai#define TY_COMPPROTO 2 356059Samurai#define TY_IPADDR 3 366059Samurai 3736285Sbrian/* Domain NameServer and NetBIOS NameServer options */ 3818752Sjkh 3918752Sjkh#define TY_PRIMARY_DNS 129 4018752Sjkh#define TY_PRIMARY_NBNS 130 4118752Sjkh#define TY_SECONDARY_DNS 131 4218752Sjkh#define TY_SECONDARY_NBNS 132 4336285Sbrian#define TY_ADJUST_NS 119 /* subtract from NS val for REJECT bit */ 4430715Sbrian 4536285Sbrianstruct ipcp { 4636285Sbrian struct fsm fsm; /* The finite state machine */ 476059Samurai 4836285Sbrian struct { 4936285Sbrian struct { 5036285Sbrian int slots; /* Maximum VJ slots */ 5136285Sbrian unsigned slotcomp : 1; /* Slot compression */ 5236285Sbrian unsigned neg : 2; /* VJ negotiation */ 5336285Sbrian } vj; 5436285Sbrian 5581634Sbrian struct ncprange my_range; /* MYADDR spec */ 5643313Sbrian struct in_addr netmask; /* Iface netmask (unused by most OSs) */ 5781634Sbrian struct ncprange peer_range; /* HISADDR spec */ 5836285Sbrian struct iplist peer_list; /* Ranges of HISADDR values */ 5936285Sbrian 6036285Sbrian struct in_addr TriggerAddress; /* Address to suggest in REQ */ 6136285Sbrian unsigned HaveTriggerAddress : 1; /* Trigger address specified */ 6236285Sbrian 6336285Sbrian struct { 6436285Sbrian struct in_addr dns[2]; /* DNS addresses offered */ 6536285Sbrian unsigned dns_neg : 2; /* dns negotiation */ 6636285Sbrian struct in_addr nbns[2]; /* NetBIOS NS addresses offered */ 6736285Sbrian } ns; 6836285Sbrian 6981634Sbrian struct fsm_retry fsm; /* frequency to resend requests */ 7036285Sbrian } cfg; 7136285Sbrian 7236285Sbrian struct { 7336285Sbrian struct slcompress cslc; /* VJ state */ 7436285Sbrian struct slstat slstat; /* VJ statistics */ 7536285Sbrian } vj; 7636285Sbrian 7758044Sbrian struct { 7858044Sbrian unsigned resolver : 1; /* Found resolv.conf ? */ 7958044Sbrian unsigned writable : 1; /* Can write resolv.conf ? */ 8058044Sbrian struct in_addr dns[2]; /* Current DNS addresses */ 8158044Sbrian char *resolv; /* Contents of resolv.conf */ 8258044Sbrian char *resolv_nons; /* Contents of resolv.conf without ns */ 8358044Sbrian } ns; 8458044Sbrian 8536285Sbrian unsigned heis1172 : 1; /* True if he is speaking rfc1172 */ 8636285Sbrian 8780476Sbrian unsigned peer_req : 1; /* Any TY_IPADDR REQs from the peer ? */ 8836285Sbrian struct in_addr peer_ip; /* IP address he's willing to use */ 8936285Sbrian u_int32_t peer_compproto; /* VJ params he's willing to use */ 9036285Sbrian 9143313Sbrian struct in_addr ifmask; /* Interface netmask */ 9243313Sbrian 9336285Sbrian struct in_addr my_ip; /* IP address I'm willing to use */ 9436285Sbrian u_int32_t my_compproto; /* VJ params I'm willing to use */ 9536285Sbrian 9636285Sbrian u_int32_t peer_reject; /* Request codes rejected by peer */ 9736285Sbrian u_int32_t my_reject; /* Request codes I have rejected */ 9836285Sbrian 9936285Sbrian struct pppThroughput throughput; /* throughput statistics */ 10051062Sbrian struct mqueue Queue[3]; /* Output packet queues */ 10136285Sbrian}; 10236285Sbrian 10336285Sbrian#define fsm2ipcp(fp) (fp->proto == PROTO_IPCP ? (struct ipcp *)fp : NULL) 10450867Sbrian#define IPCP_QUEUES(ipcp) (sizeof ipcp->Queue / sizeof ipcp->Queue[0]) 10536285Sbrian 10636285Sbrianstruct bundle; 10736285Sbrianstruct link; 10836285Sbrianstruct cmdargs; 10981634Sbrianstruct iface_addr; 11036285Sbrian 11136285Sbrianextern void ipcp_Init(struct ipcp *, struct bundle *, struct link *, 11236285Sbrian const struct fsm_parent *); 11350867Sbrianextern void ipcp_Destroy(struct ipcp *); 11443313Sbrianextern void ipcp_Setup(struct ipcp *, u_int32_t); 11536285Sbrianextern void ipcp_SetLink(struct ipcp *, struct link *); 11636285Sbrian 11736285Sbrianextern int ipcp_Show(struct cmdargs const *); 11846686Sbrianextern struct mbuf *ipcp_Input(struct bundle *, struct link *, struct mbuf *); 11936285Sbrianextern void ipcp_AddInOctets(struct ipcp *, int); 12036285Sbrianextern void ipcp_AddOutOctets(struct ipcp *, int); 12143313Sbrianextern int ipcp_UseHisIPaddr(struct bundle *, struct in_addr); 12236285Sbrianextern int ipcp_UseHisaddr(struct bundle *, const char *, int); 12336285Sbrianextern int ipcp_vjset(struct cmdargs const *); 12481634Sbrianextern void ipcp_IfaceAddrAdded(struct ipcp *, const struct iface_addr *); 12581634Sbrianextern void ipcp_IfaceAddrDeleted(struct ipcp *, const struct iface_addr *); 12636285Sbrianextern int ipcp_InterfaceUp(struct ipcp *); 12744455Sbrianextern struct in_addr addr2mask(struct in_addr); 12858044Sbrianextern int ipcp_WriteDNS(struct ipcp *); 12958044Sbrianextern void ipcp_RestoreDNS(struct ipcp *); 13058044Sbrianextern void ipcp_LoadDNS(struct ipcp *); 13181634Sbrianextern size_t ipcp_QueueLen(struct ipcp *); 13281634Sbrianextern int ipcp_PushPacket(struct ipcp *, struct link *); 133