ipcp.h revision 78189
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: head/usr.sbin/ppp/ipcp.h 78189 2001-06-13 21:52:19Z brian $ 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 sticky_route; 4618752Sjkh 476059Samuraistruct in_range { 486059Samurai struct in_addr ipaddr; 496059Samurai struct in_addr mask; 5028679Sbrian int width; 516059Samurai}; 526059Samurai 5351048Sbrianstruct port_range { 5451048Sbrian unsigned nports; /* How many ports */ 5551048Sbrian unsigned maxports; /* How many allocated (malloc) ports */ 5651048Sbrian u_short *port; /* The actual ports */ 5751048Sbrian}; 5851048Sbrian 5936285Sbrianstruct ipcp { 6036285Sbrian struct fsm fsm; /* The finite state machine */ 616059Samurai 6236285Sbrian struct { 6336285Sbrian struct { 6436285Sbrian int slots; /* Maximum VJ slots */ 6536285Sbrian unsigned slotcomp : 1; /* Slot compression */ 6636285Sbrian unsigned neg : 2; /* VJ negotiation */ 6736285Sbrian } vj; 6836285Sbrian 6936285Sbrian struct in_range my_range; /* MYADDR spec */ 7043313Sbrian struct in_addr netmask; /* Iface netmask (unused by most OSs) */ 7136285Sbrian struct in_range peer_range; /* HISADDR spec */ 7236285Sbrian struct iplist peer_list; /* Ranges of HISADDR values */ 7336285Sbrian 7440665Sbrian u_long sendpipe; /* route sendpipe size */ 7540665Sbrian u_long recvpipe; /* route recvpipe size */ 7640665Sbrian 7736285Sbrian struct in_addr TriggerAddress; /* Address to suggest in REQ */ 7836285Sbrian unsigned HaveTriggerAddress : 1; /* Trigger address specified */ 7936285Sbrian 8036285Sbrian struct { 8136285Sbrian struct in_addr dns[2]; /* DNS addresses offered */ 8236285Sbrian unsigned dns_neg : 2; /* dns negotiation */ 8336285Sbrian struct in_addr nbns[2]; /* NetBIOS NS addresses offered */ 8436285Sbrian } ns; 8536285Sbrian 8650867Sbrian struct { 8751048Sbrian struct port_range tcp, udp; /* The range of urgent ports */ 8861430Sbrian unsigned tos : 1; /* Urgent IPTOS_LOWDELAY packets ? */ 8950867Sbrian } urgent; 9050867Sbrian 9144305Sbrian struct fsm_retry fsm; /* How often/frequently to resend requests */ 9236285Sbrian } cfg; 9336285Sbrian 9436285Sbrian struct { 9536285Sbrian struct slcompress cslc; /* VJ state */ 9636285Sbrian struct slstat slstat; /* VJ statistics */ 9736285Sbrian } vj; 9836285Sbrian 9958044Sbrian struct { 10058044Sbrian unsigned resolver : 1; /* Found resolv.conf ? */ 10158044Sbrian unsigned writable : 1; /* Can write resolv.conf ? */ 10258044Sbrian struct in_addr dns[2]; /* Current DNS addresses */ 10358044Sbrian char *resolv; /* Contents of resolv.conf */ 10458044Sbrian char *resolv_nons; /* Contents of resolv.conf without ns */ 10558044Sbrian } ns; 10658044Sbrian 10736285Sbrian struct sticky_route *route; /* List of dynamic routes */ 10836285Sbrian 10936285Sbrian unsigned heis1172 : 1; /* True if he is speaking rfc1172 */ 11036285Sbrian 11136285Sbrian struct in_addr peer_ip; /* IP address he's willing to use */ 11236285Sbrian u_int32_t peer_compproto; /* VJ params he's willing to use */ 11336285Sbrian 11443313Sbrian struct in_addr ifmask; /* Interface netmask */ 11543313Sbrian 11636285Sbrian struct in_addr my_ip; /* IP address I'm willing to use */ 11736285Sbrian u_int32_t my_compproto; /* VJ params I'm willing to use */ 11836285Sbrian 11958044Sbrian struct in_addr dns[2]; /* DNSs to REQ/ACK */ 12058044Sbrian 12136285Sbrian u_int32_t peer_reject; /* Request codes rejected by peer */ 12236285Sbrian u_int32_t my_reject; /* Request codes I have rejected */ 12336285Sbrian 12436285Sbrian struct pppThroughput throughput; /* throughput statistics */ 12551062Sbrian struct mqueue Queue[3]; /* Output packet queues */ 12636285Sbrian}; 12736285Sbrian 12836285Sbrian#define fsm2ipcp(fp) (fp->proto == PROTO_IPCP ? (struct ipcp *)fp : NULL) 12950867Sbrian#define IPCP_QUEUES(ipcp) (sizeof ipcp->Queue / sizeof ipcp->Queue[0]) 13036285Sbrian 13136285Sbrianstruct bundle; 13236285Sbrianstruct link; 13336285Sbrianstruct cmdargs; 13436285Sbrian 13536285Sbrianextern void ipcp_Init(struct ipcp *, struct bundle *, struct link *, 13636285Sbrian const struct fsm_parent *); 13750867Sbrianextern void ipcp_Destroy(struct ipcp *); 13843313Sbrianextern void ipcp_Setup(struct ipcp *, u_int32_t); 13936285Sbrianextern void ipcp_SetLink(struct ipcp *, struct link *); 14036285Sbrian 14136285Sbrianextern int ipcp_Show(struct cmdargs const *); 14246686Sbrianextern struct mbuf *ipcp_Input(struct bundle *, struct link *, struct mbuf *); 14336285Sbrianextern void ipcp_AddInOctets(struct ipcp *, int); 14436285Sbrianextern void ipcp_AddOutOctets(struct ipcp *, int); 14543313Sbrianextern int ipcp_UseHisIPaddr(struct bundle *, struct in_addr); 14636285Sbrianextern int ipcp_UseHisaddr(struct bundle *, const char *, int); 14736285Sbrianextern int ipcp_vjset(struct cmdargs const *); 14836285Sbrianextern void ipcp_CleanInterface(struct ipcp *); 14936285Sbrianextern int ipcp_InterfaceUp(struct ipcp *); 15051048Sbrianextern int ipcp_IsUrgentPort(struct port_range *, u_short, u_short); 15151048Sbrianextern void ipcp_AddUrgentPort(struct port_range *, u_short); 15251048Sbrianextern void ipcp_RemoveUrgentPort(struct port_range *, u_short); 15351048Sbrianextern void ipcp_ClearUrgentPorts(struct port_range *); 15444455Sbrianextern struct in_addr addr2mask(struct in_addr); 15558044Sbrianextern int ipcp_WriteDNS(struct ipcp *); 15658044Sbrianextern void ipcp_RestoreDNS(struct ipcp *); 15758044Sbrianextern void ipcp_LoadDNS(struct ipcp *); 15851048Sbrian 15951048Sbrian#define ipcp_IsUrgentTcpPort(ipcp, p1, p2) \ 16051048Sbrian ipcp_IsUrgentPort(&(ipcp)->cfg.urgent.tcp, p1, p2) 16151048Sbrian#define ipcp_IsUrgentUdpPort(ipcp, p1, p2) \ 16251048Sbrian ipcp_IsUrgentPort(&(ipcp)->cfg.urgent.udp, p1, p2) 16351048Sbrian#define ipcp_AddUrgentTcpPort(ipcp, p) \ 16451048Sbrian ipcp_AddUrgentPort(&(ipcp)->cfg.urgent.tcp, p) 16551048Sbrian#define ipcp_AddUrgentUdpPort(ipcp, p) \ 16651048Sbrian ipcp_AddUrgentPort(&(ipcp)->cfg.urgent.udp, p) 16751048Sbrian#define ipcp_RemoveUrgentTcpPort(ipcp, p) \ 16851048Sbrian ipcp_RemoveUrgentPort(&(ipcp)->cfg.urgent.tcp, p) 16951048Sbrian#define ipcp_RemoveUrgentUdpPort(ipcp, p) \ 17051048Sbrian ipcp_RemoveUrgentPort(&(ipcp)->cfg.urgent.udp, p) 17151048Sbrian#define ipcp_ClearUrgentTcpPorts(ipcp) \ 17251048Sbrian ipcp_ClearUrgentPorts(&(ipcp)->cfg.urgent.tcp) 17351048Sbrian#define ipcp_ClearUrgentUdpPorts(ipcp) \ 17451048Sbrian ipcp_ClearUrgentPorts(&(ipcp)->cfg.urgent.udp) 17561430Sbrian#define ipcp_ClearUrgentTOS(ipcp) (ipcp)->cfg.urgent.tos = 0; 17661430Sbrian#define ipcp_SetUrgentTOS(ipcp) (ipcp)->cfg.urgent.tos = 1; 177