33 #ifndef LWIP_HDR_PPP_IMPL_H
34 #define LWIP_HDR_PPP_IMPL_H
40 #ifdef PPP_INCLUDE_SETTINGS_HEADER
41 #include "ppp_settings.h"
67 #define PPP_CTRL_PBUF_TYPE PBUF_RAM
68 #define PPP_CTRL_PBUF_MAX_SIZE 512
70 #define PPP_CTRL_PBUF_TYPE PBUF_POOL
71 #define PPP_CTRL_PBUF_MAX_SIZE PBUF_POOL_BUFSIZE
77 #define PPP_ADDRESS(p) (((u_char *)(p))[0])
78 #define PPP_CONTROL(p) (((u_char *)(p))[1])
79 #define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
84 #define PPP_ALLSTATIONS 0xff
87 #define PPP_ESCAPE 0x7d
88 #define PPP_TRANS 0x20
99 #define PPP_VJC_COMP 0x2d
100 #define PPP_VJC_UNCOMP 0x2f
103 #define PPP_IPV6 0x57
106 #define PPP_COMP 0xfd
108 #define PPP_IPCP 0x8021
110 #define PPP_ATCP 0x8029
111 #define PPP_IPXCP 0x802b
114 #define PPP_IPV6CP 0x8057
117 #define PPP_CCP 0x80fd
120 #define PPP_ECP 0x8053
122 #define PPP_LCP 0xc021
124 #define PPP_PAP 0xc023
127 #define PPP_LQR 0xc025
130 #define PPP_CHAP 0xc223
133 #define PPP_CBCP 0xc029
136 #define PPP_EAP 0xc227
143 struct link_callbacks {
145 void (*connect) (ppp_pcb *pcb,
void *ctx);
148 void (*listen) (ppp_pcb *pcb,
void *ctx);
151 void (*disconnect) (ppp_pcb *pcb,
void *ctx);
155 err_t (*write)(ppp_pcb *pcb,
void *ctx,
struct pbuf *p);
157 err_t (*netif_output)(ppp_pcb *pcb,
void *ctx,
struct pbuf *p, u_short protocol);
159 void (*send_config)(ppp_pcb *pcb,
void *ctx,
u32_t accm,
int pcomp,
int accomp);
161 void (*recv_config)(ppp_pcb *pcb,
void *ctx,
u32_t accm,
int pcomp,
int accomp);
177 #if PPP_STATS_SUPPORT
179 unsigned int ppp_ibytes;
180 unsigned int ppp_ipackets;
181 unsigned int ppp_ierrors;
182 unsigned int ppp_obytes;
183 unsigned int ppp_opackets;
184 unsigned int ppp_oerrors;
189 unsigned int vjs_packets;
190 unsigned int vjs_compressed;
191 unsigned int vjs_searches;
192 unsigned int vjs_misses;
193 unsigned int vjs_uncompressedin;
194 unsigned int vjs_compressedin;
195 unsigned int vjs_errorin;
196 unsigned int vjs_tossed;
209 unsigned int unc_bytes;
210 unsigned int unc_packets;
211 unsigned int comp_bytes;
212 unsigned int comp_packets;
213 unsigned int inc_bytes;
214 unsigned int inc_packets;
218 struct ppp_comp_stats {
226 #if PPP_IDLETIMELIMIT
243 #define EPD_PHONENUM 5
248 #ifdef HAVE_MULTILINK
249 extern u8_t multilink;
250 extern u8_t doing_multilink;
251 extern u8_t multilink_master;
252 extern u8_t bundle_eof;
253 extern u8_t bundle_terminating;
257 extern unsigned int maxoctets;
258 extern int maxoctets_dir;
263 extern int maxoctets_timeout;
264 #define PPP_OCTETS_DIRECTION_SUM 0
265 #define PPP_OCTETS_DIRECTION_IN 1
266 #define PPP_OCTETS_DIRECTION_OUT 2
267 #define PPP_OCTETS_DIRECTION_MAXOVERAL 3
269 #define PPP_OCTETS_DIRECTION_MAXSESSION 4
275 #define PPP_DATAINPUT 0
284 void (*init) (ppp_pcb *pcb);
286 void (*input) (ppp_pcb *pcb, u_char *pkt,
int len);
288 void (*protrej) (ppp_pcb *pcb);
290 void (*lowerup) (ppp_pcb *pcb);
292 void (*lowerdown) (ppp_pcb *pcb);
294 void (*open) (ppp_pcb *pcb);
296 void (*close) (ppp_pcb *pcb,
const char *reason);
299 int (*printpkt) (
const u_char *pkt,
int len,
300 void (*printer) (
void *,
const char *, ...),
305 void (*datainput) (ppp_pcb *pcb, u_char *pkt,
int len);
309 const char *data_name;
314 void (*check_options) (void);
318 int (*demand_conf) (
int unit);
320 int (*active_pkt) (u_char *pkt,
int len);
325 extern const struct protent*
const protocols[];
330 #define PAP_WITHPEER 0x1
334 #define CHAP_WITHPEER 0x4
335 #define CHAP_PEER 0x8
338 #define EAP_WITHPEER 0x10
339 #define EAP_PEER 0x20
344 #define CHAP_MD5_WITHPEER 0x40
345 #define CHAP_MD5_PEER 0x80
347 #define CHAP_MS_SHIFT 8
348 #define CHAP_MS_WITHPEER 0x100
349 #define CHAP_MS_PEER 0x200
350 #define CHAP_MS2_WITHPEER 0x400
351 #define CHAP_MS2_PEER 0x800
359 #define CHAP_MDTYPE_SUPPORTED (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
361 #define CHAP_MDTYPE_SUPPORTED (MDTYPE_MD5)
365 #define CHAP_MDTYPE_SUPPORTED (MDTYPE_NONE)
368 #if PPP_STATS_SUPPORT
373 unsigned int bytes_in;
374 unsigned int bytes_out;
375 unsigned int pkts_in;
376 unsigned int pkts_out;
398 ppp_pcb *ppp_new(
struct netif *pppif,
const struct link_callbacks *callbacks,
void *link_ctx_cb,
399 ppp_link_status_cb_fn link_status_cb,
void *ctx_cb);
402 void ppp_start(ppp_pcb *pcb);
405 void ppp_link_failed(ppp_pcb *pcb);
408 void ppp_link_end(ppp_pcb *pcb);
411 void ppp_input(ppp_pcb *pcb,
struct pbuf *pb);
419 err_t ppp_write(ppp_pcb *pcb,
struct pbuf *p);
422 void ppp_link_terminated(ppp_pcb *pcb);
424 void new_phase(ppp_pcb *pcb,
int p);
426 int ppp_send_config(ppp_pcb *pcb,
int mtu,
u32_t accm,
int pcomp,
int accomp);
427 int ppp_recv_config(ppp_pcb *pcb,
int mru,
u32_t accm,
int pcomp,
int accomp);
430 int sifaddr(ppp_pcb *pcb,
u32_t our_adr,
u32_t his_adr,
u32_t netmask);
431 int cifaddr(ppp_pcb *pcb,
u32_t our_adr,
u32_t his_adr);
433 int sifproxyarp(ppp_pcb *pcb,
u32_t his_adr);
434 int cifproxyarp(ppp_pcb *pcb,
u32_t his_adr);
441 int sifvjcomp(ppp_pcb *pcb,
int vjcomp,
int cidcomp,
int maxcid);
443 int sifup(ppp_pcb *pcb);
444 int sifdown (ppp_pcb *pcb);
449 int sif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
450 int cif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64);
451 int sif6up(ppp_pcb *pcb);
452 int sif6down (ppp_pcb *pcb);
456 int sifnpmode(ppp_pcb *pcb,
int proto,
enum NPmode mode);
459 void netif_set_mtu(ppp_pcb *pcb,
int mtu);
460 int netif_get_mtu(ppp_pcb *pcb);
464 int ccp_test(ppp_pcb *pcb, u_char *opt_ptr,
int opt_len,
int for_transmit);
466 void ccp_set(ppp_pcb *pcb,
u8_t isopen,
u8_t isup,
u8_t receive_method,
u8_t transmit_method);
467 void ccp_reset_comp(ppp_pcb *pcb);
468 void ccp_reset_decomp(ppp_pcb *pcb);
470 int ccp_fatal_error(ppp_pcb *pcb);
474 #if PPP_IDLETIMELIMIT
475 int get_idle_time(ppp_pcb *pcb,
struct ppp_idle *ip);
479 int get_loop_output(
void);
484 const char * protocol_name(
int proto);
488 #if PPP_STATS_SUPPORT
489 void print_link_stats(
void);
490 void reset_link_stats(
int u);
491 void update_link_stats(
int u);
502 #define GETCHAR(c, cp) { \
505 #define PUTCHAR(c, cp) { \
506 *(cp)++ = (u_char) (c); \
508 #define GETSHORT(s, cp) { \
509 (s) = *(cp)++ << 8; \
512 #define PUTSHORT(s, cp) { \
513 *(cp)++ = (u_char) ((s) >> 8); \
514 *(cp)++ = (u_char) (s); \
516 #define GETLONG(l, cp) { \
517 (l) = *(cp)++ << 8; \
518 (l) |= *(cp)++; (l) <<= 8; \
519 (l) |= *(cp)++; (l) <<= 8; \
522 #define PUTLONG(l, cp) { \
523 *(cp)++ = (u_char) ((l) >> 24); \
524 *(cp)++ = (u_char) ((l) >> 16); \
525 *(cp)++ = (u_char) ((l) >> 8); \
526 *(cp)++ = (u_char) (l); \
529 #define INCPTR(n, cp) ((cp) += (n))
530 #define DECPTR(n, cp) ((cp) -= (n))
535 #define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0)
536 #define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0)
537 #define UNTIMEOUT(f, a) sys_untimeout((f), (a))
539 #define BZERO(s, n) memset(s, 0, n)
540 #define BCMP(s1, s2, l) memcmp(s1, s2, l)
542 #define PRINTMSG(m, l) { ppp_info("Remote message: %0.*v", l, m); }
547 #define MAKEHEADER(p, t) { \
548 PUTCHAR(PPP_ALLSTATIONS, p); \
549 PUTCHAR(PPP_UI, p); \
553 void link_required(ppp_pcb *pcb);
554 void link_terminated(ppp_pcb *pcb);
555 void link_down(ppp_pcb *pcb);
556 void upper_layers_down(ppp_pcb *pcb);
557 void link_established(ppp_pcb *pcb);
558 void start_networks(ppp_pcb *pcb);
559 void continue_networks(ppp_pcb *pcb);
562 int auth_check_passwd(ppp_pcb *pcb,
char *auser,
int userlen,
char *apasswd,
int passwdlen,
const char **msg,
int *msglen);
564 void auth_peer_fail(ppp_pcb *pcb,
int protocol);
566 void auth_peer_success(ppp_pcb *pcb,
int protocol,
int prot_flavor,
const char *name,
int namelen);
569 void auth_withpeer_fail(ppp_pcb *pcb,
int protocol);
571 void auth_withpeer_success(ppp_pcb *pcb,
int protocol,
int prot_flavor);
574 void np_up(ppp_pcb *pcb,
int proto);
575 void np_down(ppp_pcb *pcb,
int proto);
576 void np_finished(ppp_pcb *pcb,
int proto);
578 int get_secret(ppp_pcb *pcb,
const char *client,
const char *server,
char *secret,
int *secret_len,
int am_server);
587 void demand_conf (
void);
588 void demand_block (
void);
589 void demand_unblock (
void);
590 void demand_discard (
void);
591 void demand_rexmit (
int,
u32_t);
592 int loop_chars (
unsigned char *,
int);
593 int loop_frame (
unsigned char *,
int);
597 #ifdef HAVE_MULTILINK
598 void mp_check_options (
void);
599 int mp_join_bundle (
void);
600 void mp_exit_bundle (
void);
601 void mp_bundle_terminated (
void);
602 char *epdisc_to_str (
struct epdisc *);
603 int str_to_epdisc (
struct epdisc *,
char *);
605 #define mp_bundle_terminated()
606 #define mp_exit_bundle()
607 #define doing_multilink 0
608 #define multilink_master 0
612 void ppp_print_string(
const u_char *p,
int len,
void (*printer) (
void *,
const char *, ...),
void *arg);
613 int ppp_slprintf(
char *buf,
int buflen,
const char *fmt, ...);
614 int ppp_vslprintf(
char *buf,
int buflen,
const char *fmt, va_list args);
615 size_t ppp_strlcpy(
char *dest,
const char *src,
size_t len);
616 size_t ppp_strlcat(
char *dest,
const char *src,
size_t len);
617 void ppp_dbglog(
const char *fmt, ...);
618 void ppp_info(
const char *fmt, ...);
619 void ppp_notice(
const char *fmt, ...);
620 void ppp_warn(
const char *fmt, ...);
621 void ppp_error(
const char *fmt, ...);
622 void ppp_fatal(
const char *fmt, ...);
624 void ppp_dump_packet(ppp_pcb *pcb,
const char *tag,
unsigned char *p,
int len);
#define free(ptr)
Definition: Memory_Manager.h:266
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
s8_t err_t
Definition: err.h:96