mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
more lwIP physical interfaces (#6680)
This commit adds W5500 W5100 and ENC28j60 drivers from @njh with credits They are available in libraries/ An example is added in W5500 examples directory plus: * Extract dhcp server from lwip2 and add it to the core as a class. It must always be present, it is linked and can be called by fw on boot. So it cannot be stored in a library. * ethernet: static or dhcp works * PPPServer: example * bring WiFi.config() to the lwIP generic interface (argument reorder common function) * move hostname() from WiFI-STA to generic interface * remove non readable characters from dhcp-server comments * dhcp-server: magic_cookie is part of bootp rfc * fixes from https://github.com/d-a-v/W5500lwIP/issues/17 * enable lwip_hook_dhcp_parse_option() * +ethernet tcp client example in w5500 library examples
This commit is contained in:
Submodule tools/sdk/lwip2/builder updated: 8dfe4663f2...7d498d9d39
@ -63,6 +63,7 @@ typedef uint32_t sys_prot_t;
|
||||
#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev
|
||||
#define SYS_ARCH_PROTECT(lev) lev = lwip_xt_rsil(15)
|
||||
#define SYS_ARCH_UNPROTECT(lev) lwip_xt_wsr_ps(lev)
|
||||
#define sys_jiffies() (0) // only used for increased randomness in PPP
|
||||
|
||||
#define LWIP_NO_CTYPE_H 1
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// generated by makefiles/make-lwip2-hash
|
||||
#ifndef LWIP_HASH_H
|
||||
#define LWIP_HASH_H
|
||||
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-43-ge20f213"
|
||||
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-46-g7d498d9"
|
||||
#endif // LWIP_HASH_H
|
||||
|
@ -357,7 +357,7 @@ extern struct tcp_pcb ** const tcp_pcb_lists[NUM_TCP_PCB_LISTS];
|
||||
#if TCP_DEBUG_PCB_LISTS
|
||||
#define TCP_REG(pcbs, npcb) do {\
|
||||
struct tcp_pcb *tcp_tmp_pcb; \
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %"U16_F"\n", (void *)(npcb), (npcb)->local_port)); \
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %" U16_F "\n", (void *)(npcb), (npcb)->local_port)); \
|
||||
for (tcp_tmp_pcb = *(pcbs); \
|
||||
tcp_tmp_pcb != NULL; \
|
||||
tcp_tmp_pcb = tcp_tmp_pcb->next) { \
|
||||
|
@ -3139,7 +3139,7 @@
|
||||
* u8_t *ptr = (u8_t*)pbuf_get_contiguous(p, buf, sizeof(buf), LWIP_MIN(option_len, sizeof(buf)), offset);
|
||||
*/
|
||||
#ifdef __DOXYGEN__
|
||||
#define LWIP_HOOK_DHCP_PARSE_OPTION(netif, dhcp, state, msg, msg_type, option, len, pbuf, offset)
|
||||
//#define LWIP_HOOK_DHCP_PARSE_OPTION(netif, dhcp, state, msg, msg_type, option, len, pbuf, offset)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -3551,6 +3551,12 @@
|
||||
#error LWIP_FEATURES must be defined
|
||||
#endif
|
||||
|
||||
#define PPPOS_SUPPORT IP_NAPT // because we don't have proxyarp yet
|
||||
#define PPP_SUPPORT PPPOS_SUPPORT
|
||||
#define PPP_SERVER 1
|
||||
#define PPP_DEBUG ULWIPDEBUG
|
||||
#define PRINTPKT_SUPPORT ULWIPDEBUG
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -3560,6 +3566,24 @@ extern "C" {
|
||||
*/
|
||||
#define TCP_RANDOM_PORT 1
|
||||
|
||||
/*
|
||||
--------------------------------------------------
|
||||
------------------ DHCP options ------------------
|
||||
--------------------------------------------------
|
||||
*/
|
||||
|
||||
#define LWIP_HOOK_DHCP_PARSE_OPTION(netif, dhcp, state, msg, msg_type, option, len, pbuf, option_value_offset) \
|
||||
lwip_hook_dhcp_parse_option(netif, dhcp, state, msg, msg_type, option, len, pbuf, option_value_offset)
|
||||
|
||||
// search for LWIP_HOOK_DHCP_PARSE_OPTION above for an arguments explanation
|
||||
struct netif;
|
||||
struct dhcp;
|
||||
struct dhcp_msg;
|
||||
struct pbuf;
|
||||
extern void lwip_hook_dhcp_parse_option(struct netif *netif, struct dhcp *dhcp, int state, struct dhcp_msg *msg,
|
||||
int msg_type, int option, int option_len, struct pbuf *pbuf,
|
||||
int option_value_offset);
|
||||
|
||||
/*
|
||||
--------------------------------------------------
|
||||
------------------ SNTP options ------------------
|
||||
|
182
tools/sdk/lwip2/include/netif/ppp/fsm.h
Normal file
182
tools/sdk/lwip2/include/netif/ppp/fsm.h
Normal file
@ -0,0 +1,182 @@
|
||||
/*
|
||||
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: fsm.h,v 1.10 2004/11/13 02:28:15 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "netif/ppp/ppp_opts.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef FSM_H
|
||||
#define FSM_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define HEADERLEN 4
|
||||
|
||||
|
||||
/*
|
||||
* CP (LCP, IPCP, etc.) codes.
|
||||
*/
|
||||
#define CONFREQ 1 /* Configuration Request */
|
||||
#define CONFACK 2 /* Configuration Ack */
|
||||
#define CONFNAK 3 /* Configuration Nak */
|
||||
#define CONFREJ 4 /* Configuration Reject */
|
||||
#define TERMREQ 5 /* Termination Request */
|
||||
#define TERMACK 6 /* Termination Ack */
|
||||
#define CODEREJ 7 /* Code Reject */
|
||||
|
||||
|
||||
/*
|
||||
* Each FSM is described by an fsm structure and fsm callbacks.
|
||||
*/
|
||||
typedef struct fsm {
|
||||
ppp_pcb *pcb; /* PPP Interface */
|
||||
const struct fsm_callbacks *callbacks; /* Callback routines */
|
||||
const char *term_reason; /* Reason for closing protocol */
|
||||
u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */
|
||||
/* -- This is our only flag, we might use u_int :1 if we have more flags */
|
||||
u16_t protocol; /* Data Link Layer Protocol field value */
|
||||
u8_t state; /* State */
|
||||
u8_t flags; /* Contains option bits */
|
||||
u8_t id; /* Current id */
|
||||
u8_t reqid; /* Current request id */
|
||||
u8_t retransmits; /* Number of retransmissions left */
|
||||
u8_t nakloops; /* Number of nak loops since last ack */
|
||||
u8_t rnakloops; /* Number of naks received */
|
||||
u8_t maxnakloops; /* Maximum number of nak loops tolerated
|
||||
(necessary because IPCP require a custom large max nak loops value) */
|
||||
u8_t term_reason_len; /* Length of term_reason */
|
||||
} fsm;
|
||||
|
||||
|
||||
typedef struct fsm_callbacks {
|
||||
void (*resetci) /* Reset our Configuration Information */
|
||||
(fsm *);
|
||||
int (*cilen) /* Length of our Configuration Information */
|
||||
(fsm *);
|
||||
void (*addci) /* Add our Configuration Information */
|
||||
(fsm *, u_char *, int *);
|
||||
int (*ackci) /* ACK our Configuration Information */
|
||||
(fsm *, u_char *, int);
|
||||
int (*nakci) /* NAK our Configuration Information */
|
||||
(fsm *, u_char *, int, int);
|
||||
int (*rejci) /* Reject our Configuration Information */
|
||||
(fsm *, u_char *, int);
|
||||
int (*reqci) /* Request peer's Configuration Information */
|
||||
(fsm *, u_char *, int *, int);
|
||||
void (*up) /* Called when fsm reaches PPP_FSM_OPENED state */
|
||||
(fsm *);
|
||||
void (*down) /* Called when fsm leaves PPP_FSM_OPENED state */
|
||||
(fsm *);
|
||||
void (*starting) /* Called when we want the lower layer */
|
||||
(fsm *);
|
||||
void (*finished) /* Called when we don't want the lower layer */
|
||||
(fsm *);
|
||||
void (*protreject) /* Called when Protocol-Reject received */
|
||||
(int);
|
||||
void (*retransmit) /* Retransmission is necessary */
|
||||
(fsm *);
|
||||
int (*extcode) /* Called when unknown code received */
|
||||
(fsm *, int, int, u_char *, int);
|
||||
const char *proto_name; /* String name for protocol (for messages) */
|
||||
} fsm_callbacks;
|
||||
|
||||
|
||||
/*
|
||||
* Link states.
|
||||
*/
|
||||
#define PPP_FSM_INITIAL 0 /* Down, hasn't been opened */
|
||||
#define PPP_FSM_STARTING 1 /* Down, been opened */
|
||||
#define PPP_FSM_CLOSED 2 /* Up, hasn't been opened */
|
||||
#define PPP_FSM_STOPPED 3 /* Open, waiting for down event */
|
||||
#define PPP_FSM_CLOSING 4 /* Terminating the connection, not open */
|
||||
#define PPP_FSM_STOPPING 5 /* Terminating, but open */
|
||||
#define PPP_FSM_REQSENT 6 /* We've sent a Config Request */
|
||||
#define PPP_FSM_ACKRCVD 7 /* We've received a Config Ack */
|
||||
#define PPP_FSM_ACKSENT 8 /* We've sent a Config Ack */
|
||||
#define PPP_FSM_OPENED 9 /* Connection available */
|
||||
|
||||
|
||||
/*
|
||||
* Flags - indicate options controlling FSM operation
|
||||
*/
|
||||
#define OPT_PASSIVE 1 /* Don't die if we don't get a response */
|
||||
#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
|
||||
#define OPT_SILENT 4 /* Wait for peer to speak first */
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#if 0 /* moved to ppp_opts.h */
|
||||
#define DEFTIMEOUT 3 /* Timeout time in seconds */
|
||||
#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
|
||||
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
|
||||
#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
|
||||
#endif /* moved to ppp_opts.h */
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void fsm_init(fsm *f);
|
||||
void fsm_lowerup(fsm *f);
|
||||
void fsm_lowerdown(fsm *f);
|
||||
void fsm_open(fsm *f);
|
||||
void fsm_close(fsm *f, const char *reason);
|
||||
void fsm_input(fsm *f, u_char *inpacket, int l);
|
||||
void fsm_protreject(fsm *f);
|
||||
void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FSM_H */
|
||||
#endif /* PPP_SUPPORT */
|
134
tools/sdk/lwip2/include/netif/ppp/ipcp.h
Normal file
134
tools/sdk/lwip2/include/netif/ppp/ipcp.h
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ipcp.h,v 1.14 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
#include "netif/ppp/ppp_opts.h"
|
||||
#if PPP_SUPPORT && PPP_IPV4_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef IPCP_H
|
||||
#define IPCP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_ADDRS 1 /* IP Addresses */
|
||||
#if VJ_SUPPORT
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
#endif /* VJ_SUPPORT */
|
||||
#define CI_ADDR 3
|
||||
|
||||
#if LWIP_DNS
|
||||
#define CI_MS_DNS1 129 /* Primary DNS value */
|
||||
#define CI_MS_DNS2 131 /* Secondary DNS value */
|
||||
#endif /* LWIP_DNS */
|
||||
#if 0 /* UNUSED - WINS */
|
||||
#define CI_MS_WINS1 130 /* Primary WINS value */
|
||||
#define CI_MS_WINS2 132 /* Secondary WINS value */
|
||||
#endif /* UNUSED - WINS */
|
||||
|
||||
#if VJ_SUPPORT
|
||||
#define MAX_STATES 16 /* from slcompress.h */
|
||||
|
||||
#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
|
||||
#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */
|
||||
#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */
|
||||
/* maxslot and slot number compression) */
|
||||
|
||||
#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/
|
||||
#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */
|
||||
/* compression option*/
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
typedef struct ipcp_options {
|
||||
unsigned int neg_addr :1; /* Negotiate IP Address? */
|
||||
unsigned int old_addrs :1; /* Use old (IP-Addresses) option? */
|
||||
unsigned int req_addr :1; /* Ask peer to send IP address? */
|
||||
#if 0 /* UNUSED */
|
||||
unsigned int default_route :1; /* Assign default route through interface? */
|
||||
unsigned int replace_default_route :1; /* Replace default route through interface? */
|
||||
#endif /* UNUSED */
|
||||
#if 0 /* UNUSED - PROXY ARP */
|
||||
unsigned int proxy_arp :1; /* Make proxy ARP entry for peer? */
|
||||
#endif /* UNUSED - PROXY ARP */
|
||||
#if VJ_SUPPORT
|
||||
unsigned int neg_vj :1; /* Van Jacobson Compression? */
|
||||
unsigned int old_vj :1; /* use old (short) form of VJ option? */
|
||||
unsigned int cflag :1;
|
||||
#endif /* VJ_SUPPORT */
|
||||
unsigned int accept_local :1; /* accept peer's value for ouraddr */
|
||||
unsigned int accept_remote :1; /* accept peer's value for hisaddr */
|
||||
#if LWIP_DNS
|
||||
unsigned int req_dns1 :1; /* Ask peer to send primary DNS address? */
|
||||
unsigned int req_dns2 :1; /* Ask peer to send secondary DNS address? */
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
|
||||
#if LWIP_DNS
|
||||
u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
|
||||
#endif /* LWIP_DNS */
|
||||
#if 0 /* UNUSED - WINS */
|
||||
u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
|
||||
#endif /* UNUSED - WINS */
|
||||
|
||||
#if VJ_SUPPORT
|
||||
u16_t vj_protocol; /* protocol value to use in VJ option */
|
||||
u8_t maxslotindex; /* values for RFC1332 VJ compression neg. */
|
||||
#endif /* VJ_SUPPORT */
|
||||
} ipcp_options;
|
||||
|
||||
#if 0 /* UNUSED, already defined by lwIP */
|
||||
char *ip_ntoa (u32_t);
|
||||
#endif /* UNUSED, already defined by lwIP */
|
||||
|
||||
extern const struct protent ipcp_protent;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPCP_H */
|
||||
#endif /* PPP_SUPPORT && PPP_IPV4_SUPPORT */
|
179
tools/sdk/lwip2/include/netif/ppp/lcp.h
Normal file
179
tools/sdk/lwip2/include/netif/ppp/lcp.h
Normal file
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* lcp.h - Link Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: lcp.h,v 1.20 2004/11/14 22:53:42 carlsonj Exp $
|
||||
*/
|
||||
|
||||
#include "netif/ppp/ppp_opts.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef LCP_H
|
||||
#define LCP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_VENDOR 0 /* Vendor Specific */
|
||||
#define CI_MRU 1 /* Maximum Receive Unit */
|
||||
#define CI_ASYNCMAP 2 /* Async Control Character Map */
|
||||
#define CI_AUTHTYPE 3 /* Authentication Type */
|
||||
#define CI_QUALITY 4 /* Quality Protocol */
|
||||
#define CI_MAGICNUMBER 5 /* Magic Number */
|
||||
#define CI_PCOMPRESSION 7 /* Protocol Field Compression */
|
||||
#define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */
|
||||
#define CI_FCSALTERN 9 /* FCS-Alternatives */
|
||||
#define CI_SDP 10 /* Self-Describing-Pad */
|
||||
#define CI_NUMBERED 11 /* Numbered-Mode */
|
||||
#define CI_CALLBACK 13 /* callback */
|
||||
#define CI_MRRU 17 /* max reconstructed receive unit; multilink */
|
||||
#define CI_SSNHF 18 /* short sequence numbers for multilink */
|
||||
#define CI_EPDISC 19 /* endpoint discriminator */
|
||||
#define CI_MPPLUS 22 /* Multi-Link-Plus-Procedure */
|
||||
#define CI_LDISC 23 /* Link-Discriminator */
|
||||
#define CI_LCPAUTH 24 /* LCP Authentication */
|
||||
#define CI_COBS 25 /* Consistent Overhead Byte Stuffing */
|
||||
#define CI_PREFELIS 26 /* Prefix Elision */
|
||||
#define CI_MPHDRFMT 27 /* MP Header Format */
|
||||
#define CI_I18N 28 /* Internationalization */
|
||||
#define CI_SDL 29 /* Simple Data Link */
|
||||
|
||||
/*
|
||||
* LCP-specific packet types (code numbers).
|
||||
*/
|
||||
#define PROTREJ 8 /* Protocol Reject */
|
||||
#define ECHOREQ 9 /* Echo Request */
|
||||
#define ECHOREP 10 /* Echo Reply */
|
||||
#define DISCREQ 11 /* Discard Request */
|
||||
#define IDENTIF 12 /* Identification */
|
||||
#define TIMEREM 13 /* Time Remaining */
|
||||
|
||||
/* Value used as data for CI_CALLBACK option */
|
||||
#define CBCP_OPT 6 /* Use callback control protocol */
|
||||
|
||||
#if 0 /* moved to ppp_opts.h */
|
||||
#define DEFMRU 1500 /* Try for this */
|
||||
#define MINMRU 128 /* No MRUs below this */
|
||||
#define MAXMRU 16384 /* Normally limit MRU to this */
|
||||
#endif /* moved to ppp_opts.h */
|
||||
|
||||
/* An endpoint discriminator, used with multilink. */
|
||||
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
||||
struct epdisc {
|
||||
unsigned char class_; /* -- The word "class" is reserved in C++. */
|
||||
unsigned char length;
|
||||
unsigned char value[MAX_ENDP_LEN];
|
||||
};
|
||||
|
||||
/*
|
||||
* The state of options is described by an lcp_options structure.
|
||||
*/
|
||||
typedef struct lcp_options {
|
||||
unsigned int passive :1; /* Don't die if we don't get a response */
|
||||
unsigned int silent :1; /* Wait for the other end to start first */
|
||||
#if 0 /* UNUSED */
|
||||
unsigned int restart :1; /* Restart vs. exit after close */
|
||||
#endif /* UNUSED */
|
||||
unsigned int neg_mru :1; /* Negotiate the MRU? */
|
||||
unsigned int neg_asyncmap :1; /* Negotiate the async map? */
|
||||
#if PAP_SUPPORT
|
||||
unsigned int neg_upap :1; /* Ask for UPAP authentication? */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
unsigned int neg_chap :1; /* Ask for CHAP authentication? */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
unsigned int neg_eap :1; /* Ask for EAP authentication? */
|
||||
#endif /* EAP_SUPPORT */
|
||||
unsigned int neg_magicnumber :1; /* Ask for magic number? */
|
||||
unsigned int neg_pcompression :1; /* HDLC Protocol Field Compression? */
|
||||
unsigned int neg_accompression :1; /* HDLC Address/Control Field Compression? */
|
||||
#if LQR_SUPPORT
|
||||
unsigned int neg_lqr :1; /* Negotiate use of Link Quality Reports */
|
||||
#endif /* LQR_SUPPORT */
|
||||
unsigned int neg_cbcp :1; /* Negotiate use of CBCP */
|
||||
#ifdef HAVE_MULTILINK
|
||||
unsigned int neg_mrru :1; /* negotiate multilink MRRU */
|
||||
#endif /* HAVE_MULTILINK */
|
||||
unsigned int neg_ssnhf :1; /* negotiate short sequence numbers */
|
||||
unsigned int neg_endpoint :1; /* negotiate endpoint discriminator */
|
||||
|
||||
u16_t mru; /* Value of MRU */
|
||||
#ifdef HAVE_MULTILINK
|
||||
u16_t mrru; /* Value of MRRU, and multilink enable */
|
||||
#endif /* MULTILINK */
|
||||
#if CHAP_SUPPORT
|
||||
u8_t chap_mdtype; /* which MD types (hashing algorithm) */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
u32_t asyncmap; /* Value of async map */
|
||||
u32_t magicnumber;
|
||||
u8_t numloops; /* Number of loops during magic number neg. */
|
||||
#if LQR_SUPPORT
|
||||
u32_t lqr_period; /* Reporting period for LQR 1/100ths second */
|
||||
#endif /* LQR_SUPPORT */
|
||||
struct epdisc endpoint; /* endpoint discriminator */
|
||||
} lcp_options;
|
||||
|
||||
void lcp_open(ppp_pcb *pcb);
|
||||
void lcp_close(ppp_pcb *pcb, const char *reason);
|
||||
void lcp_lowerup(ppp_pcb *pcb);
|
||||
void lcp_lowerdown(ppp_pcb *pcb);
|
||||
void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len); /* send protocol reject */
|
||||
|
||||
extern const struct protent lcp_protent;
|
||||
|
||||
#if 0 /* moved to ppp_opts.h */
|
||||
/* Default number of times we receive our magic number from the peer
|
||||
before deciding the link is looped-back. */
|
||||
#define DEFLOOPBACKFAIL 10
|
||||
#endif /* moved to ppp_opts.h */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LCP_H */
|
||||
#endif /* PPP_SUPPORT */
|
698
tools/sdk/lwip2/include/netif/ppp/ppp.h
Normal file
698
tools/sdk/lwip2/include/netif/ppp/ppp.h
Normal file
@ -0,0 +1,698 @@
|
||||
/*****************************************************************************
|
||||
* ppp.h - Network Point to Point Protocol header file.
|
||||
*
|
||||
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
|
||||
* portions Copyright (c) 1997 Global Election Systems Inc.
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice and the following disclaimer are included verbatim in any
|
||||
* distributions. No written agreement, license, or royalty fee is required
|
||||
* for any of the authorized uses.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 03-01-01 Marc Boucher <marc@mbsi.ca>
|
||||
* Ported to lwIP.
|
||||
* 97-11-05 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
|
||||
* Original derived from BSD codes.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "netif/ppp/ppp_opts.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPP_H
|
||||
#define PPP_H
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/timeouts.h"
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#include "lwip/ip6_addr.h"
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Disable non-working or rarely used PPP feature, so rarely that we don't want to bloat ppp_opts.h with them */
|
||||
#ifndef PPP_OPTIONS
|
||||
#define PPP_OPTIONS 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_NOTIFY
|
||||
#define PPP_NOTIFY 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_REMOTENAME
|
||||
#define PPP_REMOTENAME 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_IDLETIMELIMIT
|
||||
#define PPP_IDLETIMELIMIT 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_LCP_ADAPTIVE
|
||||
#define PPP_LCP_ADAPTIVE 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_MAXCONNECT
|
||||
#define PPP_MAXCONNECT 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_ALLOWED_ADDRS
|
||||
#define PPP_ALLOWED_ADDRS 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_PROTOCOLNAME
|
||||
#define PPP_PROTOCOLNAME 0
|
||||
#endif
|
||||
|
||||
#ifndef PPP_STATS_SUPPORT
|
||||
#define PPP_STATS_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef DEFLATE_SUPPORT
|
||||
#define DEFLATE_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef BSDCOMPRESS_SUPPORT
|
||||
#define BSDCOMPRESS_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#ifndef PREDICTOR_SUPPORT
|
||||
#define PREDICTOR_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/*************************
|
||||
*** PUBLIC DEFINITIONS ***
|
||||
*************************/
|
||||
|
||||
/*
|
||||
* The basic PPP frame.
|
||||
*/
|
||||
#define PPP_HDRLEN 4 /* octets for standard ppp header */
|
||||
#define PPP_FCSLEN 2 /* octets for FCS */
|
||||
|
||||
/*
|
||||
* Values for phase.
|
||||
*/
|
||||
#define PPP_PHASE_DEAD 0
|
||||
#define PPP_PHASE_MASTER 1
|
||||
#define PPP_PHASE_HOLDOFF 2
|
||||
#define PPP_PHASE_INITIALIZE 3
|
||||
#define PPP_PHASE_SERIALCONN 4
|
||||
#define PPP_PHASE_DORMANT 5
|
||||
#define PPP_PHASE_ESTABLISH 6
|
||||
#define PPP_PHASE_AUTHENTICATE 7
|
||||
#define PPP_PHASE_CALLBACK 8
|
||||
#define PPP_PHASE_NETWORK 9
|
||||
#define PPP_PHASE_RUNNING 10
|
||||
#define PPP_PHASE_TERMINATE 11
|
||||
#define PPP_PHASE_DISCONNECT 12
|
||||
|
||||
/* Error codes. */
|
||||
#define PPPERR_NONE 0 /* No error. */
|
||||
#define PPPERR_PARAM 1 /* Invalid parameter. */
|
||||
#define PPPERR_OPEN 2 /* Unable to open PPP session. */
|
||||
#define PPPERR_DEVICE 3 /* Invalid I/O device for PPP. */
|
||||
#define PPPERR_ALLOC 4 /* Unable to allocate resources. */
|
||||
#define PPPERR_USER 5 /* User interrupt. */
|
||||
#define PPPERR_CONNECT 6 /* Connection lost. */
|
||||
#define PPPERR_AUTHFAIL 7 /* Failed authentication challenge. */
|
||||
#define PPPERR_PROTOCOL 8 /* Failed to meet protocol. */
|
||||
#define PPPERR_PEERDEAD 9 /* Connection timeout */
|
||||
#define PPPERR_IDLETIMEOUT 10 /* Idle Timeout */
|
||||
#define PPPERR_CONNECTTIME 11 /* Max connect time reached */
|
||||
#define PPPERR_LOOPBACK 12 /* Loopback detected */
|
||||
|
||||
/* Whether auth support is enabled at all */
|
||||
#define PPP_AUTH_SUPPORT (PAP_SUPPORT || CHAP_SUPPORT || EAP_SUPPORT)
|
||||
|
||||
/************************
|
||||
*** PUBLIC DATA TYPES ***
|
||||
************************/
|
||||
|
||||
/*
|
||||
* Other headers require ppp_pcb definition for prototypes, but ppp_pcb
|
||||
* require some structure definition from other headers as well, we are
|
||||
* fixing the dependency loop here by declaring the ppp_pcb type then
|
||||
* by including headers containing necessary struct definition for ppp_pcb
|
||||
*/
|
||||
typedef struct ppp_pcb_s ppp_pcb;
|
||||
|
||||
/* Type definitions for BSD code. */
|
||||
#ifndef __u_char_defined
|
||||
typedef unsigned long u_long;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned char u_char;
|
||||
#endif
|
||||
|
||||
#include "fsm.h"
|
||||
#include "lcp.h"
|
||||
#if CCP_SUPPORT
|
||||
#include "ccp.h"
|
||||
#endif /* CCP_SUPPORT */
|
||||
#if MPPE_SUPPORT
|
||||
#include "mppe.h"
|
||||
#endif /* MPPE_SUPPORT */
|
||||
#if PPP_IPV4_SUPPORT
|
||||
#include "ipcp.h"
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
#include "ipv6cp.h"
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
#if PAP_SUPPORT
|
||||
#include "upap.h"
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
#include "chap-new.h"
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
#include "eap.h"
|
||||
#endif /* EAP_SUPPORT */
|
||||
#if VJ_SUPPORT
|
||||
#include "vj.h"
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
/* Link status callback function prototype */
|
||||
typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx);
|
||||
|
||||
/*
|
||||
* PPP configuration.
|
||||
*/
|
||||
typedef struct ppp_settings_s {
|
||||
|
||||
#if PPP_SERVER && PPP_AUTH_SUPPORT
|
||||
unsigned int auth_required :1; /* Peer is required to authenticate */
|
||||
unsigned int null_login :1; /* Username of "" and a password of "" are acceptable */
|
||||
#endif /* PPP_SERVER && PPP_AUTH_SUPPORT */
|
||||
#if PPP_REMOTENAME
|
||||
unsigned int explicit_remote :1; /* remote_name specified with remotename opt */
|
||||
#endif /* PPP_REMOTENAME */
|
||||
#if PAP_SUPPORT
|
||||
unsigned int refuse_pap :1; /* Don't proceed auth. with PAP */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
unsigned int refuse_chap :1; /* Don't proceed auth. with CHAP */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if MSCHAP_SUPPORT
|
||||
unsigned int refuse_mschap :1; /* Don't proceed auth. with MS-CHAP */
|
||||
unsigned int refuse_mschap_v2 :1; /* Don't proceed auth. with MS-CHAPv2 */
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
unsigned int refuse_eap :1; /* Don't proceed auth. with EAP */
|
||||
#endif /* EAP_SUPPORT */
|
||||
#if LWIP_DNS
|
||||
unsigned int usepeerdns :1; /* Ask peer for DNS adds */
|
||||
#endif /* LWIP_DNS */
|
||||
unsigned int persist :1; /* Persist mode, always try to open the connection */
|
||||
#if PRINTPKT_SUPPORT
|
||||
unsigned int hide_password :1; /* Hide password in dumped packets */
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
unsigned int noremoteip :1; /* Let him have no IP address */
|
||||
unsigned int lax_recv :1; /* accept control chars in asyncmap */
|
||||
unsigned int noendpoint :1; /* don't send/accept endpoint discriminator */
|
||||
#if PPP_LCP_ADAPTIVE
|
||||
unsigned int lcp_echo_adaptive :1; /* request echo only if the link was idle */
|
||||
#endif /* PPP_LCP_ADAPTIVE */
|
||||
#if MPPE_SUPPORT
|
||||
unsigned int require_mppe :1; /* Require MPPE (Microsoft Point to Point Encryption) */
|
||||
unsigned int refuse_mppe_40 :1; /* Allow MPPE 40-bit mode? */
|
||||
unsigned int refuse_mppe_128 :1; /* Allow MPPE 128-bit mode? */
|
||||
unsigned int refuse_mppe_stateful :1; /* Allow MPPE stateful mode? */
|
||||
#endif /* MPPE_SUPPORT */
|
||||
|
||||
u16_t listen_time; /* time to listen first (ms), waiting for peer to send LCP packet */
|
||||
|
||||
#if PPP_IDLETIMELIMIT
|
||||
u16_t idle_time_limit; /* Disconnect if idle for this many seconds */
|
||||
#endif /* PPP_IDLETIMELIMIT */
|
||||
#if PPP_MAXCONNECT
|
||||
u32_t maxconnect; /* Maximum connect time (seconds) */
|
||||
#endif /* PPP_MAXCONNECT */
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
/* auth data */
|
||||
const char *user; /* Username for PAP */
|
||||
const char *passwd; /* Password for PAP, secret for CHAP */
|
||||
#if PPP_REMOTENAME
|
||||
char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */
|
||||
#endif /* PPP_REMOTENAME */
|
||||
|
||||
#if PAP_SUPPORT
|
||||
u8_t pap_timeout_time; /* Timeout (seconds) for auth-req retrans. */
|
||||
u8_t pap_max_transmits; /* Number of auth-reqs sent */
|
||||
#if PPP_SERVER
|
||||
u8_t pap_req_timeout; /* Time to wait for auth-req from peer */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* PAP_SUPPPORT */
|
||||
|
||||
#if CHAP_SUPPORT
|
||||
u8_t chap_timeout_time; /* Timeout (seconds) for retransmitting req */
|
||||
u8_t chap_max_transmits; /* max # times to send challenge */
|
||||
#if PPP_SERVER
|
||||
u8_t chap_rechallenge_time; /* Time to wait for auth-req from peer */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* CHAP_SUPPPORT */
|
||||
|
||||
#if EAP_SUPPORT
|
||||
u8_t eap_req_time; /* Time to wait (for retransmit/fail) */
|
||||
u8_t eap_allow_req; /* Max Requests allowed */
|
||||
#if PPP_SERVER
|
||||
u8_t eap_timeout_time; /* Time to wait (for retransmit/fail) */
|
||||
u8_t eap_max_transmits; /* Max Requests allowed */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
u8_t fsm_timeout_time; /* Timeout time in seconds */
|
||||
u8_t fsm_max_conf_req_transmits; /* Maximum Configure-Request transmissions */
|
||||
u8_t fsm_max_term_transmits; /* Maximum Terminate-Request transmissions */
|
||||
u8_t fsm_max_nak_loops; /* Maximum number of nak loops tolerated */
|
||||
|
||||
u8_t lcp_loopbackfail; /* Number of times we receive our magic number from the peer
|
||||
before deciding the link is looped-back. */
|
||||
u8_t lcp_echo_interval; /* Interval between LCP echo-requests */
|
||||
u8_t lcp_echo_fails; /* Tolerance to unanswered echo-requests */
|
||||
|
||||
} ppp_settings;
|
||||
|
||||
#if PPP_SERVER
|
||||
struct ppp_addrs {
|
||||
#if PPP_IPV4_SUPPORT
|
||||
ip4_addr_t our_ipaddr, his_ipaddr, netmask;
|
||||
#if LWIP_DNS
|
||||
ip4_addr_t dns1, dns2;
|
||||
#endif /* LWIP_DNS */
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
ip6_addr_t our6_ipaddr, his6_ipaddr;
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
};
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/*
|
||||
* PPP interface control block.
|
||||
*/
|
||||
struct ppp_pcb_s {
|
||||
ppp_settings settings;
|
||||
const struct link_callbacks *link_cb;
|
||||
void *link_ctx_cb;
|
||||
void (*link_status_cb)(ppp_pcb *pcb, int err_code, void *ctx); /* Status change callback */
|
||||
#if PPP_NOTIFY_PHASE
|
||||
void (*notify_phase_cb)(ppp_pcb *pcb, u8_t phase, void *ctx); /* Notify phase callback */
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
void *ctx_cb; /* Callbacks optional pointer */
|
||||
struct netif *netif; /* PPP interface */
|
||||
u8_t phase; /* where the link is at */
|
||||
u8_t err_code; /* Code indicating why interface is down. */
|
||||
|
||||
/* flags */
|
||||
#if PPP_IPV4_SUPPORT
|
||||
unsigned int ask_for_local :1; /* request our address from peer */
|
||||
unsigned int ipcp_is_open :1; /* haven't called np_finished() */
|
||||
unsigned int ipcp_is_up :1; /* have called ipcp_up() */
|
||||
unsigned int if4_up :1; /* True when the IPv4 interface is up. */
|
||||
#if 0 /* UNUSED - PROXY ARP */
|
||||
unsigned int proxy_arp_set :1; /* Have created proxy arp entry */
|
||||
#endif /* UNUSED - PROXY ARP */
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
#if PPP_IPV6_SUPPORT
|
||||
unsigned int ipv6cp_is_up :1; /* have called ip6cp_up() */
|
||||
unsigned int if6_up :1; /* True when the IPv6 interface is up. */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
unsigned int lcp_echo_timer_running :1; /* set if a timer is running */
|
||||
#if VJ_SUPPORT
|
||||
unsigned int vj_enabled :1; /* Flag indicating VJ compression enabled. */
|
||||
#endif /* VJ_SUPPORT */
|
||||
#if CCP_SUPPORT
|
||||
unsigned int ccp_all_rejected :1; /* we rejected all peer's options */
|
||||
#endif /* CCP_SUPPORT */
|
||||
#if MPPE_SUPPORT
|
||||
unsigned int mppe_keys_set :1; /* Have the MPPE keys been set? */
|
||||
#endif /* MPPE_SUPPORT */
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
/* auth data */
|
||||
#if PPP_SERVER && defined(HAVE_MULTILINK)
|
||||
char peer_authname[MAXNAMELEN + 1]; /* The name by which the peer authenticated itself to us. */
|
||||
#endif /* PPP_SERVER && defined(HAVE_MULTILINK) */
|
||||
u16_t auth_pending; /* Records which authentication operations haven't completed yet. */
|
||||
u16_t auth_done; /* Records which authentication operations have been completed. */
|
||||
|
||||
#if PAP_SUPPORT
|
||||
upap_state upap; /* PAP data */
|
||||
#endif /* PAP_SUPPORT */
|
||||
|
||||
#if CHAP_SUPPORT
|
||||
chap_client_state chap_client; /* CHAP client data */
|
||||
#if PPP_SERVER
|
||||
chap_server_state chap_server; /* CHAP server data */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
|
||||
#if EAP_SUPPORT
|
||||
eap_state eap; /* EAP data */
|
||||
#endif /* EAP_SUPPORT */
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
fsm lcp_fsm; /* LCP fsm structure */
|
||||
lcp_options lcp_wantoptions; /* Options that we want to request */
|
||||
lcp_options lcp_gotoptions; /* Options that peer ack'd */
|
||||
lcp_options lcp_allowoptions; /* Options we allow peer to request */
|
||||
lcp_options lcp_hisoptions; /* Options that we ack'd */
|
||||
u16_t peer_mru; /* currently negotiated peer MRU */
|
||||
u8_t lcp_echos_pending; /* Number of outstanding echo msgs */
|
||||
u8_t lcp_echo_number; /* ID number of next echo frame */
|
||||
|
||||
u8_t num_np_open; /* Number of network protocols which we have opened. */
|
||||
u8_t num_np_up; /* Number of network protocols which have come up. */
|
||||
|
||||
#if VJ_SUPPORT
|
||||
struct vjcompress vj_comp; /* Van Jacobson compression header. */
|
||||
#endif /* VJ_SUPPORT */
|
||||
|
||||
#if CCP_SUPPORT
|
||||
fsm ccp_fsm; /* CCP fsm structure */
|
||||
ccp_options ccp_wantoptions; /* what to request the peer to use */
|
||||
ccp_options ccp_gotoptions; /* what the peer agreed to do */
|
||||
ccp_options ccp_allowoptions; /* what we'll agree to do */
|
||||
ccp_options ccp_hisoptions; /* what we agreed to do */
|
||||
u8_t ccp_localstate; /* Local state (mainly for handling reset-reqs and reset-acks). */
|
||||
u8_t ccp_receive_method; /* Method chosen on receive path */
|
||||
u8_t ccp_transmit_method; /* Method chosen on transmit path */
|
||||
#if MPPE_SUPPORT
|
||||
ppp_mppe_state mppe_comp; /* MPPE "compressor" structure */
|
||||
ppp_mppe_state mppe_decomp; /* MPPE "decompressor" structure */
|
||||
#endif /* MPPE_SUPPORT */
|
||||
#endif /* CCP_SUPPORT */
|
||||
|
||||
#if PPP_IPV4_SUPPORT
|
||||
fsm ipcp_fsm; /* IPCP fsm structure */
|
||||
ipcp_options ipcp_wantoptions; /* Options that we want to request */
|
||||
ipcp_options ipcp_gotoptions; /* Options that peer ack'd */
|
||||
ipcp_options ipcp_allowoptions; /* Options we allow peer to request */
|
||||
ipcp_options ipcp_hisoptions; /* Options that we ack'd */
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
|
||||
#if PPP_IPV6_SUPPORT
|
||||
fsm ipv6cp_fsm; /* IPV6CP fsm structure */
|
||||
ipv6cp_options ipv6cp_wantoptions; /* Options that we want to request */
|
||||
ipv6cp_options ipv6cp_gotoptions; /* Options that peer ack'd */
|
||||
ipv6cp_options ipv6cp_allowoptions; /* Options we allow peer to request */
|
||||
ipv6cp_options ipv6cp_hisoptions; /* Options that we ack'd */
|
||||
#endif /* PPP_IPV6_SUPPORT */
|
||||
};
|
||||
|
||||
/************************
|
||||
*** PUBLIC FUNCTIONS ***
|
||||
************************/
|
||||
|
||||
/*
|
||||
* WARNING: For multi-threads environment, all ppp_set_* functions most
|
||||
* only be called while the PPP is in the dead phase (i.e. disconnected).
|
||||
*/
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
/*
|
||||
* Set PPP authentication.
|
||||
*
|
||||
* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
|
||||
* RFC 1994 says:
|
||||
*
|
||||
* In practice, within or associated with each PPP server, there is a
|
||||
* database which associates "user" names with authentication
|
||||
* information ("secrets"). It is not anticipated that a particular
|
||||
* named user would be authenticated by multiple methods. This would
|
||||
* make the user vulnerable to attacks which negotiate the least secure
|
||||
* method from among a set (such as PAP rather than CHAP). If the same
|
||||
* secret was used, PAP would reveal the secret to be used later with
|
||||
* CHAP.
|
||||
*
|
||||
* Instead, for each user name there should be an indication of exactly
|
||||
* one method used to authenticate that user name. If a user needs to
|
||||
* make use of different authentication methods under different
|
||||
* circumstances, then distinct user names SHOULD be employed, each of
|
||||
* which identifies exactly one authentication method.
|
||||
*
|
||||
* Default is none auth type, unset (NULL) user and passwd.
|
||||
*/
|
||||
#define PPPAUTHTYPE_NONE 0x00
|
||||
#define PPPAUTHTYPE_PAP 0x01
|
||||
#define PPPAUTHTYPE_CHAP 0x02
|
||||
#define PPPAUTHTYPE_MSCHAP 0x04
|
||||
#define PPPAUTHTYPE_MSCHAP_V2 0x08
|
||||
#define PPPAUTHTYPE_EAP 0x10
|
||||
#define PPPAUTHTYPE_ANY 0xff
|
||||
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd);
|
||||
|
||||
/*
|
||||
* If set, peer is required to authenticate. This is mostly necessary for PPP server support.
|
||||
*
|
||||
* Default is false.
|
||||
*/
|
||||
#define ppp_set_auth_required(ppp, boolval) (ppp->settings.auth_required = boolval)
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
#if PPP_IPV4_SUPPORT
|
||||
/*
|
||||
* Set PPP interface "our" and "his" IPv4 addresses. This is mostly necessary for PPP server
|
||||
* support but it can also be used on a PPP link where each side choose its own IP address.
|
||||
*
|
||||
* Default is unset (0.0.0.0).
|
||||
*/
|
||||
#define ppp_set_ipcp_ouraddr(ppp, addr) do { ppp->ipcp_wantoptions.ouraddr = ip4_addr_get_u32(addr); \
|
||||
ppp->ask_for_local = ppp->ipcp_wantoptions.ouraddr != 0; } while(0)
|
||||
#define ppp_set_ipcp_hisaddr(ppp, addr) (ppp->ipcp_wantoptions.hisaddr = ip4_addr_get_u32(addr))
|
||||
#if LWIP_DNS
|
||||
/*
|
||||
* Set DNS server addresses that are sent if the peer asks for them. This is mostly necessary
|
||||
* for PPP server support.
|
||||
*
|
||||
* Default is unset (0.0.0.0).
|
||||
*/
|
||||
#define ppp_set_ipcp_dnsaddr(ppp, index, addr) (ppp->ipcp_allowoptions.dnsaddr[index] = ip4_addr_get_u32(addr))
|
||||
|
||||
/*
|
||||
* If set, we ask the peer for up to 2 DNS server addresses. Received DNS server addresses are
|
||||
* registered using the dns_setserver() function.
|
||||
*
|
||||
* Default is false.
|
||||
*/
|
||||
#define ppp_set_usepeerdns(ppp, boolval) (ppp->settings.usepeerdns = boolval)
|
||||
#endif /* LWIP_DNS */
|
||||
#endif /* PPP_IPV4_SUPPORT */
|
||||
|
||||
#if MPPE_SUPPORT
|
||||
/* Disable MPPE (Microsoft Point to Point Encryption). This parameter is exclusive. */
|
||||
#define PPP_MPPE_DISABLE 0x00
|
||||
/* Require the use of MPPE (Microsoft Point to Point Encryption). */
|
||||
#define PPP_MPPE_ENABLE 0x01
|
||||
/* Allow MPPE to use stateful mode. Stateless mode is still attempted first. */
|
||||
#define PPP_MPPE_ALLOW_STATEFUL 0x02
|
||||
/* Refuse the use of MPPE with 40-bit encryption. Conflict with PPP_MPPE_REFUSE_128. */
|
||||
#define PPP_MPPE_REFUSE_40 0x04
|
||||
/* Refuse the use of MPPE with 128-bit encryption. Conflict with PPP_MPPE_REFUSE_40. */
|
||||
#define PPP_MPPE_REFUSE_128 0x08
|
||||
/*
|
||||
* Set MPPE configuration
|
||||
*
|
||||
* Default is disabled.
|
||||
*/
|
||||
void ppp_set_mppe(ppp_pcb *pcb, u8_t flags);
|
||||
#endif /* MPPE_SUPPORT */
|
||||
|
||||
/*
|
||||
* Wait for up to intval milliseconds for a valid PPP packet from the peer.
|
||||
* At the end of this time, or when a valid PPP packet is received from the
|
||||
* peer, we commence negotiation by sending our first LCP packet.
|
||||
*
|
||||
* Default is 0.
|
||||
*/
|
||||
#define ppp_set_listen_time(ppp, intval) (ppp->settings.listen_time = intval)
|
||||
|
||||
/*
|
||||
* If set, we will attempt to initiate a connection but if no reply is received from
|
||||
* the peer, we will then just wait passively for a valid LCP packet from the peer.
|
||||
*
|
||||
* Default is false.
|
||||
*/
|
||||
#define ppp_set_passive(ppp, boolval) (ppp->lcp_wantoptions.passive = boolval)
|
||||
|
||||
/*
|
||||
* If set, we will not transmit LCP packets to initiate a connection until a valid
|
||||
* LCP packet is received from the peer. This is what we usually call the server mode.
|
||||
*
|
||||
* Default is false.
|
||||
*/
|
||||
#define ppp_set_silent(ppp, boolval) (ppp->lcp_wantoptions.silent = boolval)
|
||||
|
||||
/*
|
||||
* If set, enable protocol field compression negotiation in both the receive and
|
||||
* the transmit direction.
|
||||
*
|
||||
* Default is true.
|
||||
*/
|
||||
#define ppp_set_neg_pcomp(ppp, boolval) (ppp->lcp_wantoptions.neg_pcompression = \
|
||||
ppp->lcp_allowoptions.neg_pcompression = boolval)
|
||||
|
||||
/*
|
||||
* If set, enable Address/Control compression in both the receive and the transmit
|
||||
* direction.
|
||||
*
|
||||
* Default is true.
|
||||
*/
|
||||
#define ppp_set_neg_accomp(ppp, boolval) (ppp->lcp_wantoptions.neg_accompression = \
|
||||
ppp->lcp_allowoptions.neg_accompression = boolval)
|
||||
|
||||
/*
|
||||
* If set, enable asyncmap negotiation. Otherwise forcing all control characters to
|
||||
* be escaped for both the transmit and the receive direction.
|
||||
*
|
||||
* Default is true.
|
||||
*/
|
||||
#define ppp_set_neg_asyncmap(ppp, boolval) (ppp->lcp_wantoptions.neg_asyncmap = \
|
||||
ppp->lcp_allowoptions.neg_asyncmap = boolval)
|
||||
|
||||
/*
|
||||
* This option sets the Async-Control-Character-Map (ACCM) for this end of the link.
|
||||
* The ACCM is a set of 32 bits, one for each of the ASCII control characters with
|
||||
* values from 0 to 31, where a 1 bit indicates that the corresponding control
|
||||
* character should not be used in PPP packets sent to this system. The map is
|
||||
* an unsigned 32 bits integer where the least significant bit (00000001) represents
|
||||
* character 0 and the most significant bit (80000000) represents character 31.
|
||||
* We will then ask the peer to send these characters as a 2-byte escape sequence.
|
||||
*
|
||||
* Default is 0.
|
||||
*/
|
||||
#define ppp_set_asyncmap(ppp, intval) (ppp->lcp_wantoptions.asyncmap = intval)
|
||||
|
||||
/*
|
||||
* Set a PPP interface as the default network interface
|
||||
* (used to output all packets for which no specific route is found).
|
||||
*/
|
||||
#define ppp_set_default(ppp) netif_set_default(ppp->netif)
|
||||
|
||||
#if PPP_NOTIFY_PHASE
|
||||
/*
|
||||
* Set a PPP notify phase callback.
|
||||
*
|
||||
* This can be used for example to set a LED pattern depending on the
|
||||
* current phase of the PPP session.
|
||||
*/
|
||||
typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase, void *ctx);
|
||||
void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
|
||||
#endif /* PPP_NOTIFY_PHASE */
|
||||
|
||||
/*
|
||||
* Initiate a PPP connection.
|
||||
*
|
||||
* This can only be called if PPP is in the dead phase.
|
||||
*
|
||||
* Holdoff is the time to wait (in seconds) before initiating
|
||||
* the connection.
|
||||
*
|
||||
* If this port connects to a modem, the modem connection must be
|
||||
* established before calling this.
|
||||
*/
|
||||
err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff);
|
||||
|
||||
#if PPP_SERVER
|
||||
/*
|
||||
* Listen for an incoming PPP connection.
|
||||
*
|
||||
* This can only be called if PPP is in the dead phase.
|
||||
*
|
||||
* If this port connects to a modem, the modem connection must be
|
||||
* established before calling this.
|
||||
*/
|
||||
err_t ppp_listen(ppp_pcb *pcb);
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/*
|
||||
* Initiate the end of a PPP connection.
|
||||
* Any outstanding packets in the queues are dropped.
|
||||
*
|
||||
* Setting nocarrier to 1 close the PPP connection without initiating the
|
||||
* shutdown procedure. Always using nocarrier = 0 is still recommended,
|
||||
* this is going to take a little longer time if your link is down, but
|
||||
* is a safer choice for the PPP state machine.
|
||||
*
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
err_t ppp_close(ppp_pcb *pcb, u8_t nocarrier);
|
||||
|
||||
/*
|
||||
* Release the control block.
|
||||
*
|
||||
* This can only be called if PPP is in the dead phase.
|
||||
*
|
||||
* You must use ppp_close() before if you wish to terminate
|
||||
* an established PPP session.
|
||||
*
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
err_t ppp_free(ppp_pcb *pcb);
|
||||
|
||||
/*
|
||||
* PPP IOCTL commands.
|
||||
*
|
||||
* Get the up status - 0 for down, non-zero for up. The argument must
|
||||
* point to an int.
|
||||
*/
|
||||
#define PPPCTLG_UPSTATUS 0
|
||||
|
||||
/*
|
||||
* Get the PPP error code. The argument must point to an int.
|
||||
* Returns a PPPERR_* value.
|
||||
*/
|
||||
#define PPPCTLG_ERRCODE 1
|
||||
|
||||
/*
|
||||
* Get the fd associated with a PPP over serial
|
||||
*/
|
||||
#define PPPCTLG_FD 2
|
||||
|
||||
/*
|
||||
* Get and set parameters for the given connection.
|
||||
* Return 0 on success, an error code on failure.
|
||||
*/
|
||||
err_t ppp_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg);
|
||||
|
||||
/* Get the PPP netif interface */
|
||||
#define ppp_netif(ppp) (ppp->netif)
|
||||
|
||||
/* Set an lwIP-style status-callback for the selected PPP device */
|
||||
#define ppp_set_netif_statuscallback(ppp, status_cb) \
|
||||
netif_set_status_callback(ppp->netif, status_cb);
|
||||
|
||||
/* Set an lwIP-style link-callback for the selected PPP device */
|
||||
#define ppp_set_netif_linkcallback(ppp, link_cb) \
|
||||
netif_set_link_callback(ppp->netif, link_cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PPP_H */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
610
tools/sdk/lwip2/include/netif/ppp/ppp_opts.h
Normal file
610
tools/sdk/lwip2/include/netif/ppp/ppp_opts.h
Normal file
@ -0,0 +1,610 @@
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_PPP_OPTS_H
|
||||
#define LWIP_PPP_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/**
|
||||
* PPP_SUPPORT==1: Enable PPP.
|
||||
*/
|
||||
#ifndef PPP_SUPPORT
|
||||
#define PPP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPPOE_SUPPORT==1: Enable PPP Over Ethernet
|
||||
*/
|
||||
#ifndef PPPOE_SUPPORT
|
||||
#define PPPOE_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPPOL2TP_SUPPORT==1: Enable PPP Over L2TP
|
||||
*/
|
||||
#ifndef PPPOL2TP_SUPPORT
|
||||
#define PPPOL2TP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPPOL2TP_AUTH_SUPPORT==1: Enable PPP Over L2TP Auth (enable MD5 support)
|
||||
*/
|
||||
#ifndef PPPOL2TP_AUTH_SUPPORT
|
||||
#define PPPOL2TP_AUTH_SUPPORT PPPOL2TP_SUPPORT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPPOS_SUPPORT==1: Enable PPP Over Serial
|
||||
*/
|
||||
#ifndef PPPOS_SUPPORT
|
||||
#define PPPOS_SUPPORT PPP_SUPPORT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_PPP_API==1: Enable PPP API (in pppapi.c)
|
||||
*/
|
||||
#ifndef LWIP_PPP_API
|
||||
#define LWIP_PPP_API (PPP_SUPPORT && (NO_SYS == 0))
|
||||
#endif
|
||||
|
||||
#if PPP_SUPPORT
|
||||
|
||||
/**
|
||||
* MEMP_NUM_PPP_PCB: the number of simultaneously active PPP
|
||||
* connections (requires the PPP_SUPPORT option)
|
||||
*/
|
||||
#ifndef MEMP_NUM_PPP_PCB
|
||||
#define MEMP_NUM_PPP_PCB 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_NUM_TIMEOUTS_PER_PCB: the number of sys_timeouts running in parallel per
|
||||
* ppp_pcb. See the detailed explanation at the end of ppp_impl.h about simultaneous
|
||||
* timers analysis.
|
||||
*/
|
||||
#ifndef PPP_NUM_TIMEOUTS_PER_PCB
|
||||
#define PPP_NUM_TIMEOUTS_PER_PCB (1 + PPP_IPV4_SUPPORT + PPP_IPV6_SUPPORT + CCP_SUPPORT)
|
||||
#endif
|
||||
|
||||
/* The number of sys_timeouts required for the PPP module */
|
||||
#define PPP_NUM_TIMEOUTS (PPP_SUPPORT * PPP_NUM_TIMEOUTS_PER_PCB * MEMP_NUM_PPP_PCB)
|
||||
|
||||
/**
|
||||
* MEMP_NUM_PPPOS_INTERFACES: the number of concurrently active PPPoS
|
||||
* interfaces (only used with PPPOS_SUPPORT==1)
|
||||
*/
|
||||
#ifndef MEMP_NUM_PPPOS_INTERFACES
|
||||
#define MEMP_NUM_PPPOS_INTERFACES MEMP_NUM_PPP_PCB
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
|
||||
* interfaces (only used with PPPOE_SUPPORT==1)
|
||||
*/
|
||||
#ifndef MEMP_NUM_PPPOE_INTERFACES
|
||||
#define MEMP_NUM_PPPOE_INTERFACES 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_PPPOL2TP_INTERFACES: the number of concurrently active PPPoL2TP
|
||||
* interfaces (only used with PPPOL2TP_SUPPORT==1)
|
||||
*/
|
||||
#ifndef MEMP_NUM_PPPOL2TP_INTERFACES
|
||||
#define MEMP_NUM_PPPOL2TP_INTERFACES 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_PPP_API_MSG: Number of concurrent PPP API messages (in pppapi.c)
|
||||
*/
|
||||
#ifndef MEMP_NUM_PPP_API_MSG
|
||||
#define MEMP_NUM_PPP_API_MSG 5
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_DEBUG: Enable debugging for PPP.
|
||||
*/
|
||||
#ifndef PPP_DEBUG
|
||||
#define PPP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_INPROC_IRQ_SAFE==1 call pppos_input() using tcpip_callback().
|
||||
*
|
||||
* Please read the "PPPoS input path" chapter in the PPP documentation about this option.
|
||||
*/
|
||||
#ifndef PPP_INPROC_IRQ_SAFE
|
||||
#define PPP_INPROC_IRQ_SAFE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PRINTPKT_SUPPORT==1: Enable PPP print packet support
|
||||
*
|
||||
* Mandatory for debugging, it displays exchanged packet content in debug trace.
|
||||
*/
|
||||
#ifndef PRINTPKT_SUPPORT
|
||||
#define PRINTPKT_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_IPV4_SUPPORT==1: Enable PPP IPv4 support
|
||||
*/
|
||||
#ifndef PPP_IPV4_SUPPORT
|
||||
#define PPP_IPV4_SUPPORT (LWIP_IPV4)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_IPV6_SUPPORT==1: Enable PPP IPv6 support
|
||||
*/
|
||||
#ifndef PPP_IPV6_SUPPORT
|
||||
#define PPP_IPV6_SUPPORT (LWIP_IPV6)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_NOTIFY_PHASE==1: Support PPP notify phase support
|
||||
*
|
||||
* PPP notify phase support allows you to set a callback which is
|
||||
* called on change of the internal PPP state machine.
|
||||
*
|
||||
* This can be used for example to set a LED pattern depending on the
|
||||
* current phase of the PPP session.
|
||||
*/
|
||||
#ifndef PPP_NOTIFY_PHASE
|
||||
#define PPP_NOTIFY_PHASE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* pbuf_type PPP is using for LCP, PAP, CHAP, EAP, CCP, IPCP and IP6CP packets.
|
||||
*
|
||||
* Memory allocated must be single buffered for PPP to works, it requires pbuf
|
||||
* that are not going to be chained when allocated. This requires setting
|
||||
* PBUF_POOL_BUFSIZE to at least 512 bytes, which is quite huge for small systems.
|
||||
*
|
||||
* Setting PPP_USE_PBUF_RAM to 1 makes PPP use memory from heap where continuous
|
||||
* buffers are required, allowing you to use a smaller PBUF_POOL_BUFSIZE.
|
||||
*/
|
||||
#ifndef PPP_USE_PBUF_RAM
|
||||
#define PPP_USE_PBUF_RAM 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_FCS_TABLE: Keep a 256*2 byte table to speed up FCS calculation for PPPoS
|
||||
*/
|
||||
#ifndef PPP_FCS_TABLE
|
||||
#define PPP_FCS_TABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PAP_SUPPORT==1: Support PAP.
|
||||
*/
|
||||
#ifndef PAP_SUPPORT
|
||||
#define PAP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CHAP_SUPPORT==1: Support CHAP.
|
||||
*/
|
||||
#ifndef CHAP_SUPPORT
|
||||
#define CHAP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MSCHAP_SUPPORT==1: Support MSCHAP.
|
||||
*/
|
||||
#ifndef MSCHAP_SUPPORT
|
||||
#define MSCHAP_SUPPORT 0
|
||||
#endif
|
||||
#if MSCHAP_SUPPORT
|
||||
/* MSCHAP requires CHAP support */
|
||||
#undef CHAP_SUPPORT
|
||||
#define CHAP_SUPPORT 1
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
/**
|
||||
* EAP_SUPPORT==1: Support EAP.
|
||||
*/
|
||||
#ifndef EAP_SUPPORT
|
||||
#define EAP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CCP_SUPPORT==1: Support CCP.
|
||||
*/
|
||||
#ifndef CCP_SUPPORT
|
||||
#define CCP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MPPE_SUPPORT==1: Support MPPE.
|
||||
*/
|
||||
#ifndef MPPE_SUPPORT
|
||||
#define MPPE_SUPPORT 0
|
||||
#endif
|
||||
#if MPPE_SUPPORT
|
||||
/* MPPE requires CCP support */
|
||||
#undef CCP_SUPPORT
|
||||
#define CCP_SUPPORT 1
|
||||
/* MPPE requires MSCHAP support */
|
||||
#undef MSCHAP_SUPPORT
|
||||
#define MSCHAP_SUPPORT 1
|
||||
/* MSCHAP requires CHAP support */
|
||||
#undef CHAP_SUPPORT
|
||||
#define CHAP_SUPPORT 1
|
||||
#endif /* MPPE_SUPPORT */
|
||||
|
||||
/**
|
||||
* CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
|
||||
*/
|
||||
#ifndef CBCP_SUPPORT
|
||||
#define CBCP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ECP_SUPPORT==1: Support ECP. CURRENTLY NOT SUPPORTED! DO NOT SET!
|
||||
*/
|
||||
#ifndef ECP_SUPPORT
|
||||
#define ECP_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* DEMAND_SUPPORT==1: Support dial on demand. CURRENTLY NOT SUPPORTED! DO NOT SET!
|
||||
*/
|
||||
#ifndef DEMAND_SUPPORT
|
||||
#define DEMAND_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LQR_SUPPORT==1: Support Link Quality Report. Do nothing except exchanging some LCP packets.
|
||||
*/
|
||||
#ifndef LQR_SUPPORT
|
||||
#define LQR_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_SERVER==1: Enable PPP server support (waiting for incoming PPP session).
|
||||
*
|
||||
* Currently only supported for PPPoS.
|
||||
*/
|
||||
#ifndef PPP_SERVER
|
||||
#define PPP_SERVER 0
|
||||
#endif
|
||||
|
||||
#if PPP_SERVER
|
||||
/*
|
||||
* PPP_OUR_NAME: Our name for authentication purposes
|
||||
*/
|
||||
#ifndef PPP_OUR_NAME
|
||||
#define PPP_OUR_NAME "lwIP"
|
||||
#endif
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/**
|
||||
* VJ_SUPPORT==1: Support VJ header compression.
|
||||
*/
|
||||
#ifndef VJ_SUPPORT
|
||||
#define VJ_SUPPORT 1
|
||||
#endif
|
||||
/* VJ compression is only supported for TCP over IPv4 over PPPoS. */
|
||||
#if !PPPOS_SUPPORT || !PPP_IPV4_SUPPORT || !LWIP_TCP
|
||||
#undef VJ_SUPPORT
|
||||
#define VJ_SUPPORT 0
|
||||
#endif /* !PPPOS_SUPPORT */
|
||||
|
||||
/**
|
||||
* PPP_MD5_RANDM==1: Use MD5 for better randomness.
|
||||
* Enabled by default if CHAP, EAP, or L2TP AUTH support is enabled.
|
||||
*/
|
||||
#ifndef PPP_MD5_RANDM
|
||||
#define PPP_MD5_RANDM (CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PolarSSL embedded library
|
||||
*
|
||||
*
|
||||
* lwIP contains some files fetched from the latest BSD release of
|
||||
* the PolarSSL project (PolarSSL 0.10.1-bsd) for ciphers and encryption
|
||||
* methods we need for lwIP PPP support.
|
||||
*
|
||||
* The PolarSSL files were cleaned to contain only the necessary struct
|
||||
* fields and functions needed for lwIP.
|
||||
*
|
||||
* The PolarSSL API was not changed at all, so if you are already using
|
||||
* PolarSSL you can choose to skip the compilation of the included PolarSSL
|
||||
* library into lwIP.
|
||||
*
|
||||
* If you are not using the embedded copy you must include external
|
||||
* libraries into your arch/cc.h port file.
|
||||
*
|
||||
* Beware of the stack requirements which can be a lot larger if you are not
|
||||
* using our cleaned PolarSSL library.
|
||||
*/
|
||||
|
||||
/**
|
||||
* LWIP_USE_EXTERNAL_POLARSSL: Use external PolarSSL library
|
||||
*/
|
||||
#ifndef LWIP_USE_EXTERNAL_POLARSSL
|
||||
#define LWIP_USE_EXTERNAL_POLARSSL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_USE_EXTERNAL_MBEDTLS: Use external mbed TLS library
|
||||
*/
|
||||
#ifndef LWIP_USE_EXTERNAL_MBEDTLS
|
||||
#define LWIP_USE_EXTERNAL_MBEDTLS 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PPP Timeouts
|
||||
*/
|
||||
|
||||
/**
|
||||
* FSM_DEFTIMEOUT: Timeout time in seconds
|
||||
*/
|
||||
#ifndef FSM_DEFTIMEOUT
|
||||
#define FSM_DEFTIMEOUT 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
* FSM_DEFMAXTERMREQS: Maximum Terminate-Request transmissions
|
||||
*/
|
||||
#ifndef FSM_DEFMAXTERMREQS
|
||||
#define FSM_DEFMAXTERMREQS 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* FSM_DEFMAXCONFREQS: Maximum Configure-Request transmissions
|
||||
*/
|
||||
#ifndef FSM_DEFMAXCONFREQS
|
||||
#define FSM_DEFMAXCONFREQS 10
|
||||
#endif
|
||||
|
||||
/**
|
||||
* FSM_DEFMAXNAKLOOPS: Maximum number of nak loops
|
||||
*/
|
||||
#ifndef FSM_DEFMAXNAKLOOPS
|
||||
#define FSM_DEFMAXNAKLOOPS 5
|
||||
#endif
|
||||
|
||||
/**
|
||||
* UPAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req
|
||||
*/
|
||||
#ifndef UPAP_DEFTIMEOUT
|
||||
#define UPAP_DEFTIMEOUT 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
* UPAP_DEFTRANSMITS: Maximum number of auth-reqs to send
|
||||
*/
|
||||
#ifndef UPAP_DEFTRANSMITS
|
||||
#define UPAP_DEFTRANSMITS 10
|
||||
#endif
|
||||
|
||||
#if PPP_SERVER
|
||||
/**
|
||||
* UPAP_DEFREQTIME: Time to wait for auth-req from peer
|
||||
*/
|
||||
#ifndef UPAP_DEFREQTIME
|
||||
#define UPAP_DEFREQTIME 30
|
||||
#endif
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/**
|
||||
* CHAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req
|
||||
*/
|
||||
#ifndef CHAP_DEFTIMEOUT
|
||||
#define CHAP_DEFTIMEOUT 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CHAP_DEFTRANSMITS: max # times to send challenge
|
||||
*/
|
||||
#ifndef CHAP_DEFTRANSMITS
|
||||
#define CHAP_DEFTRANSMITS 10
|
||||
#endif
|
||||
|
||||
#if PPP_SERVER
|
||||
/**
|
||||
* CHAP_DEFRECHALLENGETIME: If this option is > 0, rechallenge the peer every n seconds
|
||||
*/
|
||||
#ifndef CHAP_DEFRECHALLENGETIME
|
||||
#define CHAP_DEFRECHALLENGETIME 0
|
||||
#endif
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/**
|
||||
* EAP_DEFREQTIME: Time to wait for peer request
|
||||
*/
|
||||
#ifndef EAP_DEFREQTIME
|
||||
#define EAP_DEFREQTIME 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
* EAP_DEFALLOWREQ: max # times to accept requests
|
||||
*/
|
||||
#ifndef EAP_DEFALLOWREQ
|
||||
#define EAP_DEFALLOWREQ 10
|
||||
#endif
|
||||
|
||||
#if PPP_SERVER
|
||||
/**
|
||||
* EAP_DEFTIMEOUT: Timeout (seconds) for rexmit
|
||||
*/
|
||||
#ifndef EAP_DEFTIMEOUT
|
||||
#define EAP_DEFTIMEOUT 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
* EAP_DEFTRANSMITS: max # times to transmit
|
||||
*/
|
||||
#ifndef EAP_DEFTRANSMITS
|
||||
#define EAP_DEFTRANSMITS 10
|
||||
#endif
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/**
|
||||
* LCP_DEFLOOPBACKFAIL: Default number of times we receive our magic number from the peer
|
||||
* before deciding the link is looped-back.
|
||||
*/
|
||||
#ifndef LCP_DEFLOOPBACKFAIL
|
||||
#define LCP_DEFLOOPBACKFAIL 10
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LCP_ECHOINTERVAL: Interval in seconds between keepalive echo requests, 0 to disable.
|
||||
*/
|
||||
#ifndef LCP_ECHOINTERVAL
|
||||
#define LCP_ECHOINTERVAL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LCP_MAXECHOFAILS: Number of unanswered echo requests before failure.
|
||||
*/
|
||||
#ifndef LCP_MAXECHOFAILS
|
||||
#define LCP_MAXECHOFAILS 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char.
|
||||
*/
|
||||
#ifndef PPP_MAXIDLEFLAG
|
||||
#define PPP_MAXIDLEFLAG 100
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP Packet sizes
|
||||
*/
|
||||
|
||||
/**
|
||||
* PPP_MRU: Default MRU
|
||||
*/
|
||||
#ifndef PPP_MRU
|
||||
#define PPP_MRU 1500
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_DEFMRU: Default MRU to try
|
||||
*/
|
||||
#ifndef PPP_DEFMRU
|
||||
#define PPP_DEFMRU 1500
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_MAXMRU: Normally limit MRU to this (pppd default = 16384)
|
||||
*/
|
||||
#ifndef PPP_MAXMRU
|
||||
#define PPP_MAXMRU 1500
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPP_MINMRU: No MRUs below this
|
||||
*/
|
||||
#ifndef PPP_MINMRU
|
||||
#define PPP_MINMRU 128
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PPPOL2TP_DEFMRU: Default MTU and MRU for L2TP
|
||||
* Default = 1500 - PPPoE(6) - PPP Protocol(2) - IPv4 header(20) - UDP Header(8)
|
||||
* - L2TP Header(6) - HDLC Header(2) - PPP Protocol(2) - MPPE Header(2) - PPP Protocol(2)
|
||||
*/
|
||||
#if PPPOL2TP_SUPPORT
|
||||
#ifndef PPPOL2TP_DEFMRU
|
||||
#define PPPOL2TP_DEFMRU 1450
|
||||
#endif
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
|
||||
/**
|
||||
* MAXNAMELEN: max length of hostname or name for auth
|
||||
*/
|
||||
#ifndef MAXNAMELEN
|
||||
#define MAXNAMELEN 256
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MAXSECRETLEN: max length of password or secret
|
||||
*/
|
||||
#ifndef MAXSECRETLEN
|
||||
#define MAXSECRETLEN 256
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Build triggers for embedded PolarSSL
|
||||
*/
|
||||
#if !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS
|
||||
|
||||
/* CHAP, EAP, L2TP AUTH and MD5 Random require MD5 support */
|
||||
#if CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM
|
||||
#define LWIP_INCLUDED_POLARSSL_MD5 1
|
||||
#endif /* CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM */
|
||||
|
||||
#if MSCHAP_SUPPORT
|
||||
|
||||
/* MSCHAP require MD4 support */
|
||||
#define LWIP_INCLUDED_POLARSSL_MD4 1
|
||||
/* MSCHAP require SHA1 support */
|
||||
#define LWIP_INCLUDED_POLARSSL_SHA1 1
|
||||
/* MSCHAP require DES support */
|
||||
#define LWIP_INCLUDED_POLARSSL_DES 1
|
||||
|
||||
/* MS-CHAP support is required for MPPE */
|
||||
#if MPPE_SUPPORT
|
||||
/* MPPE require ARC4 support */
|
||||
#define LWIP_INCLUDED_POLARSSL_ARC4 1
|
||||
#endif /* MPPE_SUPPORT */
|
||||
|
||||
#endif /* MSCHAP_SUPPORT */
|
||||
|
||||
#endif /* !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS */
|
||||
|
||||
/* Default value if unset */
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_MD4
|
||||
#define LWIP_INCLUDED_POLARSSL_MD4 0
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD4 */
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_MD5
|
||||
#define LWIP_INCLUDED_POLARSSL_MD5 0
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_MD5 */
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_SHA1
|
||||
#define LWIP_INCLUDED_POLARSSL_SHA1 0
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_DES
|
||||
#define LWIP_INCLUDED_POLARSSL_DES 0
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_DES */
|
||||
#ifndef LWIP_INCLUDED_POLARSSL_ARC4
|
||||
#define LWIP_INCLUDED_POLARSSL_ARC4 0
|
||||
#endif /* LWIP_INCLUDED_POLARSSL_ARC4 */
|
||||
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
||||
/* Default value if unset */
|
||||
#ifndef PPP_NUM_TIMEOUTS
|
||||
#define PPP_NUM_TIMEOUTS 0
|
||||
#endif /* PPP_NUM_TIMEOUTS */
|
||||
|
||||
#endif /* LWIP_PPP_OPTS_H */
|
126
tools/sdk/lwip2/include/netif/ppp/pppos.h
Normal file
126
tools/sdk/lwip2/include/netif/ppp/pppos.h
Normal file
@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @file
|
||||
* Network Point to Point Protocol over Serial header file.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "netif/ppp/ppp_opts.h"
|
||||
#if PPP_SUPPORT && PPPOS_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef PPPOS_H
|
||||
#define PPPOS_H
|
||||
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "ppp.h"
|
||||
#include "vj.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* PPP packet parser states. Current state indicates operation yet to be
|
||||
* completed. */
|
||||
enum {
|
||||
PDIDLE = 0, /* Idle state - waiting. */
|
||||
PDSTART, /* Process start flag. */
|
||||
PDADDRESS, /* Process address field. */
|
||||
PDCONTROL, /* Process control field. */
|
||||
PDPROTOCOL1, /* Process protocol field 1. */
|
||||
PDPROTOCOL2, /* Process protocol field 2. */
|
||||
PDDATA /* Process data byte. */
|
||||
};
|
||||
|
||||
/* PPPoS serial output callback function prototype */
|
||||
typedef u32_t (*pppos_output_cb_fn)(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx);
|
||||
|
||||
/*
|
||||
* Extended asyncmap - allows any character to be escaped.
|
||||
*/
|
||||
typedef u8_t ext_accm[32];
|
||||
|
||||
/*
|
||||
* PPPoS interface control block.
|
||||
*/
|
||||
typedef struct pppos_pcb_s pppos_pcb;
|
||||
struct pppos_pcb_s {
|
||||
/* -- below are data that will NOT be cleared between two sessions */
|
||||
ppp_pcb *ppp; /* PPP PCB */
|
||||
pppos_output_cb_fn output_cb; /* PPP serial output callback */
|
||||
|
||||
/* -- below are data that will be cleared between two sessions
|
||||
*
|
||||
* last_xmit must be the first member of cleared members, because it is
|
||||
* used to know which part must not be cleared.
|
||||
*/
|
||||
u32_t last_xmit; /* Time of last transmission. */
|
||||
ext_accm out_accm; /* Async-Ctl-Char-Map for output. */
|
||||
|
||||
/* flags */
|
||||
unsigned int open :1; /* Set if PPPoS is open */
|
||||
unsigned int pcomp :1; /* Does peer accept protocol compression? */
|
||||
unsigned int accomp :1; /* Does peer accept addr/ctl compression? */
|
||||
|
||||
/* PPPoS rx */
|
||||
ext_accm in_accm; /* Async-Ctl-Char-Map for input. */
|
||||
struct pbuf *in_head, *in_tail; /* The input packet. */
|
||||
u16_t in_protocol; /* The input protocol code. */
|
||||
u16_t in_fcs; /* Input Frame Check Sequence value. */
|
||||
u8_t in_state; /* The input process state. */
|
||||
u8_t in_escaped; /* Escape next character. */
|
||||
};
|
||||
|
||||
/* Create a new PPPoS session. */
|
||||
ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb,
|
||||
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
|
||||
|
||||
#if !NO_SYS && !PPP_INPROC_IRQ_SAFE
|
||||
/* Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread. */
|
||||
err_t pppos_input_tcpip(ppp_pcb *ppp, u8_t *s, int l);
|
||||
#endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */
|
||||
|
||||
/* PPP over Serial: this is the input function to be called for received data. */
|
||||
void pppos_input(ppp_pcb *ppp, u8_t* data, int len);
|
||||
|
||||
|
||||
/*
|
||||
* Functions called from lwIP
|
||||
* DO NOT CALL FROM lwIP USER APPLICATION.
|
||||
*/
|
||||
#if !NO_SYS && !PPP_INPROC_IRQ_SAFE
|
||||
err_t pppos_input_sys(struct pbuf *p, struct netif *inp);
|
||||
#endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PPPOS_H */
|
||||
#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */
|
169
tools/sdk/lwip2/include/netif/ppp/vj.h
Normal file
169
tools/sdk/lwip2/include/netif/ppp/vj.h
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Definitions for tcp compression routines.
|
||||
*
|
||||
* $Id: vj.h,v 1.7 2010/02/22 17:52:09 goldsimon Exp $
|
||||
*
|
||||
* Copyright (c) 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
*/
|
||||
|
||||
#include "netif/ppp/ppp_opts.h"
|
||||
#if PPP_SUPPORT && VJ_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef VJ_H
|
||||
#define VJ_H
|
||||
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/priv/tcp_priv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAX_SLOTS 16 /* must be > 2 and < 256 */
|
||||
#define MAX_HDR 128
|
||||
|
||||
/*
|
||||
* Compressed packet format:
|
||||
*
|
||||
* The first octet contains the packet type (top 3 bits), TCP
|
||||
* 'push' bit, and flags that indicate which of the 4 TCP sequence
|
||||
* numbers have changed (bottom 5 bits). The next octet is a
|
||||
* conversation number that associates a saved IP/TCP header with
|
||||
* the compressed packet. The next two octets are the TCP checksum
|
||||
* from the original datagram. The next 0 to 15 octets are
|
||||
* sequence number changes, one change per bit set in the header
|
||||
* (there may be no changes and there are two special cases where
|
||||
* the receiver implicitly knows what changed -- see below).
|
||||
*
|
||||
* There are 5 numbers which can change (they are always inserted
|
||||
* in the following order): TCP urgent pointer, window,
|
||||
* acknowlegement, sequence number and IP ID. (The urgent pointer
|
||||
* is different from the others in that its value is sent, not the
|
||||
* change in value.) Since typical use of SLIP links is biased
|
||||
* toward small packets (see comments on MTU/MSS below), changes
|
||||
* use a variable length coding with one octet for numbers in the
|
||||
* range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
|
||||
* range 256 - 65535 or 0. (If the change in sequence number or
|
||||
* ack is more than 65535, an uncompressed packet is sent.)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Packet types (must not conflict with IP protocol version)
|
||||
*
|
||||
* The top nibble of the first octet is the packet type. There are
|
||||
* three possible types: IP (not proto TCP or tcp with one of the
|
||||
* control flags set); uncompressed TCP (a normal IP/TCP packet but
|
||||
* with the 8-bit protocol field replaced by an 8-bit connection id --
|
||||
* this type of packet syncs the sender & receiver); and compressed
|
||||
* TCP (described above).
|
||||
*
|
||||
* LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
|
||||
* is logically part of the 4-bit "changes" field that follows. Top
|
||||
* three bits are actual packet type. For backward compatibility
|
||||
* and in the interest of conserving bits, numbers are chosen so the
|
||||
* IP protocol version number (4) which normally appears in this nibble
|
||||
* means "IP packet".
|
||||
*/
|
||||
|
||||
/* packet types */
|
||||
#define TYPE_IP 0x40
|
||||
#define TYPE_UNCOMPRESSED_TCP 0x70
|
||||
#define TYPE_COMPRESSED_TCP 0x80
|
||||
#define TYPE_ERROR 0x00
|
||||
|
||||
/* Bits in first octet of compressed packet */
|
||||
#define NEW_C 0x40 /* flag bits for what changed in a packet */
|
||||
#define NEW_I 0x20
|
||||
#define NEW_S 0x08
|
||||
#define NEW_A 0x04
|
||||
#define NEW_W 0x02
|
||||
#define NEW_U 0x01
|
||||
|
||||
/* reserved, special-case values of above */
|
||||
#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
|
||||
#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
|
||||
#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
|
||||
|
||||
#define TCP_PUSH_BIT 0x10
|
||||
|
||||
|
||||
/*
|
||||
* "state" data for each active tcp conversation on the wire. This is
|
||||
* basically a copy of the entire IP/TCP header from the last packet
|
||||
* we saw from the conversation together with a small identifier
|
||||
* the transmit & receive ends of the line use to locate saved header.
|
||||
*/
|
||||
struct cstate {
|
||||
struct cstate *cs_next; /* next most recently used state (xmit only) */
|
||||
u16_t cs_hlen; /* size of hdr (receive only) */
|
||||
u8_t cs_id; /* connection # associated with this state */
|
||||
u8_t cs_filler;
|
||||
union {
|
||||
char csu_hdr[MAX_HDR];
|
||||
struct ip_hdr csu_ip; /* ip/tcp hdr from most recent packet */
|
||||
} vjcs_u;
|
||||
};
|
||||
#define cs_ip vjcs_u.csu_ip
|
||||
#define cs_hdr vjcs_u.csu_hdr
|
||||
|
||||
|
||||
struct vjstat {
|
||||
u32_t vjs_packets; /* outbound packets */
|
||||
u32_t vjs_compressed; /* outbound compressed packets */
|
||||
u32_t vjs_searches; /* searches for connection state */
|
||||
u32_t vjs_misses; /* times couldn't find conn. state */
|
||||
u32_t vjs_uncompressedin; /* inbound uncompressed packets */
|
||||
u32_t vjs_compressedin; /* inbound compressed packets */
|
||||
u32_t vjs_errorin; /* inbound unknown type packets */
|
||||
u32_t vjs_tossed; /* inbound packets tossed because of error */
|
||||
};
|
||||
|
||||
/*
|
||||
* all the state data for one serial line (we need one of these per line).
|
||||
*/
|
||||
struct vjcompress {
|
||||
struct cstate *last_cs; /* most recently used tstate */
|
||||
u8_t last_recv; /* last rcvd conn. id */
|
||||
u8_t last_xmit; /* last sent conn. id */
|
||||
u16_t flags;
|
||||
u8_t maxSlotIndex;
|
||||
u8_t compressSlot; /* Flag indicating OK to compress slot ID. */
|
||||
#if LINK_STATS
|
||||
struct vjstat stats;
|
||||
#endif
|
||||
struct cstate tstate[MAX_SLOTS]; /* xmit connection states */
|
||||
struct cstate rstate[MAX_SLOTS]; /* receive connection states */
|
||||
};
|
||||
|
||||
/* flag values */
|
||||
#define VJF_TOSS 1U /* tossing rcvd frames because of input err */
|
||||
|
||||
extern void vj_compress_init (struct vjcompress *comp);
|
||||
extern u8_t vj_compress_tcp (struct vjcompress *comp, struct pbuf **pb);
|
||||
extern void vj_uncompress_err (struct vjcompress *comp);
|
||||
extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp);
|
||||
extern int vj_uncompress_tcp (struct pbuf **nb, struct vjcompress *comp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* VJ_H */
|
||||
|
||||
#endif /* PPP_SUPPORT && VJ_SUPPORT */
|
Reference in New Issue
Block a user