165309e5cSBrian Somers /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 31de7b4b8SPedro F. Giffuni * 465309e5cSBrian Somers * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 565309e5cSBrian Somers * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 665309e5cSBrian Somers * Internet Initiative Japan, Inc (IIJ) 765309e5cSBrian Somers * All rights reserved. 8af57ed9fSAtsushi Murai * 965309e5cSBrian Somers * Redistribution and use in source and binary forms, with or without 1065309e5cSBrian Somers * modification, are permitted provided that the following conditions 1165309e5cSBrian Somers * are met: 1265309e5cSBrian Somers * 1. Redistributions of source code must retain the above copyright 1365309e5cSBrian Somers * notice, this list of conditions and the following disclaimer. 1465309e5cSBrian Somers * 2. Redistributions in binary form must reproduce the above copyright 1565309e5cSBrian Somers * notice, this list of conditions and the following disclaimer in the 1665309e5cSBrian Somers * documentation and/or other materials provided with the distribution. 17af57ed9fSAtsushi Murai * 1865309e5cSBrian Somers * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1965309e5cSBrian Somers * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2065309e5cSBrian Somers * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2165309e5cSBrian Somers * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2265309e5cSBrian Somers * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2365309e5cSBrian Somers * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2465309e5cSBrian Somers * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2565309e5cSBrian Somers * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2665309e5cSBrian Somers * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2765309e5cSBrian Somers * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2865309e5cSBrian Somers * SUCH DAMAGE. 29af57ed9fSAtsushi Murai */ 30af57ed9fSAtsushi Murai 31af57ed9fSAtsushi Murai #define IPCP_MAXCODE CODE_CODEREJ 32af57ed9fSAtsushi Murai 33af57ed9fSAtsushi Murai #define TY_IPADDRS 1 34af57ed9fSAtsushi Murai #define TY_COMPPROTO 2 35af57ed9fSAtsushi Murai #define TY_IPADDR 3 36af57ed9fSAtsushi Murai 3729e275ceSBrian Somers /* Domain NameServer and NetBIOS NameServer options */ 38d8e55738SJordan K. Hubbard 39d8e55738SJordan K. Hubbard #define TY_PRIMARY_DNS 129 40d8e55738SJordan K. Hubbard #define TY_PRIMARY_NBNS 130 41d8e55738SJordan K. Hubbard #define TY_SECONDARY_DNS 131 42d8e55738SJordan K. Hubbard #define TY_SECONDARY_NBNS 132 433edeb0c6SBrian Somers #define TY_ADJUST_NS 119 /* subtract from NS val for REJECT bit */ 4475240ed1SBrian Somers 45aad81d1eSBrian Somers struct ipcp { 467308ec68SBrian Somers struct fsm fsm; /* The finite state machine */ 47d8e55738SJordan K. Hubbard 48503a7782SBrian Somers struct { 491342caedSBrian Somers struct { 501342caedSBrian Somers int slots; /* Maximum VJ slots */ 511342caedSBrian Somers unsigned slotcomp : 1; /* Slot compression */ 521342caedSBrian Somers unsigned neg : 2; /* VJ negotiation */ 531342caedSBrian Somers } vj; 5429e275ceSBrian Somers 5530949fd4SBrian Somers struct ncprange my_range; /* MYADDR spec */ 56972a1bcfSBrian Somers struct in_addr netmask; /* Iface netmask (unused by most OSs) */ 5730949fd4SBrian Somers struct ncprange peer_range; /* HISADDR spec */ 58503a7782SBrian Somers struct iplist peer_list; /* Ranges of HISADDR values */ 5929e275ceSBrian Somers 60503a7782SBrian Somers struct in_addr TriggerAddress; /* Address to suggest in REQ */ 61a3e27496SBrian Somers unsigned HaveTriggerAddress : 1; /* Trigger address specified */ 6229e275ceSBrian Somers 633edeb0c6SBrian Somers struct { 643edeb0c6SBrian Somers struct in_addr dns[2]; /* DNS addresses offered */ 653edeb0c6SBrian Somers unsigned dns_neg : 2; /* dns negotiation */ 663edeb0c6SBrian Somers struct in_addr nbns[2]; /* NetBIOS NS addresses offered */ 673edeb0c6SBrian Somers } ns; 683edeb0c6SBrian Somers 6930949fd4SBrian Somers struct fsm_retry fsm; /* frequency to resend requests */ 70503a7782SBrian Somers } cfg; 7129e275ceSBrian Somers 72eaa4df37SBrian Somers struct { 73eaa4df37SBrian Somers struct slcompress cslc; /* VJ state */ 74eaa4df37SBrian Somers struct slstat slstat; /* VJ statistics */ 75eaa4df37SBrian Somers } vj; 76eaa4df37SBrian Somers 77d568d6c4SBrian Somers struct { 78d568d6c4SBrian Somers unsigned resolver : 1; /* Found resolv.conf ? */ 79d568d6c4SBrian Somers unsigned writable : 1; /* Can write resolv.conf ? */ 80d568d6c4SBrian Somers struct in_addr dns[2]; /* Current DNS addresses */ 81d568d6c4SBrian Somers char *resolv; /* Contents of resolv.conf */ 82d568d6c4SBrian Somers char *resolv_nons; /* Contents of resolv.conf without ns */ 83d568d6c4SBrian Somers } ns; 84d568d6c4SBrian Somers 85a3e27496SBrian Somers unsigned heis1172 : 1; /* True if he is speaking rfc1172 */ 8629e275ceSBrian Somers 875e3b2d68SBrian Somers unsigned peer_req : 1; /* Any TY_IPADDR REQs from the peer ? */ 88503a7782SBrian Somers struct in_addr peer_ip; /* IP address he's willing to use */ 89503a7782SBrian Somers u_int32_t peer_compproto; /* VJ params he's willing to use */ 9029e275ceSBrian Somers 91972a1bcfSBrian Somers struct in_addr ifmask; /* Interface netmask */ 92972a1bcfSBrian Somers 93503a7782SBrian Somers struct in_addr my_ip; /* IP address I'm willing to use */ 94503a7782SBrian Somers u_int32_t my_compproto; /* VJ params I'm willing to use */ 9529e275ceSBrian Somers 96503a7782SBrian Somers u_int32_t peer_reject; /* Request codes rejected by peer */ 97503a7782SBrian Somers u_int32_t my_reject; /* Request codes I have rejected */ 98503a7782SBrian Somers 9929e275ceSBrian Somers struct pppThroughput throughput; /* throughput statistics */ 10055b9d469SBrian Somers struct mqueue Queue[3]; /* Output packet queues */ 10129e275ceSBrian Somers }; 10229e275ceSBrian Somers 103aad81d1eSBrian Somers #define fsm2ipcp(fp) (fp->proto == PROTO_IPCP ? (struct ipcp *)fp : NULL) 104442f8495SBrian Somers #define IPCP_QUEUES(ipcp) (sizeof ipcp->Queue / sizeof ipcp->Queue[0]) 10583d1af55SBrian Somers 1062764b86aSBrian Somers struct bundle; 1072764b86aSBrian Somers struct link; 1082764b86aSBrian Somers struct cmdargs; 10930949fd4SBrian Somers struct iface_addr; 1102764b86aSBrian Somers 111ce828a6eSBrian Somers extern void ipcp_Init(struct ipcp *, struct bundle *, struct link *, 1126d666775SBrian Somers const struct fsm_parent *); 113442f8495SBrian Somers extern void ipcp_Destroy(struct ipcp *); 114972a1bcfSBrian Somers extern void ipcp_Setup(struct ipcp *, u_int32_t); 115ce828a6eSBrian Somers extern void ipcp_SetLink(struct ipcp *, struct link *); 116503a7782SBrian Somers 117dd7e2610SBrian Somers extern int ipcp_Show(struct cmdargs const *); 1185d9e6103SBrian Somers extern struct mbuf *ipcp_Input(struct bundle *, struct link *, struct mbuf *); 1195828db6dSBrian Somers extern void ipcp_AddInOctets(struct ipcp *, int); 1205828db6dSBrian Somers extern void ipcp_AddOutOctets(struct ipcp *, int); 121972a1bcfSBrian Somers extern int ipcp_UseHisIPaddr(struct bundle *, struct in_addr); 122dd7e2610SBrian Somers extern int ipcp_UseHisaddr(struct bundle *, const char *, int); 123dd7e2610SBrian Somers extern int ipcp_vjset(struct cmdargs const *); 12430949fd4SBrian Somers extern void ipcp_IfaceAddrAdded(struct ipcp *, const struct iface_addr *); 12530949fd4SBrian Somers extern void ipcp_IfaceAddrDeleted(struct ipcp *, const struct iface_addr *); 126dd0645c5SBrian Somers extern int ipcp_InterfaceUp(struct ipcp *); 127bc76350eSBrian Somers extern struct in_addr addr2mask(struct in_addr); 128d568d6c4SBrian Somers extern int ipcp_WriteDNS(struct ipcp *); 129d568d6c4SBrian Somers extern void ipcp_RestoreDNS(struct ipcp *); 130d568d6c4SBrian Somers extern void ipcp_LoadDNS(struct ipcp *); 13130949fd4SBrian Somers extern size_t ipcp_QueueLen(struct ipcp *); 13230949fd4SBrian Somers extern int ipcp_PushPacket(struct ipcp *, struct link *); 133