ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

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