186d7f5d3SJohn Marino /*- 286d7f5d3SJohn Marino * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 386d7f5d3SJohn Marino * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 486d7f5d3SJohn Marino * Internet Initiative Japan, Inc (IIJ) 586d7f5d3SJohn Marino * All rights reserved. 686d7f5d3SJohn Marino * 786d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without 886d7f5d3SJohn Marino * modification, are permitted provided that the following conditions 986d7f5d3SJohn Marino * are met: 1086d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright 1186d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer. 1286d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 1386d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the 1486d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution. 1586d7f5d3SJohn Marino * 1686d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1786d7f5d3SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1886d7f5d3SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1986d7f5d3SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2086d7f5d3SJohn Marino * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2186d7f5d3SJohn Marino * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2286d7f5d3SJohn Marino * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2386d7f5d3SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2486d7f5d3SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2586d7f5d3SJohn Marino * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2686d7f5d3SJohn Marino * SUCH DAMAGE. 2786d7f5d3SJohn Marino * 2886d7f5d3SJohn Marino * $FreeBSD: src/usr.sbin/ppp/ipcp.h,v 1.30.2.5 2002/09/01 02:12:27 brian Exp $ 2986d7f5d3SJohn Marino * $DragonFly: src/usr.sbin/ppp/ipcp.h,v 1.2 2003/06/17 04:30:00 dillon Exp $ 3086d7f5d3SJohn Marino */ 3186d7f5d3SJohn Marino 3286d7f5d3SJohn Marino #define IPCP_MAXCODE CODE_CODEREJ 3386d7f5d3SJohn Marino 3486d7f5d3SJohn Marino #define TY_IPADDRS 1 3586d7f5d3SJohn Marino #define TY_COMPPROTO 2 3686d7f5d3SJohn Marino #define TY_IPADDR 3 3786d7f5d3SJohn Marino 3886d7f5d3SJohn Marino /* Domain NameServer and NetBIOS NameServer options */ 3986d7f5d3SJohn Marino 4086d7f5d3SJohn Marino #define TY_PRIMARY_DNS 129 4186d7f5d3SJohn Marino #define TY_PRIMARY_NBNS 130 4286d7f5d3SJohn Marino #define TY_SECONDARY_DNS 131 4386d7f5d3SJohn Marino #define TY_SECONDARY_NBNS 132 4486d7f5d3SJohn Marino #define TY_ADJUST_NS 119 /* subtract from NS val for REJECT bit */ 4586d7f5d3SJohn Marino 4686d7f5d3SJohn Marino struct ipcp { 4786d7f5d3SJohn Marino struct fsm fsm; /* The finite state machine */ 4886d7f5d3SJohn Marino 4986d7f5d3SJohn Marino struct { 5086d7f5d3SJohn Marino struct { 5186d7f5d3SJohn Marino int slots; /* Maximum VJ slots */ 5286d7f5d3SJohn Marino unsigned slotcomp : 1; /* Slot compression */ 5386d7f5d3SJohn Marino unsigned neg : 2; /* VJ negotiation */ 5486d7f5d3SJohn Marino } vj; 5586d7f5d3SJohn Marino 5686d7f5d3SJohn Marino struct ncprange my_range; /* MYADDR spec */ 5786d7f5d3SJohn Marino struct in_addr netmask; /* Iface netmask (unused by most OSs) */ 5886d7f5d3SJohn Marino struct ncprange peer_range; /* HISADDR spec */ 5986d7f5d3SJohn Marino struct iplist peer_list; /* Ranges of HISADDR values */ 6086d7f5d3SJohn Marino 6186d7f5d3SJohn Marino struct in_addr TriggerAddress; /* Address to suggest in REQ */ 6286d7f5d3SJohn Marino unsigned HaveTriggerAddress : 1; /* Trigger address specified */ 6386d7f5d3SJohn Marino 6486d7f5d3SJohn Marino struct { 6586d7f5d3SJohn Marino struct in_addr dns[2]; /* DNS addresses offered */ 6686d7f5d3SJohn Marino unsigned dns_neg : 2; /* dns negotiation */ 6786d7f5d3SJohn Marino struct in_addr nbns[2]; /* NetBIOS NS addresses offered */ 6886d7f5d3SJohn Marino } ns; 6986d7f5d3SJohn Marino 7086d7f5d3SJohn Marino struct fsm_retry fsm; /* frequency to resend requests */ 7186d7f5d3SJohn Marino } cfg; 7286d7f5d3SJohn Marino 7386d7f5d3SJohn Marino struct { 7486d7f5d3SJohn Marino struct slcompress cslc; /* VJ state */ 7586d7f5d3SJohn Marino struct slstat slstat; /* VJ statistics */ 7686d7f5d3SJohn Marino } vj; 7786d7f5d3SJohn Marino 7886d7f5d3SJohn Marino struct { 7986d7f5d3SJohn Marino unsigned resolver : 1; /* Found resolv.conf ? */ 8086d7f5d3SJohn Marino unsigned writable : 1; /* Can write resolv.conf ? */ 8186d7f5d3SJohn Marino struct in_addr dns[2]; /* Current DNS addresses */ 8286d7f5d3SJohn Marino char *resolv; /* Contents of resolv.conf */ 8386d7f5d3SJohn Marino char *resolv_nons; /* Contents of resolv.conf without ns */ 8486d7f5d3SJohn Marino } ns; 8586d7f5d3SJohn Marino 8686d7f5d3SJohn Marino unsigned heis1172 : 1; /* True if he is speaking rfc1172 */ 8786d7f5d3SJohn Marino 8886d7f5d3SJohn Marino unsigned peer_req : 1; /* Any TY_IPADDR REQs from the peer ? */ 8986d7f5d3SJohn Marino struct in_addr peer_ip; /* IP address he's willing to use */ 9086d7f5d3SJohn Marino u_int32_t peer_compproto; /* VJ params he's willing to use */ 9186d7f5d3SJohn Marino 9286d7f5d3SJohn Marino struct in_addr ifmask; /* Interface netmask */ 9386d7f5d3SJohn Marino 9486d7f5d3SJohn Marino struct in_addr my_ip; /* IP address I'm willing to use */ 9586d7f5d3SJohn Marino u_int32_t my_compproto; /* VJ params I'm willing to use */ 9686d7f5d3SJohn Marino 9786d7f5d3SJohn Marino u_int32_t peer_reject; /* Request codes rejected by peer */ 9886d7f5d3SJohn Marino u_int32_t my_reject; /* Request codes I have rejected */ 9986d7f5d3SJohn Marino 10086d7f5d3SJohn Marino struct pppThroughput throughput; /* throughput statistics */ 10186d7f5d3SJohn Marino struct mqueue Queue[3]; /* Output packet queues */ 10286d7f5d3SJohn Marino }; 10386d7f5d3SJohn Marino 10486d7f5d3SJohn Marino #define fsm2ipcp(fp) (fp->proto == PROTO_IPCP ? (struct ipcp *)fp : NULL) 10586d7f5d3SJohn Marino #define IPCP_QUEUES(ipcp) (sizeof ipcp->Queue / sizeof ipcp->Queue[0]) 10686d7f5d3SJohn Marino 10786d7f5d3SJohn Marino struct bundle; 10886d7f5d3SJohn Marino struct link; 10986d7f5d3SJohn Marino struct cmdargs; 11086d7f5d3SJohn Marino struct iface_addr; 11186d7f5d3SJohn Marino 11286d7f5d3SJohn Marino extern void ipcp_Init(struct ipcp *, struct bundle *, struct link *, 11386d7f5d3SJohn Marino const struct fsm_parent *); 11486d7f5d3SJohn Marino extern void ipcp_Destroy(struct ipcp *); 11586d7f5d3SJohn Marino extern void ipcp_Setup(struct ipcp *, u_int32_t); 11686d7f5d3SJohn Marino extern void ipcp_SetLink(struct ipcp *, struct link *); 11786d7f5d3SJohn Marino 11886d7f5d3SJohn Marino extern int ipcp_Show(struct cmdargs const *); 11986d7f5d3SJohn Marino extern struct mbuf *ipcp_Input(struct bundle *, struct link *, struct mbuf *); 12086d7f5d3SJohn Marino extern void ipcp_AddInOctets(struct ipcp *, int); 12186d7f5d3SJohn Marino extern void ipcp_AddOutOctets(struct ipcp *, int); 12286d7f5d3SJohn Marino extern int ipcp_UseHisIPaddr(struct bundle *, struct in_addr); 12386d7f5d3SJohn Marino extern int ipcp_UseHisaddr(struct bundle *, const char *, int); 12486d7f5d3SJohn Marino extern int ipcp_vjset(struct cmdargs const *); 12586d7f5d3SJohn Marino extern void ipcp_IfaceAddrAdded(struct ipcp *, const struct iface_addr *); 12686d7f5d3SJohn Marino extern void ipcp_IfaceAddrDeleted(struct ipcp *, const struct iface_addr *); 12786d7f5d3SJohn Marino extern int ipcp_InterfaceUp(struct ipcp *); 12886d7f5d3SJohn Marino extern struct in_addr addr2mask(struct in_addr); 12986d7f5d3SJohn Marino extern int ipcp_WriteDNS(struct ipcp *); 13086d7f5d3SJohn Marino extern void ipcp_RestoreDNS(struct ipcp *); 13186d7f5d3SJohn Marino extern void ipcp_LoadDNS(struct ipcp *); 13286d7f5d3SJohn Marino extern size_t ipcp_QueueLen(struct ipcp *); 13386d7f5d3SJohn Marino extern int ipcp_PushPacket(struct ipcp *, struct link *); 134