mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-05 14:04:38 +08:00
ppp_impl.h is back!
This commit is contained in:
parent
0663421d01
commit
3bad9ff50a
@ -103,7 +103,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif /* UNUSED */
|
#endif /* UNUSED */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
#include "lcp.h"
|
#include "lcp.h"
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
#include "ccp.h"
|
#include "ccp.h"
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif /* UNUSED */
|
#endif /* UNUSED */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "chap-new.h"
|
#include "chap-new.h"
|
||||||
#include "chap-md5.h"
|
#include "chap-md5.h"
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif /* UNUSED */
|
#endif /* UNUSED */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#if 0 /* UNUSED */
|
#if 0 /* UNUSED */
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif /* UNUSED */
|
#endif /* UNUSED */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "chap-new.h"
|
#include "chap-new.h"
|
||||||
#include "chap_ms.h"
|
#include "chap_ms.h"
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
#include <pcap-bpf.h>
|
#include <pcap-bpf.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
#include "ipcp.h"
|
#include "ipcp.h"
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
#if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "polarssl/md5.h"
|
#include "polarssl/md5.h"
|
||||||
#include "eap.h"
|
#include "eap.h"
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
#include "ecp.h"
|
#include "ecp.h"
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif /* UNUSED */
|
#endif /* UNUSED */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif /* UNUSED */
|
#endif /* UNUSED */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
#include "ipcp.h"
|
#include "ipcp.h"
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif /* UNUSED */
|
#endif /* UNUSED */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
#include "lcp.h"
|
#include "lcp.h"
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "polarssl/md5.h"
|
#include "polarssl/md5.h"
|
||||||
#include "magic.h"
|
#include "magic.h"
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
#include "lcp.h"
|
#include "lcp.h"
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif /* PPP_FILTER */
|
#endif /* PPP_FILTER */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#if defined(ultrix) || defined(NeXT)
|
#if defined(ultrix) || defined(NeXT)
|
||||||
char *strdup __P((char *));
|
char *strdup __P((char *));
|
||||||
|
@ -91,7 +91,7 @@
|
|||||||
#include "lwip/sio.h"
|
#include "lwip/sio.h"
|
||||||
#include "lwip/ip.h" /* for ip_input() */
|
#include "lwip/ip.h" /* for ip_input() */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
#include "lcp.h"
|
#include "lcp.h"
|
||||||
|
@ -34,390 +34,28 @@
|
|||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
#ifndef PPPMY_H_
|
#ifndef PPP_H
|
||||||
#define PPPMY_H_
|
#define PPP_H
|
||||||
|
|
||||||
#include <stdio.h> /* formats */
|
|
||||||
|
|
||||||
#if defined(__STDC__)
|
|
||||||
#include <stdarg.h>
|
|
||||||
#define __V(x) x
|
|
||||||
#else
|
|
||||||
#include <varargs.h>
|
|
||||||
#define __V(x) (va_alist) va_dcl
|
|
||||||
#define const
|
|
||||||
#define volatile
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __P
|
|
||||||
#ifdef __STDC__
|
|
||||||
#define __P(x) x
|
|
||||||
#else
|
|
||||||
#define __P(x) ()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef bool
|
|
||||||
typedef unsigned char bool;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "lwip/netif.h"
|
|
||||||
#include "lwip/def.h"
|
#include "lwip/def.h"
|
||||||
#include "lwip/timers.h"
|
|
||||||
#include "lwip/sio.h"
|
#include "lwip/sio.h"
|
||||||
|
#include "lwip/stats.h"
|
||||||
|
#include "lwip/mem.h"
|
||||||
|
#include "lwip/netif.h"
|
||||||
|
#include "lwip/sys.h"
|
||||||
|
#include "lwip/timers.h"
|
||||||
|
|
||||||
#include "pppdebug.h"
|
|
||||||
|
|
||||||
#ifdef INET6
|
#ifndef __u_char_defined
|
||||||
#include "eui64.h"
|
|
||||||
|
/* Type definitions for BSD code. */
|
||||||
|
typedef unsigned long u_long;
|
||||||
|
typedef unsigned int u_int;
|
||||||
|
typedef unsigned short u_short;
|
||||||
|
typedef unsigned char u_char;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* Limits.
|
|
||||||
*/
|
|
||||||
#define NUM_PPP 1 /* One PPP interface supported (per process) */
|
|
||||||
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
|
|
||||||
#define MAXARGS 1 /* max # args to a command */
|
|
||||||
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
|
||||||
#define MAXSECRETLEN 256 /* max length of password or secret */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The basic PPP frame.
|
|
||||||
*/
|
|
||||||
#define PPP_HDRLEN 4 /* octets for standard ppp header */
|
|
||||||
#define PPP_FCSLEN 2 /* octets for FCS */
|
|
||||||
|
|
||||||
#define PPP_ADDRESS(p) (((u_char *)(p))[0])
|
|
||||||
#define PPP_CONTROL(p) (((u_char *)(p))[1])
|
|
||||||
#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Significant octet values.
|
|
||||||
*/
|
|
||||||
#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
|
|
||||||
#define PPP_UI 0x03 /* Unnumbered Information */
|
|
||||||
#define PPP_FLAG 0x7e /* Flag Sequence */
|
|
||||||
#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
|
|
||||||
#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Protocol field values.
|
|
||||||
*/
|
|
||||||
#define PPP_IP 0x21 /* Internet Protocol */
|
|
||||||
#if 0 /* UNUSED */
|
|
||||||
#define PPP_AT 0x29 /* AppleTalk Protocol */
|
|
||||||
#define PPP_IPX 0x2b /* IPX protocol */
|
|
||||||
#endif /* UNUSED */
|
|
||||||
#if VJ_SUPPORT
|
|
||||||
#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
|
|
||||||
#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
|
|
||||||
#endif /* VJ_SUPPORT */
|
|
||||||
#ifdef INET6
|
|
||||||
#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
|
|
||||||
#endif /* INET6 */
|
|
||||||
#if CCP_SUPPORT
|
|
||||||
#define PPP_COMP 0xfd /* compressed packet */
|
|
||||||
#endif /* CCP_SUPPORT */
|
|
||||||
#define PPP_IPCP 0x8021 /* IP Control Protocol */
|
|
||||||
#if 0 /* UNUSED */
|
|
||||||
#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
|
|
||||||
#define PPP_IPXCP 0x802b /* IPX Control Protocol */
|
|
||||||
#endif /* UNUSED */
|
|
||||||
#ifdef INET6
|
|
||||||
#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
|
|
||||||
#endif /* INET6 */
|
|
||||||
#if CCP_SUPPORT
|
|
||||||
#define PPP_CCP 0x80fd /* Compression Control Protocol */
|
|
||||||
#endif /* CCP_SUPPORT */
|
|
||||||
#if ECP_SUPPORT
|
|
||||||
#define PPP_ECP 0x8053 /* Encryption Control Protocol */
|
|
||||||
#endif /* ECP_SUPPORT */
|
|
||||||
#define PPP_LCP 0xc021 /* Link Control Protocol */
|
|
||||||
#if PAP_SUPPORT
|
|
||||||
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
|
|
||||||
#endif /* PAP_SUPPORT */
|
|
||||||
#if LQR_SUPPORT
|
|
||||||
#define PPP_LQR 0xc025 /* Link Quality Report protocol */
|
|
||||||
#endif /* LQR_SUPPORT */
|
|
||||||
#if CHAP_SUPPORT
|
|
||||||
#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
|
|
||||||
#endif /* CHAP_SUPPORT */
|
|
||||||
#if CBCP_SUPPORT
|
|
||||||
#define PPP_CBCP 0xc029 /* Callback Control Protocol */
|
|
||||||
#endif /* CBCP_SUPPORT */
|
|
||||||
#if EAP_SUPPORT
|
|
||||||
#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */
|
|
||||||
#endif /* EAP_SUPPORT */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Values for FCS calculations.
|
|
||||||
*/
|
|
||||||
#define PPP_INITFCS 0xffff /* Initial FCS value */
|
|
||||||
#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
|
|
||||||
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A 32-bit unsigned integral type.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \
|
|
||||||
&& !defined(__FreeBSD__) && (NS_TARGET < 40)
|
|
||||||
#ifdef UINT32_T
|
|
||||||
typedef UINT32_T u_int32_t;
|
|
||||||
#else
|
|
||||||
typedef unsigned int u_int32_t;
|
|
||||||
typedef unsigned short u_int16_t;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Extended asyncmap - allows any character to be escaped.
|
|
||||||
*/
|
|
||||||
typedef u_char ext_accm[32];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* What to do with network protocol (NP) packets.
|
|
||||||
*/
|
|
||||||
enum NPmode {
|
|
||||||
NPMODE_PASS, /* pass the packet through */
|
|
||||||
NPMODE_DROP, /* silently drop the packet */
|
|
||||||
NPMODE_ERROR, /* return an error */
|
|
||||||
NPMODE_QUEUE /* save it up for later. */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Statistics.
|
|
||||||
*/
|
|
||||||
#if PPP_STATS_SUPPORT
|
|
||||||
struct pppstat {
|
|
||||||
unsigned int ppp_ibytes; /* bytes received */
|
|
||||||
unsigned int ppp_ipackets; /* packets received */
|
|
||||||
unsigned int ppp_ierrors; /* receive errors */
|
|
||||||
unsigned int ppp_obytes; /* bytes sent */
|
|
||||||
unsigned int ppp_opackets; /* packets sent */
|
|
||||||
unsigned int ppp_oerrors; /* transmit errors */
|
|
||||||
};
|
|
||||||
|
|
||||||
#if VJ_SUPPORT
|
|
||||||
struct vjstat {
|
|
||||||
unsigned int vjs_packets; /* outbound packets */
|
|
||||||
unsigned int vjs_compressed; /* outbound compressed packets */
|
|
||||||
unsigned int vjs_searches; /* searches for connection state */
|
|
||||||
unsigned int vjs_misses; /* times couldn't find conn. state */
|
|
||||||
unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
|
|
||||||
unsigned int vjs_compressedin; /* inbound compressed packets */
|
|
||||||
unsigned int vjs_errorin; /* inbound unknown type packets */
|
|
||||||
unsigned int vjs_tossed; /* inbound packets tossed because of error */
|
|
||||||
};
|
|
||||||
#endif /* VJ_SUPPORT */
|
|
||||||
|
|
||||||
struct ppp_stats {
|
|
||||||
struct pppstat p; /* basic PPP statistics */
|
|
||||||
#if VJ_SUPPORT
|
|
||||||
struct vjstat vj; /* VJ header compression statistics */
|
|
||||||
#endif /* VJ_SUPPORT */
|
|
||||||
};
|
|
||||||
|
|
||||||
#if CCP_SUPPORT
|
|
||||||
struct compstat {
|
|
||||||
unsigned int unc_bytes; /* total uncompressed bytes */
|
|
||||||
unsigned int unc_packets; /* total uncompressed packets */
|
|
||||||
unsigned int comp_bytes; /* compressed bytes */
|
|
||||||
unsigned int comp_packets; /* compressed packets */
|
|
||||||
unsigned int inc_bytes; /* incompressible bytes */
|
|
||||||
unsigned int inc_packets; /* incompressible packets */
|
|
||||||
unsigned int ratio; /* recent compression ratio << 8 */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ppp_comp_stats {
|
|
||||||
struct compstat c; /* packet compression statistics */
|
|
||||||
struct compstat d; /* packet decompression statistics */
|
|
||||||
};
|
|
||||||
#endif /* CCP_SUPPORT */
|
|
||||||
|
|
||||||
#endif /* PPP_STATS_SUPPORT */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following structure records the time in seconds since
|
|
||||||
* the last NP packet was sent or received.
|
|
||||||
*/
|
|
||||||
/* FIXME: add idle time support and make it optional */
|
|
||||||
struct ppp_idle {
|
|
||||||
time_t xmit_idle; /* time since last NP packet sent */
|
|
||||||
time_t recv_idle; /* time since last NP packet received */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* FIXME: make endpoint discriminator optional */
|
|
||||||
|
|
||||||
/* An endpoint discriminator, used with multilink. */
|
|
||||||
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
|
||||||
struct epdisc {
|
|
||||||
unsigned char class;
|
|
||||||
unsigned char length;
|
|
||||||
unsigned char value[MAX_ENDP_LEN];
|
|
||||||
};
|
|
||||||
|
|
||||||
/* values for epdisc.class */
|
|
||||||
#define EPD_NULL 0 /* null discriminator, no data */
|
|
||||||
#define EPD_LOCAL 1
|
|
||||||
#define EPD_IP 2
|
|
||||||
#define EPD_MAC 3
|
|
||||||
#define EPD_MAGIC 4
|
|
||||||
#define EPD_PHONENUM 5
|
|
||||||
|
|
||||||
/* FIXME: global variables per PPP session */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Global variables.
|
|
||||||
*/
|
|
||||||
/* FIXME: improve debug flag */
|
|
||||||
extern int debug; /* Debug flag */
|
|
||||||
|
|
||||||
/* FIXME: is our_name really necessary ? */
|
|
||||||
extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */
|
|
||||||
extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
|
|
||||||
extern bool explicit_remote;/* remote_name specified with remotename opt */
|
|
||||||
|
|
||||||
/* FIXME: make it a compile time option */
|
|
||||||
extern int idle_time_limit;/* Shut down link if idle for this long */
|
|
||||||
|
|
||||||
extern int phase; /* Current state of link - see values below */
|
|
||||||
extern int error_count; /* # of times error() has been called */
|
|
||||||
extern int unsuccess; /* # unsuccessful connection attempts */
|
|
||||||
extern int listen_time; /* time to listen first (ms) */
|
|
||||||
extern int status; /* exit status for pppd */
|
|
||||||
extern int need_holdoff; /* Need holdoff period after link terminates */
|
|
||||||
/* FIXME: remove ifunit */
|
|
||||||
extern int ifunit; /* Interface unit number */
|
|
||||||
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
|
||||||
|
|
||||||
/* FIXME: add more HAVE_MULTILINK */
|
|
||||||
extern bool multilink; /* enable multilink operation */
|
|
||||||
|
|
||||||
/* FIXME: it is really necessary ? */
|
|
||||||
extern int maxconnect; /* Maximum connect time (seconds) */
|
|
||||||
|
|
||||||
#ifdef HAVE_MULTILINK
|
|
||||||
extern bool doing_multilink;
|
|
||||||
extern bool multilink_master;
|
|
||||||
extern bool bundle_eof;
|
|
||||||
extern bool bundle_terminating;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MAXOCTETS
|
|
||||||
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
|
|
||||||
extern int maxoctets_dir; /* Direction :
|
|
||||||
0 - in+out (default)
|
|
||||||
1 - in
|
|
||||||
2 - out
|
|
||||||
3 - max(in,out) */
|
|
||||||
extern int maxoctets_timeout; /* Timeout for check of octets limit */
|
|
||||||
#define PPP_OCTETS_DIRECTION_SUM 0
|
|
||||||
#define PPP_OCTETS_DIRECTION_IN 1
|
|
||||||
#define PPP_OCTETS_DIRECTION_OUT 2
|
|
||||||
#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
|
|
||||||
/* same as previos, but little different on RADIUS side */
|
|
||||||
#define PPP_OCTETS_DIRECTION_MAXSESSION 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following struct gives the addresses of procedures to call
|
|
||||||
* for a particular protocol.
|
|
||||||
*/
|
|
||||||
struct protent {
|
|
||||||
u_short protocol; /* PPP protocol number */
|
|
||||||
/* Initialization procedure */
|
|
||||||
void (*init) __P((int unit));
|
|
||||||
/* Process a received packet */
|
|
||||||
void (*input) __P((int unit, u_char *pkt, int len));
|
|
||||||
/* Process a received protocol-reject */
|
|
||||||
void (*protrej) __P((int unit));
|
|
||||||
/* Lower layer has come up */
|
|
||||||
void (*lowerup) __P((int unit));
|
|
||||||
/* Lower layer has gone down */
|
|
||||||
void (*lowerdown) __P((int unit));
|
|
||||||
/* Open the protocol */
|
|
||||||
void (*open) __P((int unit));
|
|
||||||
/* Close the protocol */
|
|
||||||
void (*close) __P((int unit, char *reason));
|
|
||||||
#if PRINTPKT_SUPPORT
|
|
||||||
/* Print a packet in readable form */
|
|
||||||
int (*printpkt) __P((u_char *pkt, int len,
|
|
||||||
void (*printer) __P((void *, char *, ...)),
|
|
||||||
void *arg));
|
|
||||||
#endif /* PRINTPKT_SUPPORT */
|
|
||||||
/* FIXME: data input is only used by CCP, which is not supported at this time,
|
|
||||||
* should we remove this entry and save some flash ?
|
|
||||||
*/
|
|
||||||
/* Process a received data packet */
|
|
||||||
void (*datainput) __P((int unit, u_char *pkt, int len));
|
|
||||||
bool enabled_flag; /* 0 iff protocol is disabled */
|
|
||||||
#if PRINTPKT_SUPPORT
|
|
||||||
char *name; /* Text name of protocol */
|
|
||||||
char *data_name; /* Text name of corresponding data protocol */
|
|
||||||
#endif /* PRINTPKT_SUPPORT */
|
|
||||||
#if PPP_OPTIONS
|
|
||||||
option_t *options; /* List of command-line options */
|
|
||||||
/* Check requested options, assign defaults */
|
|
||||||
void (*check_options) __P((void));
|
|
||||||
#endif /* PPP_OPTIONS */
|
|
||||||
#if DEMAND_SUPPORT
|
|
||||||
/* Configure interface for demand-dial */
|
|
||||||
int (*demand_conf) __P((int unit));
|
|
||||||
/* Say whether to bring up link for this pkt */
|
|
||||||
int (*active_pkt) __P((u_char *pkt, int len));
|
|
||||||
#endif /* DEMAND_SUPPORT */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Table of pointers to supported protocols */
|
|
||||||
extern struct protent *protocols[];
|
|
||||||
|
|
||||||
|
|
||||||
/* Values for auth_pending, auth_done */
|
|
||||||
#if PAP_SUPPORT
|
|
||||||
#define PAP_WITHPEER 0x1
|
|
||||||
#define PAP_PEER 0x2
|
|
||||||
#endif /* PAP_SUPPORT */
|
|
||||||
#if CHAP_SUPPORT
|
|
||||||
#define CHAP_WITHPEER 0x4
|
|
||||||
#define CHAP_PEER 0x8
|
|
||||||
#endif /* CHAP_SUPPORT */
|
|
||||||
#if EAP_SUPPORT
|
|
||||||
#define EAP_WITHPEER 0x10
|
|
||||||
#define EAP_PEER 0x20
|
|
||||||
#endif /* EAP_SUPPORT */
|
|
||||||
|
|
||||||
/* Values for auth_done only */
|
|
||||||
#if CHAP_SUPPORT
|
|
||||||
#define CHAP_MD5_WITHPEER 0x40
|
|
||||||
#define CHAP_MD5_PEER 0x80
|
|
||||||
#if MSCHAP_SUPPORT
|
|
||||||
#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
|
|
||||||
#define CHAP_MS_WITHPEER 0x100
|
|
||||||
#define CHAP_MS_PEER 0x200
|
|
||||||
#define CHAP_MS2_WITHPEER 0x400
|
|
||||||
#define CHAP_MS2_PEER 0x800
|
|
||||||
#endif /* MSCHAP_SUPPORT */
|
|
||||||
#endif /* CHAP_SUPPORT */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Values for phase.
|
|
||||||
*/
|
|
||||||
#define PHASE_DEAD 0
|
|
||||||
#define PHASE_INITIALIZE 1
|
|
||||||
#define PHASE_SERIALCONN 2
|
|
||||||
#define PHASE_DORMANT 3
|
|
||||||
#define PHASE_ESTABLISH 4
|
|
||||||
#define PHASE_AUTHENTICATE 5
|
|
||||||
#define PHASE_CALLBACK 6
|
|
||||||
#define PHASE_NETWORK 7
|
|
||||||
#define PHASE_RUNNING 8
|
|
||||||
#define PHASE_TERMINATE 9
|
|
||||||
#define PHASE_DISCONNECT 10
|
|
||||||
#define PHASE_HOLDOFF 11
|
|
||||||
#define PHASE_MASTER 12
|
|
||||||
|
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
*** PUBLIC DEFINITIONS ***
|
*** PUBLIC DEFINITIONS ***
|
||||||
@ -454,58 +92,14 @@ struct ppp_addrs {
|
|||||||
ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2;
|
ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if PPP_STATS_SUPPORT
|
|
||||||
/*
|
|
||||||
* PPP statistics structure
|
|
||||||
*/
|
|
||||||
struct pppd_stats {
|
|
||||||
unsigned int bytes_in;
|
|
||||||
unsigned int bytes_out;
|
|
||||||
unsigned int pkts_in;
|
|
||||||
unsigned int pkts_out;
|
|
||||||
};
|
|
||||||
#endif /* PPP_STATS_SUPPORT */
|
|
||||||
|
|
||||||
/* FIXME: use PPP option instead ? */
|
|
||||||
|
|
||||||
struct ppp_settings {
|
|
||||||
|
|
||||||
u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */
|
|
||||||
u_int auth_required : 1; /* Peer is required to authenticate */
|
|
||||||
u_int explicit_remote : 1; /* remote_name specified with remotename opt */
|
|
||||||
#if PAP_SUPPORT
|
|
||||||
u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */
|
|
||||||
#endif /* PAP_SUPPORT */
|
|
||||||
#if CHAP_SUPPORT
|
|
||||||
u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */
|
|
||||||
#endif /* CHAP_SUPPORT */
|
|
||||||
#if MSCHAP_SUPPORT
|
|
||||||
u_int refuse_mschap : 1; /* Don't wanna auth. ourselves with MS-CHAP */
|
|
||||||
u_int refuse_mschap_v2 : 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */
|
|
||||||
#endif /* MSCHAP_SUPPORT */
|
|
||||||
#if EAP_SUPPORT
|
|
||||||
u_int refuse_eap : 1; /* Don't wanna auth. ourselves with EAP */
|
|
||||||
#endif /* EAP_SUPPORT */
|
|
||||||
u_int usehostname : 1; /* Use hostname for our_name */
|
|
||||||
u_int usepeerdns : 1; /* Ask peer for DNS adds */
|
|
||||||
|
|
||||||
u_short idle_time_limit; /* Shut down link if idle for this long */
|
|
||||||
int maxconnect; /* Maximum connect time (seconds) */
|
|
||||||
|
|
||||||
char user [MAXNAMELEN + 1]; /* Username for PAP */
|
|
||||||
char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */
|
|
||||||
char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */
|
|
||||||
/* FIXME: re-enable that */
|
|
||||||
/* char remote_name[MAXNAMELEN + 1]; */ /* Peer's name for authentication */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ppp_settings ppp_settings;
|
|
||||||
|
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
*** PUBLIC FUNCTIONS ***
|
*** PUBLIC FUNCTIONS ***
|
||||||
************************/
|
************************/
|
||||||
|
|
||||||
|
/* Initialize the PPP subsystem. */
|
||||||
|
int ppp_init(void);
|
||||||
|
|
||||||
/* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
|
/* Warning: Using PPPAUTHTYPE_ANY might have security consequences.
|
||||||
* RFC 1994 says:
|
* RFC 1994 says:
|
||||||
*
|
*
|
||||||
@ -529,21 +123,19 @@ enum pppAuthType {
|
|||||||
#if CHAP_SUPPORT
|
#if CHAP_SUPPORT
|
||||||
PPPAUTHTYPE_CHAP,
|
PPPAUTHTYPE_CHAP,
|
||||||
#endif /* CHAP_SUPPORT */
|
#endif /* CHAP_SUPPORT */
|
||||||
|
#if PAP_SUPPORT
|
||||||
PPPAUTHTYPE_PAP,
|
PPPAUTHTYPE_PAP,
|
||||||
|
#endif /* PAP_SUPPORT */
|
||||||
PPPAUTHTYPE_ANY,
|
PPPAUTHTYPE_ANY,
|
||||||
PPPAUTHTYPE_NONE
|
PPPAUTHTYPE_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Initialize the PPP subsystem. */
|
|
||||||
int ppp_init(void);
|
|
||||||
|
|
||||||
void ppp_set_auth(enum pppAuthType authType, const char *user, const char *passwd);
|
void ppp_set_auth(enum pppAuthType authType, const char *user, const char *passwd);
|
||||||
|
|
||||||
/* Link status callback function prototype */
|
/* Link status callback function prototype */
|
||||||
typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg);
|
typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg);
|
||||||
|
|
||||||
#if PPPOS_SUPPORT
|
#if PPPOS_SUPPORT
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open a new PPP connection using the given serial I/O device.
|
* Open a new PPP connection using the given serial I/O device.
|
||||||
* This initializes the PPP control block but does not
|
* This initializes the PPP control block but does not
|
||||||
@ -556,26 +148,19 @@ typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg);
|
|||||||
* an error code (negative) on failure.
|
* an error code (negative) on failure.
|
||||||
*/
|
*/
|
||||||
int pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
|
int pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
|
||||||
|
|
||||||
#if !PPP_INPROC_OWNTHREAD
|
|
||||||
/*
|
|
||||||
* PPP over Serial: this is the input function to be called for received data.
|
|
||||||
* If PPP_INPROC_OWNTHREAD==1, a separate input thread using the blocking
|
|
||||||
* sio_read() is used, so this is deactivated.
|
|
||||||
*/
|
|
||||||
void pppos_input(int pd, u_char* data, int len);
|
|
||||||
#endif /* !PPP_INPROC_OWNTHREAD */
|
|
||||||
|
|
||||||
#endif /* PPPOS_SUPPORT */
|
#endif /* PPPOS_SUPPORT */
|
||||||
|
|
||||||
#if PPPOE_SUPPORT
|
#if PPPOE_SUPPORT
|
||||||
/*
|
/*
|
||||||
* Open a new PPP Over Ethernet (PPPOE) connection.
|
* Open a new PPP Over Ethernet (PPPoE) connection.
|
||||||
*/
|
*/
|
||||||
int ppp_over_ethernet_open(struct netif *ethif, const char *service_name, const char *concentrator_name,
|
int ppp_over_ethernet_open(struct netif *ethif, const char *service_name, const char *concentrator_name,
|
||||||
pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
|
pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
|
||||||
#endif /* PPPOE_SUPPORT */
|
#endif /* PPPOE_SUPPORT */
|
||||||
|
|
||||||
|
/* for source code compatibility */
|
||||||
|
#define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close a PPP connection and release the descriptor.
|
* Close a PPP connection and release the descriptor.
|
||||||
* Any outstanding packets in the queues are dropped.
|
* Any outstanding packets in the queues are dropped.
|
||||||
@ -588,261 +173,37 @@ int pppClose(int pd);
|
|||||||
*/
|
*/
|
||||||
void pppSigHUP(int pd);
|
void pppSigHUP(int pd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get and set parameters for the given connection.
|
||||||
|
* Return 0 on success, an error code on failure.
|
||||||
|
*/
|
||||||
|
int pppIOCtl(int pd, int cmd, void *arg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the Maximum Transmission Unit for the given PPP connection.
|
||||||
|
*/
|
||||||
|
/* FIXME: demystify MTU support */
|
||||||
|
u_short pppMTU(int pd);
|
||||||
|
|
||||||
|
#if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD
|
||||||
|
/*
|
||||||
|
* PPP over Serial: this is the input function to be called for received data.
|
||||||
|
* If PPP_INPROC_OWNTHREAD==1, a seperate input thread using the blocking
|
||||||
|
* sio_read() is used, so this is deactivated.
|
||||||
|
*/
|
||||||
|
void pppos_input(int pd, u_char* data, int len);
|
||||||
|
#endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */
|
||||||
|
|
||||||
|
|
||||||
#if LWIP_NETIF_STATUS_CALLBACK
|
#if LWIP_NETIF_STATUS_CALLBACK
|
||||||
/* Set an lwIP-style status-callback for the selected PPP device */
|
/* Set an lwIP-style status-callback for the selected PPP device */
|
||||||
void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback);
|
void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback);
|
||||||
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
#endif /* LWIP_NETIF_STATUS_CALLBACK */
|
||||||
|
|
||||||
#if LWIP_NETIF_LINK_CALLBACK
|
#if LWIP_NETIF_LINK_CALLBACK
|
||||||
/* Set an lwIP-style link-callback for the selected PPP device */
|
/* Set an lwIP-style link-callback for the selected PPP device */
|
||||||
void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback);
|
void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback);
|
||||||
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
#endif /* LWIP_NETIF_LINK_CALLBACK */
|
||||||
|
|
||||||
|
#endif /* PPP_H */
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------ *
|
|
||||||
* --- EVERYTHING BELOW SHOULD BE CONSIDERED PRIVATE ---- *
|
|
||||||
* ------------------------------------------------------ */
|
|
||||||
|
|
||||||
/* PPP flow functions
|
|
||||||
*/
|
|
||||||
#if PPPOE_SUPPORT
|
|
||||||
void pppOverEthernetInitFailed(int pd);
|
|
||||||
/* function called by pppoe.c */
|
|
||||||
void ppp_input_over_ethernet(int pd, struct pbuf *pb);
|
|
||||||
#endif /* PPPOE_SUPPORT */
|
|
||||||
|
|
||||||
int pppIOCtl(int pd, int cmd, void *arg);
|
|
||||||
|
|
||||||
/* FIXME: demystify MTU support */
|
|
||||||
u_short pppMTU(int pd);
|
|
||||||
|
|
||||||
/* function called by all PPP subsystems to send packets */
|
|
||||||
int ppp_write(int pd, const u_char *s, int n);
|
|
||||||
|
|
||||||
/* functions called by auth.c link_terminated() */
|
|
||||||
void pppLinkDown(int pd);
|
|
||||||
void pppLinkTerminated(int pd);
|
|
||||||
|
|
||||||
/* merge a pbuf chain into one pbuf */
|
|
||||||
struct pbuf * ppp_singlebuf(struct pbuf *p);
|
|
||||||
|
|
||||||
|
|
||||||
/* Functions called by various PPP subsystems to configure
|
|
||||||
* the PPP interface or change the PPP phase.
|
|
||||||
*/
|
|
||||||
void new_phase(int p);
|
|
||||||
|
|
||||||
#if PPPOS_SUPPORT
|
|
||||||
void ppp_set_xaccm(int unit, ext_accm *accm);
|
|
||||||
#endif /* PPPOS_SUPPORT */
|
|
||||||
int ppp_send_config(int unit, int mtu, u_int32_t accm, int pcomp, int accomp);
|
|
||||||
int ppp_recv_config(int unit, int mru, u_int32_t accm, int pcomp, int accomp);
|
|
||||||
|
|
||||||
int sifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr, u_int32_t net_mask);
|
|
||||||
int cifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr);
|
|
||||||
|
|
||||||
int sifup(int u);
|
|
||||||
int sifdown (int u);
|
|
||||||
|
|
||||||
int sifnpmode(int u, int proto, enum NPmode mode);
|
|
||||||
|
|
||||||
void netif_set_mtu(int unit, int mtu);
|
|
||||||
int netif_get_mtu(int mtu);
|
|
||||||
|
|
||||||
int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace);
|
|
||||||
int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway);
|
|
||||||
|
|
||||||
int sifproxyarp (int unit, u_int32_t his_adr);
|
|
||||||
int cifproxyarp (int unit, u_int32_t his_adr);
|
|
||||||
|
|
||||||
int sifvjcomp (int u, int vjcomp, int cidcomp, int maxcid);
|
|
||||||
|
|
||||||
int get_idle_time(int u, struct ppp_idle *ip);
|
|
||||||
|
|
||||||
int get_loop_output(void);
|
|
||||||
|
|
||||||
u_int32_t GetMask (u_int32_t addr);
|
|
||||||
|
|
||||||
|
|
||||||
/* Optional protocol names list, to make our messages a little more informative. */
|
|
||||||
#if PPP_PROTOCOLNAME
|
|
||||||
const char * protocol_name(int proto);
|
|
||||||
#endif /* PPP_PROTOCOLNAME */
|
|
||||||
|
|
||||||
|
|
||||||
/* Optional stats support, to get some statistics on the PPP interface */
|
|
||||||
#if PPP_STATS_SUPPORT
|
|
||||||
void print_link_stats(void); /* Print stats, if available */
|
|
||||||
void reset_link_stats(int u); /* Reset (init) stats when link goes up */
|
|
||||||
void update_link_stats(int u); /* Get stats at link termination */
|
|
||||||
#endif /* PPP_STATS_SUPPORT */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Inline versions of get/put char/short/long.
|
|
||||||
* Pointer is advanced; we assume that both arguments
|
|
||||||
* are lvalues and will already be in registers.
|
|
||||||
* cp MUST be u_char *.
|
|
||||||
*/
|
|
||||||
#define GETCHAR(c, cp) { \
|
|
||||||
(c) = *(cp)++; \
|
|
||||||
}
|
|
||||||
#define PUTCHAR(c, cp) { \
|
|
||||||
*(cp)++ = (u_char) (c); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define GETSHORT(s, cp) { \
|
|
||||||
(s) = *(cp)++ << 8; \
|
|
||||||
(s) |= *(cp)++; \
|
|
||||||
}
|
|
||||||
#define PUTSHORT(s, cp) { \
|
|
||||||
*(cp)++ = (u_char) ((s) >> 8); \
|
|
||||||
*(cp)++ = (u_char) (s); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GETLONG(l, cp) { \
|
|
||||||
(l) = *(cp)++ << 8; \
|
|
||||||
(l) |= *(cp)++; (l) <<= 8; \
|
|
||||||
(l) |= *(cp)++; (l) <<= 8; \
|
|
||||||
(l) |= *(cp)++; \
|
|
||||||
}
|
|
||||||
#define PUTLONG(l, cp) { \
|
|
||||||
*(cp)++ = (u_char) ((l) >> 24); \
|
|
||||||
*(cp)++ = (u_char) ((l) >> 16); \
|
|
||||||
*(cp)++ = (u_char) ((l) >> 8); \
|
|
||||||
*(cp)++ = (u_char) (l); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define INCPTR(n, cp) ((cp) += (n))
|
|
||||||
#define DECPTR(n, cp) ((cp) -= (n))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
|
||||||
*/
|
|
||||||
#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
|
|
||||||
#define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0)
|
|
||||||
#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
|
|
||||||
|
|
||||||
#define BZERO(s, n) memset(s, 0, n)
|
|
||||||
#define BCMP(s1, s2, l) memcmp(s1, s2, l)
|
|
||||||
|
|
||||||
#define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MAKEHEADER - Add Header fields to a packet.
|
|
||||||
*/
|
|
||||||
#define MAKEHEADER(p, t) { \
|
|
||||||
PUTCHAR(PPP_ALLSTATIONS, p); \
|
|
||||||
PUTCHAR(PPP_UI, p); \
|
|
||||||
PUTSHORT(t, p); }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Exit status values.
|
|
||||||
*/
|
|
||||||
#define EXIT_OK 0
|
|
||||||
#define EXIT_FATAL_ERROR 1
|
|
||||||
#define EXIT_OPTION_ERROR 2
|
|
||||||
#define EXIT_NOT_ROOT 3
|
|
||||||
#define EXIT_NO_KERNEL_SUPPORT 4
|
|
||||||
#define EXIT_USER_REQUEST 5
|
|
||||||
#define EXIT_LOCK_FAILED 6
|
|
||||||
#define EXIT_OPEN_FAILED 7
|
|
||||||
#define EXIT_CONNECT_FAILED 8
|
|
||||||
#define EXIT_PTYCMD_FAILED 9
|
|
||||||
#define EXIT_NEGOTIATION_FAILED 10
|
|
||||||
#define EXIT_PEER_AUTH_FAILED 11
|
|
||||||
#define EXIT_IDLE_TIMEOUT 12
|
|
||||||
#define EXIT_CONNECT_TIME 13
|
|
||||||
#define EXIT_CALLBACK 14
|
|
||||||
#define EXIT_PEER_DEAD 15
|
|
||||||
#define EXIT_HANGUP 16
|
|
||||||
#define EXIT_LOOPBACK 17
|
|
||||||
#define EXIT_INIT_FAILED 18
|
|
||||||
#define EXIT_AUTH_TOPEER_FAILED 19
|
|
||||||
#ifdef MAXOCTETS
|
|
||||||
#define EXIT_TRAFFIC_LIMIT 20
|
|
||||||
#endif
|
|
||||||
#define EXIT_CNID_AUTH_FAILED 21
|
|
||||||
|
|
||||||
/* Procedures exported from auth.c */
|
|
||||||
void link_required __P((int)); /* we are starting to use the link */
|
|
||||||
void link_terminated __P((int)); /* we are finished with the link */
|
|
||||||
void link_down __P((int)); /* the LCP layer has left the Opened state */
|
|
||||||
void upper_layers_down __P((int));/* take all NCPs down */
|
|
||||||
void link_established __P((int)); /* the link is up; authenticate now */
|
|
||||||
void start_networks __P((int)); /* start all the network control protos */
|
|
||||||
void continue_networks __P((int)); /* start network [ip, etc] control protos */
|
|
||||||
|
|
||||||
void auth_peer_fail __P((int, int));
|
|
||||||
/* peer failed to authenticate itself */
|
|
||||||
void auth_peer_success __P((int, int, int, char *, int));
|
|
||||||
/* peer successfully authenticated itself */
|
|
||||||
void auth_withpeer_fail __P((int, int));
|
|
||||||
/* we failed to authenticate ourselves */
|
|
||||||
void auth_withpeer_success __P((int, int, int));
|
|
||||||
/* we successfully authenticated ourselves */
|
|
||||||
void np_up __P((int, int)); /* a network protocol has come up */
|
|
||||||
void np_down __P((int, int)); /* a network protocol has gone down */
|
|
||||||
void np_finished __P((int, int)); /* a network protocol no longer needs link */
|
|
||||||
void auth_reset __P((int)); /* check what secrets we have */
|
|
||||||
int get_secret __P((int, char *, char *, char *, int *, int));
|
|
||||||
/* get "secret" for chap */
|
|
||||||
|
|
||||||
/* Procedures exported from ipcp.c */
|
|
||||||
/* int parse_dotted_ip __P((char *, u_int32_t *)); */
|
|
||||||
|
|
||||||
/* Procedures exported from demand.c */
|
|
||||||
#if DEMAND_SUPPORT
|
|
||||||
void demand_conf __P((void)); /* config interface(s) for demand-dial */
|
|
||||||
void demand_block __P((void)); /* set all NPs to queue up packets */
|
|
||||||
void demand_unblock __P((void)); /* set all NPs to pass packets */
|
|
||||||
void demand_discard __P((void)); /* set all NPs to discard packets */
|
|
||||||
void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
|
|
||||||
int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
|
|
||||||
int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
|
|
||||||
#endif /* DEMAND_SUPPORT */
|
|
||||||
|
|
||||||
/* Procedures exported from multilink.c */
|
|
||||||
#ifdef HAVE_MULTILINK
|
|
||||||
void mp_check_options __P((void)); /* Check multilink-related options */
|
|
||||||
int mp_join_bundle __P((void)); /* join our link to an appropriate bundle */
|
|
||||||
void mp_exit_bundle __P((void)); /* have disconnected our link from bundle */
|
|
||||||
void mp_bundle_terminated __P((void));
|
|
||||||
char *epdisc_to_str __P((struct epdisc *)); /* string from endpoint discrim. */
|
|
||||||
int str_to_epdisc __P((struct epdisc *, char *)); /* endpt disc. from str */
|
|
||||||
#else
|
|
||||||
#define mp_bundle_terminated() /* nothing */
|
|
||||||
#define mp_exit_bundle() /* nothing */
|
|
||||||
#define doing_multilink 0
|
|
||||||
#define multilink_master 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Procedures exported from utils.c. */
|
|
||||||
void print_string __P((char *, int, void (*) (void *, char *, ...),
|
|
||||||
void *)); /* Format a string for output */
|
|
||||||
int slprintf __P((char *, int, char *, ...)); /* sprintf++ */
|
|
||||||
int vslprintf __P((char *, int, char *, va_list)); /* vsprintf++ */
|
|
||||||
size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */
|
|
||||||
size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */
|
|
||||||
void dbglog __P((char *, ...)); /* log a debug message */
|
|
||||||
void info __P((char *, ...)); /* log an informational message */
|
|
||||||
void notice __P((char *, ...)); /* log a notice-level message */
|
|
||||||
void warn __P((char *, ...)); /* log a warning message */
|
|
||||||
void error __P((char *, ...)); /* log an error message */
|
|
||||||
void fatal __P((char *, ...)); /* log an error message and die(1) */
|
|
||||||
void init_pr_log __P((const char *, int)); /* initialize for using pr_log */
|
|
||||||
void pr_log __P((void *, char *, ...)); /* printer fn, output to syslog */
|
|
||||||
void end_pr_log __P((void)); /* finish up after using pr_log */
|
|
||||||
#if PRINTPKT_SUPPORT
|
|
||||||
void dump_packet __P((const char *, u_char *, int));
|
|
||||||
/* dump packet to debug log if interesting */
|
|
||||||
#endif /* PRINTPKT_SUPPORT */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* PPPMY_H_ */
|
|
||||||
|
|
||||||
#endif /* PPP_SUPPORT */
|
#endif /* PPP_SUPPORT */
|
||||||
|
706
src/netif/ppp/ppp_impl.h
Normal file
706
src/netif/ppp/ppp_impl.h
Normal file
@ -0,0 +1,706 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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 "lwip/opt.h"
|
||||||
|
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
|
#ifndef PPP_IMP_H_
|
||||||
|
#define PPP_IMP_H_
|
||||||
|
|
||||||
|
#include <stdio.h> /* formats */
|
||||||
|
|
||||||
|
#if defined(__STDC__)
|
||||||
|
#include <stdarg.h>
|
||||||
|
#define __V(x) x
|
||||||
|
#else
|
||||||
|
#include <varargs.h>
|
||||||
|
#define __V(x) (va_alist) va_dcl
|
||||||
|
#define const
|
||||||
|
#define volatile
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __P
|
||||||
|
#ifdef __STDC__
|
||||||
|
#define __P(x) x
|
||||||
|
#else
|
||||||
|
#define __P(x) ()
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef bool
|
||||||
|
typedef unsigned char bool;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "lwip/netif.h"
|
||||||
|
#include "lwip/def.h"
|
||||||
|
#include "lwip/timers.h"
|
||||||
|
#include "lwip/sio.h"
|
||||||
|
|
||||||
|
#include "ppp.h"
|
||||||
|
#include "pppdebug.h"
|
||||||
|
|
||||||
|
#ifdef INET6
|
||||||
|
#include "eui64.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Limits.
|
||||||
|
*/
|
||||||
|
#define NUM_PPP 1 /* One PPP interface supported (per process) */
|
||||||
|
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
|
||||||
|
#define MAXARGS 1 /* max # args to a command */
|
||||||
|
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
||||||
|
#define MAXSECRETLEN 256 /* max length of password or secret */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The basic PPP frame.
|
||||||
|
*/
|
||||||
|
#define PPP_HDRLEN 4 /* octets for standard ppp header */
|
||||||
|
#define PPP_FCSLEN 2 /* octets for FCS */
|
||||||
|
|
||||||
|
#define PPP_ADDRESS(p) (((u_char *)(p))[0])
|
||||||
|
#define PPP_CONTROL(p) (((u_char *)(p))[1])
|
||||||
|
#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Significant octet values.
|
||||||
|
*/
|
||||||
|
#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
|
||||||
|
#define PPP_UI 0x03 /* Unnumbered Information */
|
||||||
|
#define PPP_FLAG 0x7e /* Flag Sequence */
|
||||||
|
#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
|
||||||
|
#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Protocol field values.
|
||||||
|
*/
|
||||||
|
#define PPP_IP 0x21 /* Internet Protocol */
|
||||||
|
#if 0 /* UNUSED */
|
||||||
|
#define PPP_AT 0x29 /* AppleTalk Protocol */
|
||||||
|
#define PPP_IPX 0x2b /* IPX protocol */
|
||||||
|
#endif /* UNUSED */
|
||||||
|
#if VJ_SUPPORT
|
||||||
|
#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
|
||||||
|
#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
|
||||||
|
#endif /* VJ_SUPPORT */
|
||||||
|
#ifdef INET6
|
||||||
|
#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
|
||||||
|
#endif /* INET6 */
|
||||||
|
#if CCP_SUPPORT
|
||||||
|
#define PPP_COMP 0xfd /* compressed packet */
|
||||||
|
#endif /* CCP_SUPPORT */
|
||||||
|
#define PPP_IPCP 0x8021 /* IP Control Protocol */
|
||||||
|
#if 0 /* UNUSED */
|
||||||
|
#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
|
||||||
|
#define PPP_IPXCP 0x802b /* IPX Control Protocol */
|
||||||
|
#endif /* UNUSED */
|
||||||
|
#ifdef INET6
|
||||||
|
#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
|
||||||
|
#endif /* INET6 */
|
||||||
|
#if CCP_SUPPORT
|
||||||
|
#define PPP_CCP 0x80fd /* Compression Control Protocol */
|
||||||
|
#endif /* CCP_SUPPORT */
|
||||||
|
#if ECP_SUPPORT
|
||||||
|
#define PPP_ECP 0x8053 /* Encryption Control Protocol */
|
||||||
|
#endif /* ECP_SUPPORT */
|
||||||
|
#define PPP_LCP 0xc021 /* Link Control Protocol */
|
||||||
|
#if PAP_SUPPORT
|
||||||
|
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
|
||||||
|
#endif /* PAP_SUPPORT */
|
||||||
|
#if LQR_SUPPORT
|
||||||
|
#define PPP_LQR 0xc025 /* Link Quality Report protocol */
|
||||||
|
#endif /* LQR_SUPPORT */
|
||||||
|
#if CHAP_SUPPORT
|
||||||
|
#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
|
||||||
|
#endif /* CHAP_SUPPORT */
|
||||||
|
#if CBCP_SUPPORT
|
||||||
|
#define PPP_CBCP 0xc029 /* Callback Control Protocol */
|
||||||
|
#endif /* CBCP_SUPPORT */
|
||||||
|
#if EAP_SUPPORT
|
||||||
|
#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */
|
||||||
|
#endif /* EAP_SUPPORT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Values for FCS calculations.
|
||||||
|
*/
|
||||||
|
#define PPP_INITFCS 0xffff /* Initial FCS value */
|
||||||
|
#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
|
||||||
|
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A 32-bit unsigned integral type.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \
|
||||||
|
&& !defined(__FreeBSD__) && (NS_TARGET < 40)
|
||||||
|
#ifdef UINT32_T
|
||||||
|
typedef UINT32_T u_int32_t;
|
||||||
|
#else
|
||||||
|
typedef unsigned int u_int32_t;
|
||||||
|
typedef unsigned short u_int16_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extended asyncmap - allows any character to be escaped.
|
||||||
|
*/
|
||||||
|
typedef u_char ext_accm[32];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* What to do with network protocol (NP) packets.
|
||||||
|
*/
|
||||||
|
enum NPmode {
|
||||||
|
NPMODE_PASS, /* pass the packet through */
|
||||||
|
NPMODE_DROP, /* silently drop the packet */
|
||||||
|
NPMODE_ERROR, /* return an error */
|
||||||
|
NPMODE_QUEUE /* save it up for later. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Statistics.
|
||||||
|
*/
|
||||||
|
#if PPP_STATS_SUPPORT
|
||||||
|
struct pppstat {
|
||||||
|
unsigned int ppp_ibytes; /* bytes received */
|
||||||
|
unsigned int ppp_ipackets; /* packets received */
|
||||||
|
unsigned int ppp_ierrors; /* receive errors */
|
||||||
|
unsigned int ppp_obytes; /* bytes sent */
|
||||||
|
unsigned int ppp_opackets; /* packets sent */
|
||||||
|
unsigned int ppp_oerrors; /* transmit errors */
|
||||||
|
};
|
||||||
|
|
||||||
|
#if VJ_SUPPORT
|
||||||
|
struct vjstat {
|
||||||
|
unsigned int vjs_packets; /* outbound packets */
|
||||||
|
unsigned int vjs_compressed; /* outbound compressed packets */
|
||||||
|
unsigned int vjs_searches; /* searches for connection state */
|
||||||
|
unsigned int vjs_misses; /* times couldn't find conn. state */
|
||||||
|
unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
|
||||||
|
unsigned int vjs_compressedin; /* inbound compressed packets */
|
||||||
|
unsigned int vjs_errorin; /* inbound unknown type packets */
|
||||||
|
unsigned int vjs_tossed; /* inbound packets tossed because of error */
|
||||||
|
};
|
||||||
|
#endif /* VJ_SUPPORT */
|
||||||
|
|
||||||
|
struct ppp_stats {
|
||||||
|
struct pppstat p; /* basic PPP statistics */
|
||||||
|
#if VJ_SUPPORT
|
||||||
|
struct vjstat vj; /* VJ header compression statistics */
|
||||||
|
#endif /* VJ_SUPPORT */
|
||||||
|
};
|
||||||
|
|
||||||
|
#if CCP_SUPPORT
|
||||||
|
struct compstat {
|
||||||
|
unsigned int unc_bytes; /* total uncompressed bytes */
|
||||||
|
unsigned int unc_packets; /* total uncompressed packets */
|
||||||
|
unsigned int comp_bytes; /* compressed bytes */
|
||||||
|
unsigned int comp_packets; /* compressed packets */
|
||||||
|
unsigned int inc_bytes; /* incompressible bytes */
|
||||||
|
unsigned int inc_packets; /* incompressible packets */
|
||||||
|
unsigned int ratio; /* recent compression ratio << 8 */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ppp_comp_stats {
|
||||||
|
struct compstat c; /* packet compression statistics */
|
||||||
|
struct compstat d; /* packet decompression statistics */
|
||||||
|
};
|
||||||
|
#endif /* CCP_SUPPORT */
|
||||||
|
|
||||||
|
#endif /* PPP_STATS_SUPPORT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following structure records the time in seconds since
|
||||||
|
* the last NP packet was sent or received.
|
||||||
|
*/
|
||||||
|
/* FIXME: add idle time support and make it optional */
|
||||||
|
struct ppp_idle {
|
||||||
|
time_t xmit_idle; /* time since last NP packet sent */
|
||||||
|
time_t recv_idle; /* time since last NP packet received */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* FIXME: make endpoint discriminator optional */
|
||||||
|
|
||||||
|
/* An endpoint discriminator, used with multilink. */
|
||||||
|
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
||||||
|
struct epdisc {
|
||||||
|
unsigned char class;
|
||||||
|
unsigned char length;
|
||||||
|
unsigned char value[MAX_ENDP_LEN];
|
||||||
|
};
|
||||||
|
|
||||||
|
/* values for epdisc.class */
|
||||||
|
#define EPD_NULL 0 /* null discriminator, no data */
|
||||||
|
#define EPD_LOCAL 1
|
||||||
|
#define EPD_IP 2
|
||||||
|
#define EPD_MAC 3
|
||||||
|
#define EPD_MAGIC 4
|
||||||
|
#define EPD_PHONENUM 5
|
||||||
|
|
||||||
|
/* FIXME: global variables per PPP session */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Global variables.
|
||||||
|
*/
|
||||||
|
/* FIXME: improve debug flag */
|
||||||
|
extern int debug; /* Debug flag */
|
||||||
|
|
||||||
|
/* FIXME: is our_name really necessary ? */
|
||||||
|
extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */
|
||||||
|
extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
|
||||||
|
extern bool explicit_remote;/* remote_name specified with remotename opt */
|
||||||
|
|
||||||
|
/* FIXME: make it a compile time option */
|
||||||
|
extern int idle_time_limit;/* Shut down link if idle for this long */
|
||||||
|
|
||||||
|
extern int phase; /* Current state of link - see values below */
|
||||||
|
extern int error_count; /* # of times error() has been called */
|
||||||
|
extern int unsuccess; /* # unsuccessful connection attempts */
|
||||||
|
extern int listen_time; /* time to listen first (ms) */
|
||||||
|
extern int status; /* exit status for pppd */
|
||||||
|
extern int need_holdoff; /* Need holdoff period after link terminates */
|
||||||
|
/* FIXME: remove ifunit */
|
||||||
|
extern int ifunit; /* Interface unit number */
|
||||||
|
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
||||||
|
|
||||||
|
/* FIXME: add more HAVE_MULTILINK */
|
||||||
|
extern bool multilink; /* enable multilink operation */
|
||||||
|
|
||||||
|
/* FIXME: it is really necessary ? */
|
||||||
|
extern int maxconnect; /* Maximum connect time (seconds) */
|
||||||
|
|
||||||
|
#ifdef HAVE_MULTILINK
|
||||||
|
extern bool doing_multilink;
|
||||||
|
extern bool multilink_master;
|
||||||
|
extern bool bundle_eof;
|
||||||
|
extern bool bundle_terminating;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAXOCTETS
|
||||||
|
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
|
||||||
|
extern int maxoctets_dir; /* Direction :
|
||||||
|
0 - in+out (default)
|
||||||
|
1 - in
|
||||||
|
2 - out
|
||||||
|
3 - max(in,out) */
|
||||||
|
extern int maxoctets_timeout; /* Timeout for check of octets limit */
|
||||||
|
#define PPP_OCTETS_DIRECTION_SUM 0
|
||||||
|
#define PPP_OCTETS_DIRECTION_IN 1
|
||||||
|
#define PPP_OCTETS_DIRECTION_OUT 2
|
||||||
|
#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
|
||||||
|
/* same as previos, but little different on RADIUS side */
|
||||||
|
#define PPP_OCTETS_DIRECTION_MAXSESSION 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following struct gives the addresses of procedures to call
|
||||||
|
* for a particular protocol.
|
||||||
|
*/
|
||||||
|
struct protent {
|
||||||
|
u_short protocol; /* PPP protocol number */
|
||||||
|
/* Initialization procedure */
|
||||||
|
void (*init) __P((int unit));
|
||||||
|
/* Process a received packet */
|
||||||
|
void (*input) __P((int unit, u_char *pkt, int len));
|
||||||
|
/* Process a received protocol-reject */
|
||||||
|
void (*protrej) __P((int unit));
|
||||||
|
/* Lower layer has come up */
|
||||||
|
void (*lowerup) __P((int unit));
|
||||||
|
/* Lower layer has gone down */
|
||||||
|
void (*lowerdown) __P((int unit));
|
||||||
|
/* Open the protocol */
|
||||||
|
void (*open) __P((int unit));
|
||||||
|
/* Close the protocol */
|
||||||
|
void (*close) __P((int unit, char *reason));
|
||||||
|
#if PRINTPKT_SUPPORT
|
||||||
|
/* Print a packet in readable form */
|
||||||
|
int (*printpkt) __P((u_char *pkt, int len,
|
||||||
|
void (*printer) __P((void *, char *, ...)),
|
||||||
|
void *arg));
|
||||||
|
#endif /* PRINTPKT_SUPPORT */
|
||||||
|
/* FIXME: data input is only used by CCP, which is not supported at this time,
|
||||||
|
* should we remove this entry and save some flash ?
|
||||||
|
*/
|
||||||
|
/* Process a received data packet */
|
||||||
|
void (*datainput) __P((int unit, u_char *pkt, int len));
|
||||||
|
bool enabled_flag; /* 0 iff protocol is disabled */
|
||||||
|
#if PRINTPKT_SUPPORT
|
||||||
|
char *name; /* Text name of protocol */
|
||||||
|
char *data_name; /* Text name of corresponding data protocol */
|
||||||
|
#endif /* PRINTPKT_SUPPORT */
|
||||||
|
#if PPP_OPTIONS
|
||||||
|
option_t *options; /* List of command-line options */
|
||||||
|
/* Check requested options, assign defaults */
|
||||||
|
void (*check_options) __P((void));
|
||||||
|
#endif /* PPP_OPTIONS */
|
||||||
|
#if DEMAND_SUPPORT
|
||||||
|
/* Configure interface for demand-dial */
|
||||||
|
int (*demand_conf) __P((int unit));
|
||||||
|
/* Say whether to bring up link for this pkt */
|
||||||
|
int (*active_pkt) __P((u_char *pkt, int len));
|
||||||
|
#endif /* DEMAND_SUPPORT */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Table of pointers to supported protocols */
|
||||||
|
extern struct protent *protocols[];
|
||||||
|
|
||||||
|
|
||||||
|
/* Values for auth_pending, auth_done */
|
||||||
|
#if PAP_SUPPORT
|
||||||
|
#define PAP_WITHPEER 0x1
|
||||||
|
#define PAP_PEER 0x2
|
||||||
|
#endif /* PAP_SUPPORT */
|
||||||
|
#if CHAP_SUPPORT
|
||||||
|
#define CHAP_WITHPEER 0x4
|
||||||
|
#define CHAP_PEER 0x8
|
||||||
|
#endif /* CHAP_SUPPORT */
|
||||||
|
#if EAP_SUPPORT
|
||||||
|
#define EAP_WITHPEER 0x10
|
||||||
|
#define EAP_PEER 0x20
|
||||||
|
#endif /* EAP_SUPPORT */
|
||||||
|
|
||||||
|
/* Values for auth_done only */
|
||||||
|
#if CHAP_SUPPORT
|
||||||
|
#define CHAP_MD5_WITHPEER 0x40
|
||||||
|
#define CHAP_MD5_PEER 0x80
|
||||||
|
#if MSCHAP_SUPPORT
|
||||||
|
#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
|
||||||
|
#define CHAP_MS_WITHPEER 0x100
|
||||||
|
#define CHAP_MS_PEER 0x200
|
||||||
|
#define CHAP_MS2_WITHPEER 0x400
|
||||||
|
#define CHAP_MS2_PEER 0x800
|
||||||
|
#endif /* MSCHAP_SUPPORT */
|
||||||
|
#endif /* CHAP_SUPPORT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Values for phase.
|
||||||
|
*/
|
||||||
|
#define PHASE_DEAD 0
|
||||||
|
#define PHASE_INITIALIZE 1
|
||||||
|
#define PHASE_SERIALCONN 2
|
||||||
|
#define PHASE_DORMANT 3
|
||||||
|
#define PHASE_ESTABLISH 4
|
||||||
|
#define PHASE_AUTHENTICATE 5
|
||||||
|
#define PHASE_CALLBACK 6
|
||||||
|
#define PHASE_NETWORK 7
|
||||||
|
#define PHASE_RUNNING 8
|
||||||
|
#define PHASE_TERMINATE 9
|
||||||
|
#define PHASE_DISCONNECT 10
|
||||||
|
#define PHASE_HOLDOFF 11
|
||||||
|
#define PHASE_MASTER 12
|
||||||
|
|
||||||
|
|
||||||
|
#if PPP_STATS_SUPPORT
|
||||||
|
/*
|
||||||
|
* PPP statistics structure
|
||||||
|
*/
|
||||||
|
struct pppd_stats {
|
||||||
|
unsigned int bytes_in;
|
||||||
|
unsigned int bytes_out;
|
||||||
|
unsigned int pkts_in;
|
||||||
|
unsigned int pkts_out;
|
||||||
|
};
|
||||||
|
#endif /* PPP_STATS_SUPPORT */
|
||||||
|
|
||||||
|
/* FIXME: fill the struct below with option.c global variables */
|
||||||
|
|
||||||
|
struct ppp_settings {
|
||||||
|
|
||||||
|
u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */
|
||||||
|
u_int auth_required : 1; /* Peer is required to authenticate */
|
||||||
|
u_int explicit_remote : 1; /* remote_name specified with remotename opt */
|
||||||
|
#if PAP_SUPPORT
|
||||||
|
u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */
|
||||||
|
#endif /* PAP_SUPPORT */
|
||||||
|
#if CHAP_SUPPORT
|
||||||
|
u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */
|
||||||
|
#endif /* CHAP_SUPPORT */
|
||||||
|
#if MSCHAP_SUPPORT
|
||||||
|
u_int refuse_mschap : 1; /* Don't wanna auth. ourselves with MS-CHAP */
|
||||||
|
u_int refuse_mschap_v2 : 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */
|
||||||
|
#endif /* MSCHAP_SUPPORT */
|
||||||
|
#if EAP_SUPPORT
|
||||||
|
u_int refuse_eap : 1; /* Don't wanna auth. ourselves with EAP */
|
||||||
|
#endif /* EAP_SUPPORT */
|
||||||
|
u_int usehostname : 1; /* Use hostname for our_name */
|
||||||
|
u_int usepeerdns : 1; /* Ask peer for DNS adds */
|
||||||
|
|
||||||
|
u_short idle_time_limit; /* Shut down link if idle for this long */
|
||||||
|
int maxconnect; /* Maximum connect time (seconds) */
|
||||||
|
|
||||||
|
char user [MAXNAMELEN + 1]; /* Username for PAP */
|
||||||
|
char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */
|
||||||
|
char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */
|
||||||
|
/* FIXME: re-enable that */
|
||||||
|
/* char remote_name[MAXNAMELEN + 1]; */ /* Peer's name for authentication */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ppp_settings ppp_settings;
|
||||||
|
|
||||||
|
|
||||||
|
/* PPP flow functions
|
||||||
|
*/
|
||||||
|
#if PPPOE_SUPPORT
|
||||||
|
void pppOverEthernetInitFailed(int pd);
|
||||||
|
/* function called by pppoe.c */
|
||||||
|
void ppp_input_over_ethernet(int pd, struct pbuf *pb);
|
||||||
|
#endif /* PPPOE_SUPPORT */
|
||||||
|
|
||||||
|
/* function called by all PPP subsystems to send packets */
|
||||||
|
int ppp_write(int pd, const u_char *s, int n);
|
||||||
|
|
||||||
|
/* functions called by auth.c link_terminated() */
|
||||||
|
void pppLinkDown(int pd);
|
||||||
|
void pppLinkTerminated(int pd);
|
||||||
|
|
||||||
|
/* merge a pbuf chain into one pbuf */
|
||||||
|
struct pbuf * ppp_singlebuf(struct pbuf *p);
|
||||||
|
|
||||||
|
|
||||||
|
/* Functions called by various PPP subsystems to configure
|
||||||
|
* the PPP interface or change the PPP phase.
|
||||||
|
*/
|
||||||
|
void new_phase(int p);
|
||||||
|
|
||||||
|
#if PPPOS_SUPPORT
|
||||||
|
void ppp_set_xaccm(int unit, ext_accm *accm);
|
||||||
|
#endif /* PPPOS_SUPPORT */
|
||||||
|
int ppp_send_config(int unit, int mtu, u_int32_t accm, int pcomp, int accomp);
|
||||||
|
int ppp_recv_config(int unit, int mru, u_int32_t accm, int pcomp, int accomp);
|
||||||
|
|
||||||
|
int sifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr, u_int32_t net_mask);
|
||||||
|
int cifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr);
|
||||||
|
|
||||||
|
int sifup(int u);
|
||||||
|
int sifdown (int u);
|
||||||
|
|
||||||
|
int sifnpmode(int u, int proto, enum NPmode mode);
|
||||||
|
|
||||||
|
void netif_set_mtu(int unit, int mtu);
|
||||||
|
int netif_get_mtu(int mtu);
|
||||||
|
|
||||||
|
int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace);
|
||||||
|
int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway);
|
||||||
|
|
||||||
|
int sifproxyarp (int unit, u_int32_t his_adr);
|
||||||
|
int cifproxyarp (int unit, u_int32_t his_adr);
|
||||||
|
|
||||||
|
int sifvjcomp (int u, int vjcomp, int cidcomp, int maxcid);
|
||||||
|
|
||||||
|
int get_idle_time(int u, struct ppp_idle *ip);
|
||||||
|
|
||||||
|
int get_loop_output(void);
|
||||||
|
|
||||||
|
u_int32_t GetMask (u_int32_t addr);
|
||||||
|
|
||||||
|
|
||||||
|
/* Optional protocol names list, to make our messages a little more informative. */
|
||||||
|
#if PPP_PROTOCOLNAME
|
||||||
|
const char * protocol_name(int proto);
|
||||||
|
#endif /* PPP_PROTOCOLNAME */
|
||||||
|
|
||||||
|
|
||||||
|
/* Optional stats support, to get some statistics on the PPP interface */
|
||||||
|
#if PPP_STATS_SUPPORT
|
||||||
|
void print_link_stats(void); /* Print stats, if available */
|
||||||
|
void reset_link_stats(int u); /* Reset (init) stats when link goes up */
|
||||||
|
void update_link_stats(int u); /* Get stats at link termination */
|
||||||
|
#endif /* PPP_STATS_SUPPORT */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inline versions of get/put char/short/long.
|
||||||
|
* Pointer is advanced; we assume that both arguments
|
||||||
|
* are lvalues and will already be in registers.
|
||||||
|
* cp MUST be u_char *.
|
||||||
|
*/
|
||||||
|
#define GETCHAR(c, cp) { \
|
||||||
|
(c) = *(cp)++; \
|
||||||
|
}
|
||||||
|
#define PUTCHAR(c, cp) { \
|
||||||
|
*(cp)++ = (u_char) (c); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define GETSHORT(s, cp) { \
|
||||||
|
(s) = *(cp)++ << 8; \
|
||||||
|
(s) |= *(cp)++; \
|
||||||
|
}
|
||||||
|
#define PUTSHORT(s, cp) { \
|
||||||
|
*(cp)++ = (u_char) ((s) >> 8); \
|
||||||
|
*(cp)++ = (u_char) (s); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GETLONG(l, cp) { \
|
||||||
|
(l) = *(cp)++ << 8; \
|
||||||
|
(l) |= *(cp)++; (l) <<= 8; \
|
||||||
|
(l) |= *(cp)++; (l) <<= 8; \
|
||||||
|
(l) |= *(cp)++; \
|
||||||
|
}
|
||||||
|
#define PUTLONG(l, cp) { \
|
||||||
|
*(cp)++ = (u_char) ((l) >> 24); \
|
||||||
|
*(cp)++ = (u_char) ((l) >> 16); \
|
||||||
|
*(cp)++ = (u_char) ((l) >> 8); \
|
||||||
|
*(cp)++ = (u_char) (l); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define INCPTR(n, cp) ((cp) += (n))
|
||||||
|
#define DECPTR(n, cp) ((cp) -= (n))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
||||||
|
*/
|
||||||
|
#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
|
||||||
|
#define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0)
|
||||||
|
#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
|
||||||
|
|
||||||
|
#define BZERO(s, n) memset(s, 0, n)
|
||||||
|
#define BCMP(s1, s2, l) memcmp(s1, s2, l)
|
||||||
|
|
||||||
|
#define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MAKEHEADER - Add Header fields to a packet.
|
||||||
|
*/
|
||||||
|
#define MAKEHEADER(p, t) { \
|
||||||
|
PUTCHAR(PPP_ALLSTATIONS, p); \
|
||||||
|
PUTCHAR(PPP_UI, p); \
|
||||||
|
PUTSHORT(t, p); }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exit status values.
|
||||||
|
*/
|
||||||
|
#define EXIT_OK 0
|
||||||
|
#define EXIT_FATAL_ERROR 1
|
||||||
|
#define EXIT_OPTION_ERROR 2
|
||||||
|
#define EXIT_NOT_ROOT 3
|
||||||
|
#define EXIT_NO_KERNEL_SUPPORT 4
|
||||||
|
#define EXIT_USER_REQUEST 5
|
||||||
|
#define EXIT_LOCK_FAILED 6
|
||||||
|
#define EXIT_OPEN_FAILED 7
|
||||||
|
#define EXIT_CONNECT_FAILED 8
|
||||||
|
#define EXIT_PTYCMD_FAILED 9
|
||||||
|
#define EXIT_NEGOTIATION_FAILED 10
|
||||||
|
#define EXIT_PEER_AUTH_FAILED 11
|
||||||
|
#define EXIT_IDLE_TIMEOUT 12
|
||||||
|
#define EXIT_CONNECT_TIME 13
|
||||||
|
#define EXIT_CALLBACK 14
|
||||||
|
#define EXIT_PEER_DEAD 15
|
||||||
|
#define EXIT_HANGUP 16
|
||||||
|
#define EXIT_LOOPBACK 17
|
||||||
|
#define EXIT_INIT_FAILED 18
|
||||||
|
#define EXIT_AUTH_TOPEER_FAILED 19
|
||||||
|
#ifdef MAXOCTETS
|
||||||
|
#define EXIT_TRAFFIC_LIMIT 20
|
||||||
|
#endif
|
||||||
|
#define EXIT_CNID_AUTH_FAILED 21
|
||||||
|
|
||||||
|
/* Procedures exported from auth.c */
|
||||||
|
void link_required __P((int)); /* we are starting to use the link */
|
||||||
|
void link_terminated __P((int)); /* we are finished with the link */
|
||||||
|
void link_down __P((int)); /* the LCP layer has left the Opened state */
|
||||||
|
void upper_layers_down __P((int));/* take all NCPs down */
|
||||||
|
void link_established __P((int)); /* the link is up; authenticate now */
|
||||||
|
void start_networks __P((int)); /* start all the network control protos */
|
||||||
|
void continue_networks __P((int)); /* start network [ip, etc] control protos */
|
||||||
|
|
||||||
|
void auth_peer_fail __P((int, int));
|
||||||
|
/* peer failed to authenticate itself */
|
||||||
|
void auth_peer_success __P((int, int, int, char *, int));
|
||||||
|
/* peer successfully authenticated itself */
|
||||||
|
void auth_withpeer_fail __P((int, int));
|
||||||
|
/* we failed to authenticate ourselves */
|
||||||
|
void auth_withpeer_success __P((int, int, int));
|
||||||
|
/* we successfully authenticated ourselves */
|
||||||
|
void np_up __P((int, int)); /* a network protocol has come up */
|
||||||
|
void np_down __P((int, int)); /* a network protocol has gone down */
|
||||||
|
void np_finished __P((int, int)); /* a network protocol no longer needs link */
|
||||||
|
void auth_reset __P((int)); /* check what secrets we have */
|
||||||
|
int get_secret __P((int, char *, char *, char *, int *, int));
|
||||||
|
/* get "secret" for chap */
|
||||||
|
|
||||||
|
/* Procedures exported from ipcp.c */
|
||||||
|
/* int parse_dotted_ip __P((char *, u_int32_t *)); */
|
||||||
|
|
||||||
|
/* Procedures exported from demand.c */
|
||||||
|
#if DEMAND_SUPPORT
|
||||||
|
void demand_conf __P((void)); /* config interface(s) for demand-dial */
|
||||||
|
void demand_block __P((void)); /* set all NPs to queue up packets */
|
||||||
|
void demand_unblock __P((void)); /* set all NPs to pass packets */
|
||||||
|
void demand_discard __P((void)); /* set all NPs to discard packets */
|
||||||
|
void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
|
||||||
|
int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
|
||||||
|
int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
|
||||||
|
#endif /* DEMAND_SUPPORT */
|
||||||
|
|
||||||
|
/* Procedures exported from multilink.c */
|
||||||
|
#ifdef HAVE_MULTILINK
|
||||||
|
void mp_check_options __P((void)); /* Check multilink-related options */
|
||||||
|
int mp_join_bundle __P((void)); /* join our link to an appropriate bundle */
|
||||||
|
void mp_exit_bundle __P((void)); /* have disconnected our link from bundle */
|
||||||
|
void mp_bundle_terminated __P((void));
|
||||||
|
char *epdisc_to_str __P((struct epdisc *)); /* string from endpoint discrim. */
|
||||||
|
int str_to_epdisc __P((struct epdisc *, char *)); /* endpt disc. from str */
|
||||||
|
#else
|
||||||
|
#define mp_bundle_terminated() /* nothing */
|
||||||
|
#define mp_exit_bundle() /* nothing */
|
||||||
|
#define doing_multilink 0
|
||||||
|
#define multilink_master 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Procedures exported from utils.c. */
|
||||||
|
void print_string __P((char *, int, void (*) (void *, char *, ...),
|
||||||
|
void *)); /* Format a string for output */
|
||||||
|
int slprintf __P((char *, int, char *, ...)); /* sprintf++ */
|
||||||
|
int vslprintf __P((char *, int, char *, va_list)); /* vsprintf++ */
|
||||||
|
size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */
|
||||||
|
size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */
|
||||||
|
void dbglog __P((char *, ...)); /* log a debug message */
|
||||||
|
void info __P((char *, ...)); /* log an informational message */
|
||||||
|
void notice __P((char *, ...)); /* log a notice-level message */
|
||||||
|
void warn __P((char *, ...)); /* log a warning message */
|
||||||
|
void error __P((char *, ...)); /* log an error message */
|
||||||
|
void fatal __P((char *, ...)); /* log an error message and die(1) */
|
||||||
|
void init_pr_log __P((const char *, int)); /* initialize for using pr_log */
|
||||||
|
void pr_log __P((void *, char *, ...)); /* printer fn, output to syslog */
|
||||||
|
void end_pr_log __P((void)); /* finish up after using pr_log */
|
||||||
|
#if PRINTPKT_SUPPORT
|
||||||
|
void dump_packet __P((const char *, u_char *, int));
|
||||||
|
/* dump packet to debug log if interesting */
|
||||||
|
#endif /* PRINTPKT_SUPPORT */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* PPP_IMP_H_ */
|
||||||
|
|
||||||
|
#endif /* PPP_SUPPORT */
|
@ -80,7 +80,7 @@
|
|||||||
#include "lwip/memp.h"
|
#include "lwip/memp.h"
|
||||||
#include "lwip/stats.h"
|
#include "lwip/stats.h"
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "netif/ppp_oe.h"
|
#include "netif/ppp_oe.h"
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not necessary */
|
#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not necessary */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "pppcrypt.h"
|
#include "pppcrypt.h"
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif /* UNUSED */
|
#endif /* UNUSED */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "upap.h"
|
#include "upap.h"
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
#include <ctype.h> /* isdigit() */
|
#include <ctype.h> /* isdigit() */
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp_impl.h"
|
||||||
|
|
||||||
#include "fsm.h"
|
#include "fsm.h"
|
||||||
#include "lcp.h"
|
#include "lcp.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user