SAMV71 Xplained Ultra Software Package 1.0

ppp.h

00001 /*****************************************************************************
00002 * ppp.h - Network Point to Point Protocol header file.
00003 *
00004 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
00005 * portions Copyright (c) 1997 Global Election Systems Inc.
00006 *
00007 * The authors hereby grant permission to use, copy, modify, distribute,
00008 * and license this software and its documentation for any purpose, provided
00009 * that existing copyright notices are retained in all copies and that this
00010 * notice and the following disclaimer are included verbatim in any 
00011 * distributions. No written agreement, license, or royalty fee is required
00012 * for any of the authorized uses.
00013 *
00014 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
00015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
00017 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00024 *
00025 ******************************************************************************
00026 * REVISION HISTORY
00027 *
00028 * 03-01-01 Marc Boucher <marc@mbsi.ca>
00029 *   Ported to lwIP.
00030 * 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
00031 *   Original derived from BSD codes.
00032 *****************************************************************************/
00033 
00034 #ifndef PPP_H
00035 #define PPP_H
00036 
00037 #include "lwip/opt.h"
00038 
00039 #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
00040 
00041 #include "lwip/def.h"
00042 #include "lwip/sio.h"
00043 #include "lwip/stats.h"
00044 #include "lwip/mem.h"
00045 #include "lwip/netif.h"
00046 #include "lwip/sys.h"
00047 #include "lwip/timers.h"
00048 
00049 
00050 #ifndef __u_char_defined
00051 
00052 /* Type definitions for BSD code. */
00053 typedef unsigned long  u_long;
00054 typedef unsigned int   u_int;
00055 typedef unsigned short u_short;
00056 typedef unsigned char  u_char;
00057 
00058 #endif
00059 
00060 
00061 /*************************
00062 *** PUBLIC DEFINITIONS ***
00063 *************************/
00064 
00065 /* Error codes. */
00066 #define PPPERR_NONE      0 /* No error. */
00067 #define PPPERR_PARAM    -1 /* Invalid parameter. */
00068 #define PPPERR_OPEN     -2 /* Unable to open PPP session. */
00069 #define PPPERR_DEVICE   -3 /* Invalid I/O device for PPP. */
00070 #define PPPERR_ALLOC    -4 /* Unable to allocate resources. */
00071 #define PPPERR_USER     -5 /* User interrupt. */
00072 #define PPPERR_CONNECT  -6 /* Connection lost. */
00073 #define PPPERR_AUTHFAIL -7 /* Failed authentication challenge. */
00074 #define PPPERR_PROTOCOL -8 /* Failed to meet protocol. */
00075 
00076 /*
00077  * PPP IOCTL commands.
00078  */
00079 /*
00080  * Get the up status - 0 for down, non-zero for up.  The argument must
00081  * point to an int.
00082  */
00083 #define PPPCTLG_UPSTATUS 100 /* Get the up status - 0 down else up */
00084 #define PPPCTLS_ERRCODE  101 /* Set the error code */
00085 #define PPPCTLG_ERRCODE  102 /* Get the error code */
00086 #define PPPCTLG_FD       103 /* Get the fd associated with the ppp */
00087 
00088 /************************
00089 *** PUBLIC DATA TYPES ***
00090 ************************/
00091 
00092 struct ppp_addrs {
00093   ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2;
00094 };
00095 
00096 
00097 /***********************
00098 *** PUBLIC FUNCTIONS ***
00099 ***********************/
00100 
00101 /* Initialize the PPP subsystem. */
00102 void pppInit(void);
00103 
00104 /* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
00105  * RFC 1994 says:
00106  *
00107  * In practice, within or associated with each PPP server, there is a
00108  * database which associates "user" names with authentication
00109  * information ("secrets").  It is not anticipated that a particular
00110  * named user would be authenticated by multiple methods.  This would
00111  * make the user vulnerable to attacks which negotiate the least secure
00112  * method from among a set (such as PAP rather than CHAP).  If the same
00113  * secret was used, PAP would reveal the secret to be used later with
00114  * CHAP.
00115  *
00116  * Instead, for each user name there should be an indication of exactly
00117  * one method used to authenticate that user name.  If a user needs to
00118  * make use of different authentication methods under different
00119  * circumstances, then distinct user names SHOULD be employed, each of
00120  * which identifies exactly one authentication method.
00121  *
00122  */
00123 enum pppAuthType {
00124     PPPAUTHTYPE_NONE,
00125     PPPAUTHTYPE_ANY,
00126     PPPAUTHTYPE_PAP,
00127     PPPAUTHTYPE_CHAP
00128 };
00129 
00130 void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd);
00131 
00132 /* Link status callback function prototype */
00133 typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg);
00134 
00135 #if PPPOS_SUPPORT
00136 /*
00137  * Open a new PPP connection using the given serial I/O device.
00138  * This initializes the PPP control block but does not
00139  * attempt to negotiate the LCP session.
00140  * Return a new PPP connection descriptor on success or
00141  * an error code (negative) on failure. 
00142  */
00143 int pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
00144 #endif /* PPPOS_SUPPORT */
00145 
00146 #if PPPOE_SUPPORT
00147 /*
00148  * Open a new PPP Over Ethernet (PPPOE) connection.
00149  */
00150 int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name,
00151                         pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
00152 #endif /* PPPOE_SUPPORT */
00153 
00154 /* for source code compatibility */
00155 #define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls)
00156 
00157 /*
00158  * Close a PPP connection and release the descriptor. 
00159  * Any outstanding packets in the queues are dropped.
00160  * Return 0 on success, an error code on failure. 
00161  */
00162 int pppClose(int pd);
00163 
00164 /*
00165  * Indicate to the PPP process that the line has disconnected.
00166  */
00167 void pppSigHUP(int pd);
00168 
00169 /*
00170  * Get and set parameters for the given connection.
00171  * Return 0 on success, an error code on failure. 
00172  */
00173 int  pppIOCtl(int pd, int cmd, void *arg);
00174 
00175 /*
00176  * Return the Maximum Transmission Unit for the given PPP connection.
00177  */
00178 u_short pppMTU(int pd);
00179 
00180 #if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD
00181 /*
00182  * PPP over Serial: this is the input function to be called for received data.
00183  * If PPP_INPROC_OWNTHREAD==1, a seperate input thread using the blocking
00184  * sio_read() is used, so this is deactivated.
00185  */
00186 void pppos_input(int pd, u_char* data, int len);
00187 #endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */
00188 
00189 
00190 #if LWIP_NETIF_STATUS_CALLBACK
00191 /* Set an lwIP-style status-callback for the selected PPP device */
00192 void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback);
00193 #endif /* LWIP_NETIF_STATUS_CALLBACK */
00194 #if LWIP_NETIF_LINK_CALLBACK
00195 /* Set an lwIP-style link-callback for the selected PPP device */
00196 void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback);
00197 #endif /* LWIP_NETIF_LINK_CALLBACK */
00198 
00199 #endif /* PPP_SUPPORT */
00200 
00201 #endif /* PPP_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines