44#ifdef PPP_INCLUDE_SETTINGS_HEADER
45#include "ppp_settings.h"
64#define LITTLE_ENDIAN 1234
68#define BIG_ENDIAN 4321
72#define BYTE_ORDER LITTLE_ENDIAN
75#if BYTE_ORDER == BIG_ENDIAN
76#define ppp_htons(x) ((u16_t)(x))
77#define ppp_ntohs(x) ((u16_t)(x))
78#define ppp_htonl(x) ((u32_t)(x))
79#define ppp_ntohl(x) ((u32_t)(x))
80#define PP_HTONS(x) ((u16_t)(x))
81#define PP_NTOHS(x) ((u16_t)(x))
82#define PP_HTONL(x) ((u32_t)(x))
83#define PP_NTOHL(x) ((u32_t)(x))
86u16_t ppp_htons(u16_t x);
88#define ppp_ntohs(x) ppp_htons(x)
91u32_t ppp_htonl(u32_t x);
93#define ppp_ntohl(x) ppp_htonl(x)
98#define PP_HTONS(x) ((u16_t)((((x) & (u16_t)0x00ffU) << 8) | (((x) & (u16_t)0xff00U) >> 8)))
99#define PP_NTOHS(x) PP_HTONS(x)
100#define PP_HTONL(x) ((((x) & (u32_t)0x000000ffUL) << 24) | \
101 (((x) & (u32_t)0x0000ff00UL) << 8) | \
102 (((x) & (u32_t)0x00ff0000UL) >> 8) | \
103 (((x) & (u32_t)0xff000000UL) >> 24))
104#define PP_NTOHL(x) PP_HTONL(x)
114#define PPP_CTRL_PBUF_TYPE PBUF_RAM
115#define PPP_CTRL_PBUF_MAX_SIZE 512
117#define PPP_CTRL_PBUF_TYPE PBUF_POOL
118#define PPP_CTRL_PBUF_MAX_SIZE PBUF_POOL_BUFSIZE
124#define PPP_ADDRESS(p) (((u_char *)(p))[0])
125#define PPP_CONTROL(p) (((u_char *)(p))[1])
126#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
131#define PPP_ALLSTATIONS 0xff
134#define PPP_ESCAPE 0x7d
135#define PPP_TRANS 0x20
146#define PPP_VJC_COMP 0x2d
147#define PPP_VJC_UNCOMP 0x2f
155#define PPP_IPCP 0x8021
157#define PPP_ATCP 0x8029
158#define PPP_IPXCP 0x802b
161#define PPP_IPV6CP 0x8057
164#define PPP_CCP 0x80fd
167#define PPP_ECP 0x8053
169#define PPP_LCP 0xc021
171#define PPP_PAP 0xc023
174#define PPP_LQR 0xc025
177#define PPP_CHAP 0xc223
180#define PPP_CBCP 0xc029
183#define PPP_EAP 0xc227
190struct link_callbacks {
192 void (*connect) (ppp_pcb *pcb,
void *ctx);
195 void (*listen) (ppp_pcb *pcb,
void *ctx);
198 void (*disconnect) (ppp_pcb *pcb,
void *ctx);
200 err_t (*free) (ppp_pcb *pcb,
void *ctx);
202 err_t (*write)(ppp_pcb *pcb,
void *ctx,
struct pbuf *p);
204 err_t (*netif_output)(ppp_pcb *pcb,
void *ctx,
struct pbuf *p, u_short protocol);
206 void (*send_config)(ppp_pcb *pcb,
void *ctx, u32_t accm,
int pcomp,
int accomp);
208 void (*recv_config)(ppp_pcb *pcb,
void *ctx, u32_t accm,
int pcomp,
int accomp);
226 unsigned int ppp_ibytes;
227 unsigned int ppp_ipackets;
228 unsigned int ppp_ierrors;
229 unsigned int ppp_obytes;
230 unsigned int ppp_opackets;
231 unsigned int ppp_oerrors;
236 unsigned int vjs_packets;
237 unsigned int vjs_compressed;
238 unsigned int vjs_searches;
239 unsigned int vjs_misses;
240 unsigned int vjs_uncompressedin;
241 unsigned int vjs_compressedin;
242 unsigned int vjs_errorin;
243 unsigned int vjs_tossed;
256 unsigned int unc_bytes;
257 unsigned int unc_packets;
258 unsigned int comp_bytes;
259 unsigned int comp_packets;
260 unsigned int inc_bytes;
261 unsigned int inc_packets;
265struct ppp_comp_stats {
290#define EPD_PHONENUM 5
296extern u8_t multilink;
297extern u8_t doing_multilink;
298extern u8_t multilink_master;
299extern u8_t bundle_eof;
300extern u8_t bundle_terminating;
304extern unsigned int maxoctets;
305extern int maxoctets_dir;
310extern int maxoctets_timeout;
311#define PPP_OCTETS_DIRECTION_SUM 0
312#define PPP_OCTETS_DIRECTION_IN 1
313#define PPP_OCTETS_DIRECTION_OUT 2
314#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
316#define PPP_OCTETS_DIRECTION_MAXSESSION 4
322#define PPP_DATAINPUT 0
331 void (*init) (ppp_pcb *pcb);
333 void (*input) (ppp_pcb *pcb, u_char *pkt,
int len);
335 void (*protrej) (ppp_pcb *pcb);
337 void (*lowerup) (ppp_pcb *pcb);
339 void (*lowerdown) (ppp_pcb *pcb);
341 void (*open) (ppp_pcb *pcb);
343 void (*close) (ppp_pcb *pcb,
const char *reason);
346 int (*printpkt) (
const u_char *pkt,
int len,
347 void (*printer) (
void *,
const char *, ...),
352 void (*datainput) (ppp_pcb *pcb, u_char *pkt,
int len);
356 const char *data_name;
361 void (*check_options) (void);
365 int (*demand_conf) (
int unit);
367 int (*active_pkt) (u_char *pkt,
int len);
372extern const struct protent*
const protocols[];
377#define PAP_WITHPEER 0x1
381#define CHAP_WITHPEER 0x4
385#define EAP_WITHPEER 0x10
391#define CHAP_MD5_WITHPEER 0x40
392#define CHAP_MD5_PEER 0x80
394#define CHAP_MS_SHIFT 8
395#define CHAP_MS_WITHPEER 0x100
396#define CHAP_MS_PEER 0x200
397#define CHAP_MS2_WITHPEER 0x400
398#define CHAP_MS2_PEER 0x800
406#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
408#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MD5)
412#define CHAP_MDTYPE_SUPPORTED (MDTYPE_NONE)
420 unsigned int bytes_in;
421 unsigned int bytes_out;
422 unsigned int pkts_in;
423 unsigned int pkts_out;
445ppp_pcb *ppp_new(
struct netif *pppif,
const struct link_callbacks *callbacks,
void *link_ctx_cb,
446 ppp_link_status_cb_fn link_status_cb,
void *ctx_cb);
449void ppp_start(ppp_pcb *pcb);
452void ppp_link_failed(ppp_pcb *pcb);
455void ppp_link_end(ppp_pcb *pcb);
458void ppp_input(ppp_pcb *pcb,
struct pbuf *pb);
466err_t ppp_write(ppp_pcb *pcb,
struct pbuf *p);
469void ppp_link_terminated(ppp_pcb *pcb);
471void new_phase(ppp_pcb *pcb,
int p);
473int ppp_send_config(ppp_pcb *pcb,
int mtu, u32_t accm,
int pcomp,
int accomp);
474int ppp_recv_config(ppp_pcb *pcb,
int mru, u32_t accm,
int pcomp,
int accomp);
477int sifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr, u32_t netmask);
478int cifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr);
480int sifproxyarp(ppp_pcb *pcb, u32_t his_adr);
481int cifproxyarp(ppp_pcb *pcb, u32_t his_adr);
484int sdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2);
485int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2);
488int sifvjcomp(ppp_pcb *pcb,
int vjcomp,
int cidcomp,
int maxcid);
490int sifup(ppp_pcb *pcb);
491int sifdown (ppp_pcb *pcb);
492u32_t get_mask(u32_t addr);
496int sif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
497int cif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
498int sif6up(ppp_pcb *pcb);
499int sif6down (ppp_pcb *pcb);
503int sifnpmode(ppp_pcb *pcb,
int proto,
enum NPmode mode);
506void netif_set_mtu(ppp_pcb *pcb,
int mtu);
507int netif_get_mtu(ppp_pcb *pcb);
511int ccp_test(ppp_pcb *pcb, u_char *opt_ptr,
int opt_len,
int for_transmit);
513void ccp_set(ppp_pcb *pcb, u8_t isopen, u8_t isup, u8_t receive_method, u8_t transmit_method);
514void ccp_reset_comp(ppp_pcb *pcb);
515void ccp_reset_decomp(ppp_pcb *pcb);
517int ccp_fatal_error(ppp_pcb *pcb);
522int get_idle_time(ppp_pcb *pcb,
struct ppp_idle *ip);
526int get_loop_output(
void);
531const char * protocol_name(
int proto);
536void print_link_stats(
void);
537void reset_link_stats(
int u);
538void update_link_stats(
int u);
549#define GETCHAR(c, cp) { \
552#define PUTCHAR(c, cp) { \
553 *(cp)++ = (u_char) (c); \
555#define GETSHORT(s, cp) { \
556 (s) = *(cp)++ << 8; \
559#define PUTSHORT(s, cp) { \
560 *(cp)++ = (u_char) ((s) >> 8); \
561 *(cp)++ = (u_char) (s); \
563#define GETLONG(l, cp) { \
564 (l) = *(cp)++ << 8; \
565 (l) |= *(cp)++; (l) <<= 8; \
566 (l) |= *(cp)++; (l) <<= 8; \
569#define PUTLONG(l, cp) { \
570 *(cp)++ = (u_char) ((l) >> 24); \
571 *(cp)++ = (u_char) ((l) >> 16); \
572 *(cp)++ = (u_char) ((l) >> 8); \
573 *(cp)++ = (u_char) (l); \
576#define INCPTR(n, cp) ((cp) += (n))
577#define DECPTR(n, cp) ((cp) -= (n))
579#define BZERO(s, n) memset(s, 0, n)
580#define BCMP(s1, s2, l) memcmp(s1, s2, l)
582#define PRINTMSG(m, l) { ppp_info("Remote message: %0.*v", l, m); }
587#define MAKEHEADER(p, t) { \
588 PUTCHAR(PPP_ALLSTATIONS, p); \
589 PUTCHAR(PPP_UI, p); \
593void link_required(ppp_pcb *pcb);
594void link_terminated(ppp_pcb *pcb);
595void link_down(ppp_pcb *pcb);
596void upper_layers_down(ppp_pcb *pcb);
597void link_established(ppp_pcb *pcb);
598void start_networks(ppp_pcb *pcb);
599void continue_networks(ppp_pcb *pcb);
602int auth_check_passwd(ppp_pcb *pcb,
char *auser,
int userlen,
char *apasswd,
int passwdlen,
const char **msg,
int *msglen);
604void auth_peer_fail(ppp_pcb *pcb,
int protocol);
606void auth_peer_success(ppp_pcb *pcb,
int protocol,
int prot_flavor,
const char *name,
int namelen);
609void auth_withpeer_fail(ppp_pcb *pcb,
int protocol);
611void auth_withpeer_success(ppp_pcb *pcb,
int protocol,
int prot_flavor);
614void np_up(ppp_pcb *pcb,
int proto);
615void np_down(ppp_pcb *pcb,
int proto);
616void np_finished(ppp_pcb *pcb,
int proto);
618int get_secret(ppp_pcb *pcb,
const char *client,
const char *server,
char *secret,
int *secret_len,
int am_server);
627void demand_conf (
void);
628void demand_block (
void);
629void demand_unblock (
void);
630void demand_discard (
void);
631void demand_rexmit (
int, u32_t);
632int loop_chars (
unsigned char *,
int);
633int loop_frame (
unsigned char *,
int);
638void mp_check_options (
void);
639int mp_join_bundle (
void);
640void mp_exit_bundle (
void);
641void mp_bundle_terminated (
void);
642char *epdisc_to_str (
struct epdisc *);
643int str_to_epdisc (
struct epdisc *,
char *);
645#define mp_bundle_terminated()
646#define mp_exit_bundle()
647#define doing_multilink 0
648#define multilink_master 0
654void ppp_print_string(
const u_char *p,
int len,
void (*printer) (
void *,
const char *, ...),
void *arg);
655int ppp_slprintf(
char *buf,
int buflen,
const char *fmt, ...);
656int ppp_vslprintf(
char *buf,
int buflen,
const char *fmt, va_list args);
657size_t ppp_strlcpy(
char *dest,
const char *src,
size_t len);
658size_t ppp_strlcat(
char *dest,
const char *src,
size_t len);
659void ppp_dbglog(
const char *fmt, ...);
660void ppp_info(
const char *fmt, ...);
661void ppp_notice(
const char *fmt, ...);
662void ppp_warn(
const char *fmt, ...);
663void ppp_error(
const char *fmt, ...);
664void ppp_fatal(
const char *fmt, ...);
666void ppp_dump_packet(ppp_pcb *pcb,
const char *tag,
unsigned char *p,
int len);
672#define ppp_print_string(...)
673#define ppp_slprintf(...)
674#define ppp_vslprintf(...)
675#define ppp_strlcpy(...)
676#define ppp_strlcat(...)
677#define ppp_dbglog(...)
679#define ppp_notice(...)
681#define ppp_error(...)
682#define ppp_fatal(...)