Ethernet for Nucleo and Disco board STM32F746 works with gcc and arm. IAC is untested
Fork of F7_Ethernet by
ppp_impl.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_IMPL_H 00035 #define PPP_IMPL_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 "ppp.h" 00042 #include "lwip/def.h" 00043 #include "lwip/sio.h" 00044 #include "lwip/stats.h" 00045 #include "lwip/mem.h" 00046 #include "lwip/netif.h" 00047 #include "lwip/sys.h" 00048 #include "lwip/timers.h" 00049 00050 /** Some defines for code we skip compared to the original pppd. 00051 * These are just here to minimise the use of the ugly "#if 0". */ 00052 #define PPP_ADDITIONAL_CALLBACKS 0 00053 00054 /** Some error checks to test for unsupported code */ 00055 #if CBCP_SUPPORT 00056 #error "CBCP is not supported in lwIP PPP" 00057 #endif 00058 #if CCP_SUPPORT 00059 #error "CCP is not supported in lwIP PPP" 00060 #endif 00061 00062 /* 00063 * pppd.h - PPP daemon global declarations. 00064 * 00065 * Copyright (c) 1989 Carnegie Mellon University. 00066 * All rights reserved. 00067 * 00068 * Redistribution and use in source and binary forms are permitted 00069 * provided that the above copyright notice and this paragraph are 00070 * duplicated in all such forms and that any documentation, 00071 * advertising materials, and other materials related to such 00072 * distribution and use acknowledge that the software was developed 00073 * by Carnegie Mellon University. The name of the 00074 * University may not be used to endorse or promote products derived 00075 * from this software without specific prior written permission. 00076 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 00077 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 00078 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00079 * 00080 */ 00081 /* 00082 * ppp_defs.h - PPP definitions. 00083 * 00084 * Copyright (c) 1994 The Australian National University. 00085 * All rights reserved. 00086 * 00087 * Permission to use, copy, modify, and distribute this software and its 00088 * documentation is hereby granted, provided that the above copyright 00089 * notice appears in all copies. This software is provided without any 00090 * warranty, express or implied. The Australian National University 00091 * makes no representations about the suitability of this software for 00092 * any purpose. 00093 * 00094 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY 00095 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 00096 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 00097 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY 00098 * OF SUCH DAMAGE. 00099 * 00100 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00101 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00102 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00103 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO 00104 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, 00105 * OR MODIFICATIONS. 00106 */ 00107 00108 #define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0) 00109 #define UNTIMEOUT(f, a) sys_untimeout((f), (a)) 00110 00111 00112 /* 00113 * Constants and structures defined by the internet system, 00114 * Per RFC 790, September 1981, and numerous additions. 00115 */ 00116 00117 /* 00118 * The basic PPP frame. 00119 */ 00120 #define PPP_HDRLEN 4 /* octets for standard ppp header */ 00121 #define PPP_FCSLEN 2 /* octets for FCS */ 00122 00123 00124 /* 00125 * Significant octet values. 00126 */ 00127 #define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ 00128 #define PPP_UI 0x03 /* Unnumbered Information */ 00129 #define PPP_FLAG 0x7e /* Flag Sequence */ 00130 #define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ 00131 #define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ 00132 00133 /* 00134 * Protocol field values. 00135 */ 00136 #define PPP_IP 0x21 /* Internet Protocol */ 00137 #define PPP_AT 0x29 /* AppleTalk Protocol */ 00138 #define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ 00139 #define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ 00140 #define PPP_COMP 0xfd /* compressed packet */ 00141 #define PPP_IPCP 0x8021 /* IP Control Protocol */ 00142 #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ 00143 #define PPP_CCP 0x80fd /* Compression Control Protocol */ 00144 #define PPP_LCP 0xc021 /* Link Control Protocol */ 00145 #define PPP_PAP 0xc023 /* Password Authentication Protocol */ 00146 #define PPP_LQR 0xc025 /* Link Quality Report protocol */ 00147 #define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ 00148 #define PPP_CBCP 0xc029 /* Callback Control Protocol */ 00149 00150 /* 00151 * Values for FCS calculations. 00152 */ 00153 #define PPP_INITFCS 0xffff /* Initial FCS value */ 00154 #define PPP_GOODFCS 0xf0b8 /* Good final FCS value */ 00155 #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) 00156 00157 /* 00158 * Extended asyncmap - allows any character to be escaped. 00159 */ 00160 typedef u_char ext_accm[32]; 00161 00162 /* 00163 * What to do with network protocol (NP) packets. 00164 */ 00165 enum NPmode { 00166 NPMODE_PASS, /* pass the packet through */ 00167 NPMODE_DROP, /* silently drop the packet */ 00168 NPMODE_ERROR, /* return an error */ 00169 NPMODE_QUEUE /* save it up for later. */ 00170 }; 00171 00172 /* 00173 * Inline versions of get/put char/short/long. 00174 * Pointer is advanced; we assume that both arguments 00175 * are lvalues and will already be in registers. 00176 * cp MUST be u_char *. 00177 */ 00178 #define GETCHAR(c, cp) { \ 00179 (c) = *(cp)++; \ 00180 } 00181 #define PUTCHAR(c, cp) { \ 00182 *(cp)++ = (u_char) (c); \ 00183 } 00184 00185 00186 #define GETSHORT(s, cp) { \ 00187 (s) = *(cp); (cp)++; (s) <<= 8; \ 00188 (s) |= *(cp); (cp)++; \ 00189 } 00190 #define PUTSHORT(s, cp) { \ 00191 *(cp)++ = (u_char) ((s) >> 8); \ 00192 *(cp)++ = (u_char) (s & 0xff); \ 00193 } 00194 00195 #define GETLONG(l, cp) { \ 00196 (l) = *(cp); (cp)++; (l) <<= 8; \ 00197 (l) |= *(cp); (cp)++; (l) <<= 8; \ 00198 (l) |= *(cp); (cp)++; (l) <<= 8; \ 00199 (l) |= *(cp); (cp)++; \ 00200 } 00201 #define PUTLONG(l, cp) { \ 00202 *(cp)++ = (u_char) ((l) >> 24); \ 00203 *(cp)++ = (u_char) ((l) >> 16); \ 00204 *(cp)++ = (u_char) ((l) >> 8); \ 00205 *(cp)++ = (u_char) (l); \ 00206 } 00207 00208 00209 #define INCPTR(n, cp) ((cp) += (n)) 00210 #define DECPTR(n, cp) ((cp) -= (n)) 00211 00212 #define BCMP(s0, s1, l) memcmp((u_char *)(s0), (u_char *)(s1), (l)) 00213 #define BCOPY(s, d, l) MEMCPY((d), (s), (l)) 00214 #define BZERO(s, n) memset(s, 0, n) 00215 00216 #if PPP_DEBUG 00217 #define PRINTMSG(m, l) { m[l] = '\0'; LWIP_DEBUGF(LOG_INFO, ("Remote message: %s\n", m)); } 00218 #else /* PPP_DEBUG */ 00219 #define PRINTMSG(m, l) 00220 #endif /* PPP_DEBUG */ 00221 00222 /* 00223 * MAKEHEADER - Add PPP Header fields to a packet. 00224 */ 00225 #define MAKEHEADER(p, t) { \ 00226 PUTCHAR(PPP_ALLSTATIONS, p); \ 00227 PUTCHAR(PPP_UI, p); \ 00228 PUTSHORT(t, p); } 00229 00230 /************************ 00231 *** PUBLIC DATA TYPES *** 00232 ************************/ 00233 00234 /* 00235 * The following struct gives the addresses of procedures to call 00236 * for a particular protocol. 00237 */ 00238 struct protent { 00239 u_short protocol; /* PPP protocol number */ 00240 /* Initialization procedure */ 00241 void (*init) (int unit); 00242 /* Process a received packet */ 00243 void (*input) (int unit, u_char *pkt, int len); 00244 /* Process a received protocol-reject */ 00245 void (*protrej) (int unit); 00246 /* Lower layer has come up */ 00247 void (*lowerup) (int unit); 00248 /* Lower layer has gone down */ 00249 void (*lowerdown) (int unit); 00250 /* Open the protocol */ 00251 void (*open) (int unit); 00252 /* Close the protocol */ 00253 void (*close) (int unit, char *reason); 00254 #if PPP_ADDITIONAL_CALLBACKS 00255 /* Print a packet in readable form */ 00256 int (*printpkt) (u_char *pkt, int len, 00257 void (*printer) (void *, char *, ...), 00258 void *arg); 00259 /* Process a received data packet */ 00260 void (*datainput) (int unit, u_char *pkt, int len); 00261 #endif /* PPP_ADDITIONAL_CALLBACKS */ 00262 int enabled_flag; /* 0 if protocol is disabled */ 00263 char *name; /* Text name of protocol */ 00264 #if PPP_ADDITIONAL_CALLBACKS 00265 /* Check requested options, assign defaults */ 00266 void (*check_options) (u_long); 00267 /* Configure interface for demand-dial */ 00268 int (*demand_conf) (int unit); 00269 /* Say whether to bring up link for this pkt */ 00270 int (*active_pkt) (u_char *pkt, int len); 00271 #endif /* PPP_ADDITIONAL_CALLBACKS */ 00272 }; 00273 00274 /* 00275 * The following structure records the time in seconds since 00276 * the last NP packet was sent or received. 00277 */ 00278 struct ppp_idle { 00279 u_short xmit_idle; /* seconds since last NP packet sent */ 00280 u_short recv_idle; /* seconds since last NP packet received */ 00281 }; 00282 00283 struct ppp_settings { 00284 00285 u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */ 00286 u_int auth_required : 1; /* Peer is required to authenticate */ 00287 u_int explicit_remote : 1; /* remote_name specified with remotename opt */ 00288 u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */ 00289 u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */ 00290 u_int usehostname : 1; /* Use hostname for our_name */ 00291 u_int usepeerdns : 1; /* Ask peer for DNS adds */ 00292 00293 u_short idle_time_limit; /* Shut down link if idle for this long */ 00294 int maxconnect; /* Maximum connect time (seconds) */ 00295 00296 char user [MAXNAMELEN + 1]; /* Username for PAP */ 00297 char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */ 00298 char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */ 00299 char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */ 00300 }; 00301 00302 /***************************** 00303 *** PUBLIC DATA STRUCTURES *** 00304 *****************************/ 00305 00306 /* Buffers for outgoing packets. */ 00307 extern u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN]; 00308 00309 extern struct ppp_settings ppp_settings; 00310 00311 extern struct protent *ppp_protocols[]; /* Table of pointers to supported protocols */ 00312 00313 00314 /*********************** 00315 *** PUBLIC FUNCTIONS *** 00316 ***********************/ 00317 00318 /* 00319 * Write n characters to a ppp link. 00320 * RETURN: >= 0 Number of characters written, -1 Failed to write to device. 00321 */ 00322 int pppWrite(int pd, const u_char *s, int n); 00323 00324 void pppInProcOverEthernet(int pd, struct pbuf *pb); 00325 00326 struct pbuf *pppSingleBuf(struct pbuf *p); 00327 00328 void pppLinkTerminated(int pd); 00329 00330 void pppLinkDown(int pd); 00331 00332 /* Configure i/f transmit parameters */ 00333 void ppp_send_config (int, u16_t, u32_t, int, int); 00334 /* Set extended transmit ACCM */ 00335 void ppp_set_xaccm (int, ext_accm *); 00336 /* Configure i/f receive parameters */ 00337 void ppp_recv_config (int, int, u32_t, int, int); 00338 /* Find out how long link has been idle */ 00339 int get_idle_time (int, struct ppp_idle *); 00340 00341 /* Configure VJ TCP header compression */ 00342 int sifvjcomp (int, int, u8_t, u8_t); 00343 /* Configure i/f down (for IP) */ 00344 int sifup (int); 00345 /* Set mode for handling packets for proto */ 00346 int sifnpmode (int u, int proto, enum NPmode mode); 00347 /* Configure i/f down (for IP) */ 00348 int sifdown (int); 00349 /* Configure IP addresses for i/f */ 00350 int sifaddr (int, u32_t, u32_t, u32_t, u32_t, u32_t); 00351 /* Reset i/f IP addresses */ 00352 int cifaddr (int, u32_t, u32_t); 00353 /* Create default route through i/f */ 00354 int sifdefaultroute (int, u32_t, u32_t); 00355 /* Delete default route through i/f */ 00356 int cifdefaultroute (int, u32_t, u32_t); 00357 00358 /* Get appropriate netmask for address */ 00359 u32_t GetMask (u32_t); 00360 00361 #endif /* PPP_SUPPORT */ 00362 00363 #endif /* PPP_IMPL_H */
Generated on Tue Jul 12 2022 21:19:02 by 1.7.2