1/*- 2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 4 * Internet Initiative Japan, Inc (IIJ) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD: src/usr.sbin/ppp/ipcp.h,v 1.35.40.1 2010/12/21 17:10:29 kensmith Exp $ 29 */ 30 31#define IPCP_MAXCODE CODE_CODEREJ 32 33#define TY_IPADDRS 1 34#define TY_COMPPROTO 2 35#define TY_IPADDR 3 36 37/* Domain NameServer and NetBIOS NameServer options */ 38 39#define TY_PRIMARY_DNS 129 40#define TY_PRIMARY_NBNS 130 41#define TY_SECONDARY_DNS 131 42#define TY_SECONDARY_NBNS 132 43#define TY_ADJUST_NS 119 /* subtract from NS val for REJECT bit */ 44 45struct ipcp { 46 struct fsm fsm; /* The finite state machine */ 47 48 struct { 49 struct { 50 int slots; /* Maximum VJ slots */ 51 unsigned slotcomp : 1; /* Slot compression */ 52 unsigned neg : 2; /* VJ negotiation */ 53 } vj; 54 55 struct ncprange my_range; /* MYADDR spec */ 56 struct in_addr netmask; /* Iface netmask (unused by most OSs) */ 57 struct ncprange peer_range; /* HISADDR spec */ 58 struct iplist peer_list; /* Ranges of HISADDR values */ 59 60 struct in_addr TriggerAddress; /* Address to suggest in REQ */ 61 unsigned HaveTriggerAddress : 1; /* Trigger address specified */ 62 63 struct { 64 struct in_addr dns[2]; /* DNS addresses offered */ 65 unsigned dns_neg : 2; /* dns negotiation */ 66 struct in_addr nbns[2]; /* NetBIOS NS addresses offered */ 67 } ns; 68 69 struct fsm_retry fsm; /* frequency to resend requests */ 70 } cfg; 71 72 struct { 73 struct slcompress cslc; /* VJ state */ 74 struct slstat slstat; /* VJ statistics */ 75 } vj; 76 77 struct { 78 unsigned resolver : 1; /* Found resolv.conf ? */ 79 unsigned writable : 1; /* Can write resolv.conf ? */ 80 struct in_addr dns[2]; /* Current DNS addresses */ 81 char *resolv; /* Contents of resolv.conf */ 82 char *resolv_nons; /* Contents of resolv.conf without ns */ 83 } ns; 84 85 unsigned heis1172 : 1; /* True if he is speaking rfc1172 */ 86 87 unsigned peer_req : 1; /* Any TY_IPADDR REQs from the peer ? */ 88 struct in_addr peer_ip; /* IP address he's willing to use */ 89 u_int32_t peer_compproto; /* VJ params he's willing to use */ 90 91 struct in_addr ifmask; /* Interface netmask */ 92 93 struct in_addr my_ip; /* IP address I'm willing to use */ 94 u_int32_t my_compproto; /* VJ params I'm willing to use */ 95 96 u_int32_t peer_reject; /* Request codes rejected by peer */ 97 u_int32_t my_reject; /* Request codes I have rejected */ 98 99 struct pppThroughput throughput; /* throughput statistics */ 100 struct mqueue Queue[3]; /* Output packet queues */ 101}; 102 103#define fsm2ipcp(fp) (fp->proto == PROTO_IPCP ? (struct ipcp *)fp : NULL) 104#define IPCP_QUEUES(ipcp) (sizeof ipcp->Queue / sizeof ipcp->Queue[0]) 105 106struct bundle; 107struct link; 108struct cmdargs; 109struct iface_addr; 110 111extern void ipcp_Init(struct ipcp *, struct bundle *, struct link *, 112 const struct fsm_parent *); 113extern void ipcp_Destroy(struct ipcp *); 114extern void ipcp_Setup(struct ipcp *, u_int32_t); 115extern void ipcp_SetLink(struct ipcp *, struct link *); 116 117extern int ipcp_Show(struct cmdargs const *); 118extern struct mbuf *ipcp_Input(struct bundle *, struct link *, struct mbuf *); 119extern void ipcp_AddInOctets(struct ipcp *, int); 120extern void ipcp_AddOutOctets(struct ipcp *, int); 121extern int ipcp_UseHisIPaddr(struct bundle *, struct in_addr); 122extern int ipcp_UseHisaddr(struct bundle *, const char *, int); 123extern int ipcp_vjset(struct cmdargs const *); 124extern void ipcp_IfaceAddrAdded(struct ipcp *, const struct iface_addr *); 125extern void ipcp_IfaceAddrDeleted(struct ipcp *, const struct iface_addr *); 126extern int ipcp_InterfaceUp(struct ipcp *); 127extern struct in_addr addr2mask(struct in_addr); 128extern int ipcp_WriteDNS(struct ipcp *); 129extern void ipcp_RestoreDNS(struct ipcp *); 130extern void ipcp_LoadDNS(struct ipcp *); 131extern size_t ipcp_QueueLen(struct ipcp *); 132extern int ipcp_PushPacket(struct ipcp *, struct link *); 133