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