1 | /*****************************************************************************
|
---|
2 | * ppp.h - Network Point to Point Protocol header file.
|
---|
3 | *
|
---|
4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
---|
5 | * portions Copyright (c) 1997 Global Election Systems Inc.
|
---|
6 | *
|
---|
7 | * The authors hereby grant permission to use, copy, modify, distribute,
|
---|
8 | * and license this software and its documentation for any purpose, provided
|
---|
9 | * that existing copyright notices are retained in all copies and that this
|
---|
10 | * notice and the following disclaimer are included verbatim in any
|
---|
11 | * distributions. No written agreement, license, or royalty fee is required
|
---|
12 | * for any of the authorized uses.
|
---|
13 | *
|
---|
14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
|
---|
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
24 | *
|
---|
25 | ******************************************************************************
|
---|
26 | * REVISION HISTORY
|
---|
27 | *
|
---|
28 | * 03-01-01 Marc Boucher <marc@mbsi.ca>
|
---|
29 | * Ported to lwIP.
|
---|
30 | * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
|
---|
31 | * Original derived from BSD codes.
|
---|
32 | *****************************************************************************/
|
---|
33 |
|
---|
34 | #ifndef PPP_H
|
---|
35 | #define PPP_H
|
---|
36 |
|
---|
37 | #include "lwip/opt.h"
|
---|
38 |
|
---|
39 | #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
---|
40 |
|
---|
41 | #include "lwip/def.h"
|
---|
42 | #include "lwip/sio.h"
|
---|
43 | #include "lwip/stats.h"
|
---|
44 | #include "lwip/mem.h"
|
---|
45 | #include "lwip/netif.h"
|
---|
46 | #include "lwip/sys.h"
|
---|
47 | #include "lwip/timers.h"
|
---|
48 |
|
---|
49 |
|
---|
50 | #ifndef __u_char_defined
|
---|
51 |
|
---|
52 | /* Type definitions for BSD code. */
|
---|
53 | typedef unsigned long u_long;
|
---|
54 | typedef unsigned int u_int;
|
---|
55 | typedef unsigned short u_short;
|
---|
56 | typedef unsigned char u_char;
|
---|
57 |
|
---|
58 | #endif
|
---|
59 |
|
---|
60 |
|
---|
61 | /*************************
|
---|
62 | *** PUBLIC DEFINITIONS ***
|
---|
63 | *************************/
|
---|
64 |
|
---|
65 | /* Error codes. */
|
---|
66 | #define PPPERR_NONE 0 /* No error. */
|
---|
67 | #define PPPERR_PARAM -1 /* Invalid parameter. */
|
---|
68 | #define PPPERR_OPEN -2 /* Unable to open PPP session. */
|
---|
69 | #define PPPERR_DEVICE -3 /* Invalid I/O device for PPP. */
|
---|
70 | #define PPPERR_ALLOC -4 /* Unable to allocate resources. */
|
---|
71 | #define PPPERR_USER -5 /* User interrupt. */
|
---|
72 | #define PPPERR_CONNECT -6 /* Connection lost. */
|
---|
73 | #define PPPERR_AUTHFAIL -7 /* Failed authentication challenge. */
|
---|
74 | #define PPPERR_PROTOCOL -8 /* Failed to meet protocol. */
|
---|
75 |
|
---|
76 | /*
|
---|
77 | * PPP IOCTL commands.
|
---|
78 | */
|
---|
79 | /*
|
---|
80 | * Get the up status - 0 for down, non-zero for up. The argument must
|
---|
81 | * point to an int.
|
---|
82 | */
|
---|
83 | #define PPPCTLG_UPSTATUS 100 /* Get the up status - 0 down else up */
|
---|
84 | #define PPPCTLS_ERRCODE 101 /* Set the error code */
|
---|
85 | #define PPPCTLG_ERRCODE 102 /* Get the error code */
|
---|
86 | #define PPPCTLG_FD 103 /* Get the fd associated with the ppp */
|
---|
87 |
|
---|
88 | /************************
|
---|
89 | *** PUBLIC DATA TYPES ***
|
---|
90 | ************************/
|
---|
91 |
|
---|
92 | struct ppp_addrs {
|
---|
93 | ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2;
|
---|
94 | };
|
---|
95 |
|
---|
96 |
|
---|
97 | /***********************
|
---|
98 | *** PUBLIC FUNCTIONS ***
|
---|
99 | ***********************/
|
---|
100 |
|
---|
101 | /* Initialize the PPP subsystem. */
|
---|
102 | void pppInit(void);
|
---|
103 |
|
---|
104 | /* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
|
---|
105 | * RFC 1994 says:
|
---|
106 | *
|
---|
107 | * In practice, within or associated with each PPP server, there is a
|
---|
108 | * database which associates "user" names with authentication
|
---|
109 | * information ("secrets"). It is not anticipated that a particular
|
---|
110 | * named user would be authenticated by multiple methods. This would
|
---|
111 | * make the user vulnerable to attacks which negotiate the least secure
|
---|
112 | * method from among a set (such as PAP rather than CHAP). If the same
|
---|
113 | * secret was used, PAP would reveal the secret to be used later with
|
---|
114 | * CHAP.
|
---|
115 | *
|
---|
116 | * Instead, for each user name there should be an indication of exactly
|
---|
117 | * one method used to authenticate that user name. If a user needs to
|
---|
118 | * make use of different authentication methods under different
|
---|
119 | * circumstances, then distinct user names SHOULD be employed, each of
|
---|
120 | * which identifies exactly one authentication method.
|
---|
121 | *
|
---|
122 | */
|
---|
123 | enum pppAuthType {
|
---|
124 | PPPAUTHTYPE_NONE,
|
---|
125 | PPPAUTHTYPE_ANY,
|
---|
126 | PPPAUTHTYPE_PAP,
|
---|
127 | PPPAUTHTYPE_CHAP
|
---|
128 | };
|
---|
129 |
|
---|
130 | void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd);
|
---|
131 |
|
---|
132 | /* Link status callback function prototype */
|
---|
133 | typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg);
|
---|
134 |
|
---|
135 | #if PPPOS_SUPPORT
|
---|
136 | /*
|
---|
137 | * Open a new PPP connection using the given serial I/O device.
|
---|
138 | * This initializes the PPP control block but does not
|
---|
139 | * attempt to negotiate the LCP session.
|
---|
140 | * Return a new PPP connection descriptor on success or
|
---|
141 | * an error code (negative) on failure.
|
---|
142 | */
|
---|
143 | int pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
|
---|
144 | #endif /* PPPOS_SUPPORT */
|
---|
145 |
|
---|
146 | #if PPPOE_SUPPORT
|
---|
147 | /*
|
---|
148 | * Open a new PPP Over Ethernet (PPPOE) connection.
|
---|
149 | */
|
---|
150 | int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name,
|
---|
151 | pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
|
---|
152 | #endif /* PPPOE_SUPPORT */
|
---|
153 |
|
---|
154 | /* for source code compatibility */
|
---|
155 | #define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls)
|
---|
156 |
|
---|
157 | /*
|
---|
158 | * Close a PPP connection and release the descriptor.
|
---|
159 | * Any outstanding packets in the queues are dropped.
|
---|
160 | * Return 0 on success, an error code on failure.
|
---|
161 | */
|
---|
162 | int pppClose(int pd);
|
---|
163 |
|
---|
164 | /*
|
---|
165 | * Indicate to the PPP process that the line has disconnected.
|
---|
166 | */
|
---|
167 | void pppSigHUP(int pd);
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * Get and set parameters for the given connection.
|
---|
171 | * Return 0 on success, an error code on failure.
|
---|
172 | */
|
---|
173 | int pppIOCtl(int pd, int cmd, void *arg);
|
---|
174 |
|
---|
175 | /*
|
---|
176 | * Return the Maximum Transmission Unit for the given PPP connection.
|
---|
177 | */
|
---|
178 | u_short pppMTU(int pd);
|
---|
179 |
|
---|
180 | #if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD
|
---|
181 | /*
|
---|
182 | * PPP over Serial: this is the input function to be called for received data.
|
---|
183 | * If PPP_INPROC_OWNTHREAD==1, a seperate input thread using the blocking
|
---|
184 | * sio_read() is used, so this is deactivated.
|
---|
185 | */
|
---|
186 | void pppos_input(int pd, u_char* data, int len);
|
---|
187 | #endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */
|
---|
188 |
|
---|
189 |
|
---|
190 | #if LWIP_NETIF_STATUS_CALLBACK
|
---|
191 | /* Set an lwIP-style status-callback for the selected PPP device */
|
---|
192 | void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback);
|
---|
193 | #endif /* LWIP_NETIF_STATUS_CALLBACK */
|
---|
194 | #if LWIP_NETIF_LINK_CALLBACK
|
---|
195 | /* Set an lwIP-style link-callback for the selected PPP device */
|
---|
196 | void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback);
|
---|
197 | #endif /* LWIP_NETIF_LINK_CALLBACK */
|
---|
198 |
|
---|
199 | #endif /* PPP_SUPPORT */
|
---|
200 |
|
---|
201 | #endif /* PPP_H */
|
---|