1 /*****************************************************************************
2 * ppp.h - Network Point to Point Protocol header file.
4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 * portions Copyright (c) 1997 Global Election Systems Inc.
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.
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.
25 ******************************************************************************
28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
30 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
31 * Original derived from BSD codes.
32 *****************************************************************************/
39 #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
43 #include "lwip/stats.h"
45 #include "lwip/netif.h"
47 #include "lwip/timers.h"
50 #ifndef __u_char_defined
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
;
61 /*************************
62 *** PUBLIC DEFINITIONS ***
63 *************************/
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. */
80 * Get the up status - 0 for down, non-zero for up. The argument must
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 */
88 /************************
89 *** PUBLIC DATA TYPES ***
90 ************************/
93 ip_addr_t our_ipaddr
, his_ipaddr
, netmask
, dns1
, dns2
;
97 /***********************
98 *** PUBLIC FUNCTIONS ***
99 ***********************/
101 /* Initialize the PPP subsystem. */
104 /* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
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
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.
130 void pppSetAuth(enum pppAuthType authType
, const char *user
, const char *passwd
);
132 /* Link status callback function prototype */
133 typedef void (*pppLinkStatusCB_fn
)(void *ctx
, int errCode
, void *arg
);
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.
143 int pppOverSerialOpen(sio_fd_t fd
, pppLinkStatusCB_fn linkStatusCB
, void *linkStatusCtx
);
144 #endif /* PPPOS_SUPPORT */
148 * Open a new PPP Over Ethernet (PPPOE) connection.
150 int pppOverEthernetOpen(struct netif
*ethif
, const char *service_name
, const char *concentrator_name
,
151 pppLinkStatusCB_fn linkStatusCB
, void *linkStatusCtx
);
152 #endif /* PPPOE_SUPPORT */
154 /* for source code compatibility */
155 #define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls)
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.
162 int pppClose(int pd
);
165 * Indicate to the PPP process that the line has disconnected.
167 void pppSigHUP(int pd
);
170 * Get and set parameters for the given connection.
171 * Return 0 on success, an error code on failure.
173 int pppIOCtl(int pd
, int cmd
, void *arg
);
176 * Return the Maximum Transmission Unit for the given PPP connection.
178 u_short
pppMTU(int pd
);
180 #if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD
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.
186 void pppos_input(int pd
, u_char
* data
, int len
);
187 #endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */
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 */
199 #endif /* PPP_SUPPORT */