]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/ppp/ipcp.h
This commit was generated by cvs2svn to compensate for changes in r80062,
[FreeBSD/FreeBSD.git] / usr.sbin / ppp / ipcp.h
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$
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
45 struct sticky_route;
46
47 struct in_range {
48   struct in_addr ipaddr;
49   struct in_addr mask;
50   int width;
51 };
52
53 struct port_range {
54   unsigned nports;              /* How many ports */
55   unsigned maxports;            /* How many allocated (malloc) ports */
56   u_short *port;                /* The actual ports */
57 };
58
59 struct ipcp {
60   struct fsm fsm;                       /* The finite state machine */
61
62   struct {
63     struct {
64       int slots;                        /* Maximum VJ slots */
65       unsigned slotcomp : 1;            /* Slot compression */
66       unsigned neg : 2;                 /* VJ negotiation */
67     } vj;
68
69     struct in_range  my_range;          /* MYADDR spec */
70     struct in_addr   netmask;           /* Iface netmask (unused by most OSs) */
71     struct in_range  peer_range;        /* HISADDR spec */
72     struct iplist    peer_list;         /* Ranges of HISADDR values */
73
74     u_long sendpipe;                    /* route sendpipe size */
75     u_long recvpipe;                    /* route recvpipe size */
76
77     struct in_addr   TriggerAddress;    /* Address to suggest in REQ */
78     unsigned HaveTriggerAddress : 1;    /* Trigger address specified */
79
80     struct {
81       struct in_addr dns[2];            /* DNS addresses offered */
82       unsigned dns_neg : 2;             /* dns negotiation */
83       struct in_addr nbns[2];           /* NetBIOS NS addresses offered */
84     } ns;
85
86     struct {
87       struct port_range tcp, udp;       /* The range of urgent ports */
88       unsigned tos : 1;                 /* Urgent IPTOS_LOWDELAY packets ? */
89     } urgent;
90
91     struct fsm_retry fsm;       /* How often/frequently to resend requests */
92   } cfg;
93
94   struct {
95     struct slcompress cslc;             /* VJ state */
96     struct slstat slstat;               /* VJ statistics */
97   } vj;
98
99   struct {
100     unsigned resolver : 1;              /* Found resolv.conf ? */
101     unsigned writable : 1;              /* Can write resolv.conf ? */
102     struct in_addr dns[2];              /* Current DNS addresses */
103     char *resolv;                       /* Contents of resolv.conf */
104     char *resolv_nons;                  /* Contents of resolv.conf without ns */
105   } ns;
106
107   struct sticky_route *route;           /* List of dynamic routes */
108
109   unsigned heis1172 : 1;                /* True if he is speaking rfc1172 */
110
111   struct in_addr peer_ip;               /* IP address he's willing to use */
112   u_int32_t peer_compproto;             /* VJ params he's willing to use */
113
114   struct in_addr ifmask;                /* Interface netmask */
115
116   struct in_addr my_ip;                 /* IP address I'm willing to use */
117   u_int32_t my_compproto;               /* VJ params I'm willing to use */
118
119   struct in_addr dns[2];                /* DNSs to REQ/ACK */
120
121   u_int32_t peer_reject;                /* Request codes rejected by peer */
122   u_int32_t my_reject;                  /* Request codes I have rejected */
123
124   struct pppThroughput throughput;      /* throughput statistics */
125   struct mqueue Queue[3];               /* Output packet queues */
126 };
127
128 #define fsm2ipcp(fp) (fp->proto == PROTO_IPCP ? (struct ipcp *)fp : NULL)
129 #define IPCP_QUEUES(ipcp) (sizeof ipcp->Queue / sizeof ipcp->Queue[0])
130
131 struct bundle;
132 struct link;
133 struct cmdargs;
134
135 extern void ipcp_Init(struct ipcp *, struct bundle *, struct link *,
136                       const struct fsm_parent *);
137 extern void ipcp_Destroy(struct ipcp *);
138 extern void ipcp_Setup(struct ipcp *, u_int32_t);
139 extern void ipcp_SetLink(struct ipcp *, struct link *);
140
141 extern int  ipcp_Show(struct cmdargs const *);
142 extern struct mbuf *ipcp_Input(struct bundle *, struct link *, struct mbuf *);
143 extern void ipcp_AddInOctets(struct ipcp *, int);
144 extern void ipcp_AddOutOctets(struct ipcp *, int);
145 extern int  ipcp_UseHisIPaddr(struct bundle *, struct in_addr);
146 extern int  ipcp_UseHisaddr(struct bundle *, const char *, int);
147 extern int  ipcp_vjset(struct cmdargs const *);
148 extern void ipcp_CleanInterface(struct ipcp *);
149 extern int  ipcp_InterfaceUp(struct ipcp *);
150 extern int  ipcp_IsUrgentPort(struct port_range *, u_short, u_short);
151 extern void ipcp_AddUrgentPort(struct port_range *, u_short);
152 extern void ipcp_RemoveUrgentPort(struct port_range *, u_short);
153 extern void ipcp_ClearUrgentPorts(struct port_range *);
154 extern struct in_addr addr2mask(struct in_addr);
155 extern int ipcp_WriteDNS(struct ipcp *);
156 extern void ipcp_RestoreDNS(struct ipcp *);
157 extern void ipcp_LoadDNS(struct ipcp *);
158
159 #define ipcp_IsUrgentTcpPort(ipcp, p1, p2) \
160           ipcp_IsUrgentPort(&(ipcp)->cfg.urgent.tcp, p1, p2)
161 #define ipcp_IsUrgentUdpPort(ipcp, p1, p2) \
162           ipcp_IsUrgentPort(&(ipcp)->cfg.urgent.udp, p1, p2)
163 #define ipcp_AddUrgentTcpPort(ipcp, p) \
164           ipcp_AddUrgentPort(&(ipcp)->cfg.urgent.tcp, p)
165 #define ipcp_AddUrgentUdpPort(ipcp, p) \
166           ipcp_AddUrgentPort(&(ipcp)->cfg.urgent.udp, p)
167 #define ipcp_RemoveUrgentTcpPort(ipcp, p) \
168           ipcp_RemoveUrgentPort(&(ipcp)->cfg.urgent.tcp, p)
169 #define ipcp_RemoveUrgentUdpPort(ipcp, p) \
170           ipcp_RemoveUrgentPort(&(ipcp)->cfg.urgent.udp, p)
171 #define ipcp_ClearUrgentTcpPorts(ipcp) \
172           ipcp_ClearUrgentPorts(&(ipcp)->cfg.urgent.tcp)
173 #define ipcp_ClearUrgentUdpPorts(ipcp) \
174           ipcp_ClearUrgentPorts(&(ipcp)->cfg.urgent.udp)
175 #define ipcp_ClearUrgentTOS(ipcp) (ipcp)->cfg.urgent.tos = 0;
176 #define ipcp_SetUrgentTOS(ipcp) (ipcp)->cfg.urgent.tos = 1;