139 #if PPP_STATS_SUPPORT 140 static struct timeval start_time;
141 static struct pppd_stats old_link_stats;
142 struct pppd_stats link_stats;
143 unsigned link_connect_time;
144 int link_stats_valid;
152 const struct protent*
const protocols[] = {
185 static void ppp_do_connect(
void *arg);
188 static err_t ppp_netif_output_ip4(
struct netif *
netif,
struct pbuf *pb,
const ip4_addr_t *ipaddr);
191 static err_t ppp_netif_output_ip6(
struct netif *
netif,
struct pbuf *pb,
const ip6_addr_t *ipaddr);
198 void ppp_set_auth(ppp_pcb *pcb,
u8_t authtype,
const char *user,
const char *passwd) {
201 pcb->settings.refuse_pap = !(authtype & PPPAUTHTYPE_PAP);
204 pcb->settings.refuse_chap = !(authtype & PPPAUTHTYPE_CHAP);
206 pcb->settings.refuse_mschap = !(authtype & PPPAUTHTYPE_MSCHAP);
207 pcb->settings.refuse_mschap_v2 = !(authtype & PPPAUTHTYPE_MSCHAP_V2);
211 pcb->settings.refuse_eap = !(authtype & PPPAUTHTYPE_EAP);
213 pcb->settings.user = user;
214 pcb->settings.passwd = passwd;
224 void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb) {
225 pcb->notify_phase_cb = notify_phase_cb;
226 notify_phase_cb(pcb, pcb->phase, pcb->ctx_cb);
241 err_t ppp_connect(ppp_pcb *pcb,
u16_t holdoff) {
242 if (pcb->phase != PPP_PHASE_DEAD) {
246 PPPDEBUG(LOG_DEBUG, (
"ppp_connect[%d]: holdoff=%d\n", pcb->netif->num, holdoff));
249 return pcb->link_cb->connect(pcb, pcb->link_ctx_cb);
252 new_phase(pcb, PPP_PHASE_HOLDOFF);
269 err_t ppp_listen(ppp_pcb *pcb,
struct ppp_addrs *addrs) {
270 if (pcb->phase != PPP_PHASE_DEAD) {
274 PPPDEBUG(LOG_DEBUG, (
"ppp_listen[%d]\n", pcb->netif->num));
276 if (pcb->link_cb->listen) {
277 return pcb->link_cb->listen(pcb, pcb->link_ctx_cb, addrs);
295 ppp_close(ppp_pcb *pcb,
u8_t nocarrier)
297 pcb->err_code = PPPERR_USER;
300 if (pcb->phase == PPP_PHASE_HOLDOFF) {
302 new_phase(pcb, PPP_PHASE_DEAD);
306 if (pcb->phase == PPP_PHASE_DEAD) {
307 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
318 if (nocarrier && pcb->phase == PPP_PHASE_RUNNING) {
319 PPPDEBUG(LOG_DEBUG, (
"ppp_close[%d]: carrier lost -> lcp_lowerdown\n", pcb->netif->num));
322 link_terminated(pcb);
327 PPPDEBUG(LOG_DEBUG, (
"ppp_close[%d]: kill_link -> lcp_close\n", pcb->netif->num));
329 lcp_close(pcb,
"User request");
343 err_t ppp_free(ppp_pcb *pcb) {
345 if (pcb->phase != PPP_PHASE_DEAD) {
349 PPPDEBUG(LOG_DEBUG, (
"ppp_free[%d]\n", pcb->netif->num));
353 err = pcb->link_cb->free(pcb, pcb->link_ctx_cb);
362 ppp_ioctl(ppp_pcb *pcb,
u8_t cmd,
void *arg)
369 case PPPCTLG_UPSTATUS:
373 *(
int *)arg = (
int)(0
383 case PPPCTLG_ERRCODE:
387 *(
int *)arg = (
int)(pcb->err_code);
403 static void ppp_do_connect(
void *arg) {
404 ppp_pcb *pcb = (ppp_pcb*)arg;
406 LWIP_ASSERT(
"pcb->phase == PPP_PHASE_DEAD || pcb->phase == PPP_PHASE_HOLDOFF", pcb->phase == PPP_PHASE_DEAD || pcb->phase == PPP_PHASE_HOLDOFF);
408 pcb->link_cb->connect(pcb, pcb->link_ctx_cb);
415 netif->
name[0] =
'p';
416 netif->
name[1] =
'p';
419 netif->output = ppp_netif_output_ip4;
422 netif->output_ip6 = ppp_netif_output_ip6;
425 #if LWIP_NETIF_HOSTNAME 436 static err_t ppp_netif_output_ip4(
struct netif *
netif,
struct pbuf *pb,
const ip4_addr_t *ipaddr) {
439 return ppp_netif_output(netif, pb, PPP_IP);
452 static err_t ppp_netif_output_ip6(
struct netif *
netif,
struct pbuf *pb,
const ip6_addr_t *ipaddr) {
454 return ppp_netif_output(netif, pb, PPP_IPV6);
459 ppp_pcb *pcb = (ppp_pcb*)netif->
state;
466 || (protocol == PPP_IP && !pcb->if4_up)
469 || (protocol == PPP_IPV6 && !pcb->if6_up)
472 PPPDEBUG(LOG_ERR, (
"ppp_netif_output[%d]: link not up\n", pcb->netif->num));
478 if (pcb->settings.require_mppe && pcb->ccp_transmit_method != CI_MPPE) {
479 PPPDEBUG(LOG_ERR, (
"ppp_netif_output[%d]: MPPE required, not up\n", pcb->netif->num));
484 #if VJ_SUPPORT && LWIP_TCP 489 if (protocol == PPP_IP && pcb->vj_enabled) {
490 switch (vj_compress_tcp(&pcb->vj_comp, &pb)) {
495 case TYPE_COMPRESSED_TCP:
499 protocol = PPP_VJC_COMP;
501 case TYPE_UNCOMPRESSED_TCP:
505 protocol = PPP_VJC_UNCOMP;
508 PPPDEBUG(LOG_WARNING, (
"ppp_netif_output[%d]: bad IP packet\n", pcb->netif->num));
518 switch (pcb->ccp_transmit_method) {
523 if ((err = mppe_compress(pcb, &pcb->mppe_comp, &pb, protocol)) !=
ERR_OK) {
540 PPPDEBUG(LOG_ERR, (
"ppp_netif_output[%d]: bad CCP transmit method\n", pcb->netif->num));
545 err = pcb->link_cb->netif_output(pcb, pcb->link_ctx_cb, pb, protocol);
585 ppp_pcb *ppp_new(
struct netif *pppif,
const struct link_callbacks *callbacks,
void *link_ctx_cb, ppp_link_status_cb_fn link_status_cb,
void *ctx_cb) {
590 if (link_status_cb ==
NULL) {
599 memset(pcb, 0,
sizeof(ppp_pcb));
603 pcb->settings.usepeerdns = 1;
607 pcb->settings.pap_timeout_time = UPAP_DEFTIMEOUT;
608 pcb->settings.pap_max_transmits = UPAP_DEFTRANSMITS;
610 pcb->settings.pap_req_timeout = UPAP_DEFREQTIME;
615 pcb->settings.chap_timeout_time = CHAP_DEFTIMEOUT;
616 pcb->settings.chap_max_transmits = CHAP_DEFTRANSMITS;
618 pcb->settings.chap_rechallenge_time = CHAP_DEFRECHALLENGETIME;
623 pcb->settings.eap_req_time = EAP_DEFREQTIME;
624 pcb->settings.eap_allow_req = EAP_DEFALLOWREQ;
626 pcb->settings.eap_timeout_time = EAP_DEFTIMEOUT;
627 pcb->settings.eap_max_transmits = EAP_DEFTRANSMITS;
632 pcb->settings.refuse_mppe_stateful = 1;
635 pcb->settings.lcp_loopbackfail = LCP_DEFLOOPBACKFAIL;
636 pcb->settings.lcp_echo_interval = LCP_ECHOINTERVAL;
637 pcb->settings.lcp_echo_fails = LCP_MAXECHOFAILS;
639 pcb->settings.fsm_timeout_time = FSM_DEFTIMEOUT;
640 pcb->settings.fsm_max_conf_req_transmits = FSM_DEFMAXCONFREQS;
641 pcb->settings.fsm_max_term_transmits = FSM_DEFMAXTERMREQS;
642 pcb->settings.fsm_max_nak_loops = FSM_DEFMAXNAKLOOPS;
647 IP4_ADDR_ANY, IP4_ADDR_BROADCAST, IP4_ADDR_ANY,
649 (
void *)pcb, ppp_netif_init_cb,
NULL)) {
651 PPPDEBUG(LOG_ERR, (
"ppp_new: netif_add failed\n"));
655 pcb->link_cb = callbacks;
656 pcb->link_ctx_cb = link_ctx_cb;
657 pcb->link_status_cb = link_status_cb;
658 pcb->ctx_cb = ctx_cb;
659 new_phase(pcb, PPP_PHASE_DEAD);
664 void ppp_clear(ppp_pcb *pcb) {
665 const struct protent *protp;
668 LWIP_ASSERT(
"pcb->phase == PPP_PHASE_DEAD || pcb->phase == PPP_PHASE_HOLDOFF", pcb->phase == PPP_PHASE_DEAD || pcb->phase == PPP_PHASE_HOLDOFF);
670 #if PPP_STATS_SUPPORT 671 link_stats_valid = 0;
674 memset(&pcb->phase, 0,
sizeof(ppp_pcb) - ( (
char*)&((ppp_pcb*)0)->phase - (
char*)0 ) );
679 for (i = 0; (protp = protocols[i]) !=
NULL; ++i) {
683 #if VJ_SUPPORT && LWIP_TCP 684 vj_compress_init(&pcb->vj_comp);
687 new_phase(pcb, PPP_PHASE_INITIALIZE);
691 void ppp_start(ppp_pcb *pcb) {
692 PPPDEBUG(LOG_DEBUG, (
"ppp_start[%d]\n", pcb->netif->num));
695 PPPDEBUG(LOG_DEBUG, (
"ppp_start[%d]: finished\n", pcb->netif->num));
699 void ppp_link_failed(ppp_pcb *pcb) {
700 PPPDEBUG(LOG_DEBUG, (
"ppp_failed[%d]\n", pcb->netif->num));
701 new_phase(pcb, PPP_PHASE_DEAD);
702 pcb->err_code = PPPERR_OPEN;
703 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
707 void ppp_link_end(ppp_pcb *pcb) {
708 PPPDEBUG(LOG_DEBUG, (
"ppp_end[%d]\n", pcb->netif->num));
709 if (pcb->err_code == PPPERR_NONE) {
710 pcb->err_code = PPPERR_CONNECT;
712 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
719 void ppp_input(ppp_pcb *pcb,
struct pbuf *pb) {
721 #if PPP_DEBUG && PPP_PROTOCOLNAME 728 PPPDEBUG(LOG_ERR, (
"ppp_input[%d]: packet too short\n", pcb->netif->num));
734 ppp_dump_packet(
"rcvd", (
unsigned char *)pb->
payload, pb->
len);
746 if (protocol != PPP_LCP && pcb->lcp_fsm.state != PPP_FSM_OPENED) {
747 ppp_dbglog(
"Discarded non-LCP packet when LCP not open");
755 if (pcb->phase <= PPP_PHASE_AUTHENTICATE
756 && !(protocol == PPP_LCP
758 || protocol == PPP_LQR
761 || protocol == PPP_PAP
764 || protocol == PPP_CHAP
767 || protocol == PPP_EAP
770 ppp_dbglog(
"discarding proto 0x%x in phase %d", protocol, pcb->phase);
782 if (pcb->settings.require_mppe && protocol != PPP_COMP && protocol < 0x8000) {
783 PPPDEBUG(LOG_ERR, (
"ppp_input[%d]: MPPE required, received unencrypted data!\n", pcb->netif->num));
788 if (protocol == PPP_COMP) {
791 switch (pcb->ccp_receive_method) {
794 if (mppe_decompress(pcb, &pcb->mppe_decomp, &pb) !=
ERR_OK) {
800 PPPDEBUG(LOG_ERR, (
"ppp_input[%d]: bad CCP receive method\n", pcb->netif->num));
815 protocol = (pl[0] << 8) | pl[1];
825 PPPDEBUG(LOG_INFO, (
"ppp_input[%d]: ip in pbuf len=%d\n", pcb->netif->num, pb->
tot_len));
826 ip4_input(pb, pcb->netif);
832 PPPDEBUG(LOG_INFO, (
"ppp_input[%d]: ip6 in pbuf len=%d\n", pcb->netif->num, pb->
tot_len));
833 ip6_input(pb, pcb->netif);
837 #if VJ_SUPPORT && LWIP_TCP 843 PPPDEBUG(LOG_INFO, (
"ppp_input[%d]: vj_comp in pbuf len=%d\n", pcb->netif->num, pb->
tot_len));
844 if (pcb->vj_enabled && vj_uncompress_tcp(&pb, &pcb->vj_comp) >= 0) {
845 ip4_input(pb, pcb->netif);
849 PPPDEBUG(LOG_WARNING, (
"ppp_input[%d]: Dropping VJ compressed\n", pcb->netif->num));
857 PPPDEBUG(LOG_INFO, (
"ppp_input[%d]: vj_un in pbuf len=%d\n", pcb->netif->num, pb->
tot_len));
858 if (pcb->vj_enabled && vj_uncompress_uncomp(pb, &pcb->vj_comp) >= 0) {
859 ip4_input(pb, pcb->netif);
863 PPPDEBUG(LOG_WARNING, (
"ppp_input[%d]: Dropping VJ uncompressed\n", pcb->netif->num));
869 const struct protent *protp;
874 for (i = 0; (protp = protocols[i]) !=
NULL; ++i) {
875 if (protp->protocol == protocol) {
876 pb = ppp_singlebuf(pb);
893 if (protocol == (protp->protocol & ~0x8000)
894 && protp->datainput !=
NULL) {
895 (*protp->datainput)(pcb, pb->
payload, pb->
len);
903 pname = protocol_name(protocol);
905 ppp_warn(
"Unsupported protocol '%s' (0x%x) received", pname, protocol);
908 ppp_warn(
"Unsupported protocol 0x%x received", protocol);
925 struct pbuf *ppp_singlebuf(
struct pbuf *p) {
936 (
"ppp_singlebuf: unable to alloc new buf (%d)\n", p->
tot_len));
961 err_t ppp_write(ppp_pcb *pcb,
struct pbuf *p) {
963 ppp_dump_packet(
"sent", (
unsigned char *)p->
payload+2, p->
len-2);
965 return pcb->link_cb->write(pcb, pcb->link_ctx_cb, p);
968 void ppp_link_terminated(ppp_pcb *pcb) {
969 PPPDEBUG(LOG_DEBUG, (
"ppp_link_terminated[%d]\n", pcb->netif->num));
970 pcb->link_cb->disconnect(pcb, pcb->link_ctx_cb);
971 PPPDEBUG(LOG_DEBUG, (
"ppp_link_terminated[%d]: finished.\n", pcb->netif->num));
983 void new_phase(ppp_pcb *pcb,
int p) {
985 PPPDEBUG(LOG_DEBUG, (
"ppp phase changed[%d]: phase=%d\n", pcb->netif->num, pcb->phase));
987 if (pcb->notify_phase_cb !=
NULL) {
988 pcb->notify_phase_cb(pcb, p, pcb->ctx_cb);
997 int ppp_send_config(ppp_pcb *pcb,
int mtu,
u32_t accm,
int pcomp,
int accomp) {
1001 if (pcb->link_cb->send_config) {
1002 pcb->link_cb->send_config(pcb, pcb->link_ctx_cb, accm, pcomp, accomp);
1005 PPPDEBUG(LOG_INFO, (
"ppp_send_config[%d]\n", pcb->netif->num) );
1013 int ppp_recv_config(ppp_pcb *pcb,
int mru,
u32_t accm,
int pcomp,
int accomp) {
1016 if (pcb->link_cb->recv_config) {
1017 pcb->link_cb->recv_config(pcb, pcb->link_ctx_cb, accm, pcomp, accomp);
1020 PPPDEBUG(LOG_INFO, (
"ppp_recv_config[%d]\n", pcb->netif->num));
1024 #if PPP_IPV4_SUPPORT 1028 int sifaddr(ppp_pcb *pcb,
u32_t our_adr,
u32_t his_adr,
u32_t netmask) {
1029 ip4_addr_t ip, nm, gw;
1031 ip4_addr_set_u32(&ip, our_adr);
1032 ip4_addr_set_u32(&nm, netmask);
1033 ip4_addr_set_u32(&gw, his_adr);
1034 netif_set_addr(pcb->netif, &ip, &nm, &gw);
1043 int cifaddr(ppp_pcb *pcb,
u32_t our_adr,
u32_t his_adr) {
1047 netif_set_addr(pcb->netif, IP4_ADDR_ANY, IP4_ADDR_BROADCAST, IP4_ADDR_ANY);
1057 int sifproxyarp(ppp_pcb *pcb,
u32_t his_adr) {
1068 int cifproxyarp(ppp_pcb *pcb,
u32_t his_adr) {
1079 int sdns(ppp_pcb *pcb,
u32_t ns1,
u32_t ns2) {
1083 ip_addr_set_ip4_u32(&ns, ns1);
1084 dns_setserver(0, &ns);
1085 ip_addr_set_ip4_u32(&ns, ns2);
1086 dns_setserver(1, &ns);
1094 int cdns(ppp_pcb *pcb,
u32_t ns1,
u32_t ns2) {
1098 nsa = dns_getserver(0);
1099 ip_addr_set_ip4_u32(&nsb, ns1);
1101 dns_setserver(0, IP_ADDR_ANY);
1103 nsa = dns_getserver(1);
1104 ip_addr_set_ip4_u32(&nsb, ns2);
1106 dns_setserver(1, IP_ADDR_ANY);
1117 int sifvjcomp(ppp_pcb *pcb,
int vjcomp,
int cidcomp,
int maxcid) {
1118 pcb->vj_enabled = vjcomp;
1119 pcb->vj_comp.compressSlot = cidcomp;
1120 pcb->vj_comp.maxSlotIndex = maxcid;
1121 PPPDEBUG(LOG_INFO, (
"sifvjcomp[%d]: VJ compress enable=%d slot=%d max slot=%d\n",
1122 pcb->netif->num, vjcomp, cidcomp, maxcid));
1130 int sifup(ppp_pcb *pcb) {
1132 pcb->err_code = PPPERR_NONE;
1135 PPPDEBUG(LOG_DEBUG, (
"sifup[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code));
1136 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
1145 int sifdown(ppp_pcb *pcb) {
1150 #
if PPP_IPV6_SUPPORT
1158 PPPDEBUG(LOG_DEBUG, (
"sifdown[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code));
1176 if (IP_CLASSA(addr)) {
1177 nmask = IP_CLASSA_NET;
1178 }
else if (IP_CLASSB(addr)) {
1179 nmask = IP_CLASSB_NET;
1181 nmask = IP_CLASSC_NET;
1195 return IPADDR_BROADCAST;
1199 #if PPP_IPV6_SUPPORT 1200 #define IN6_LLADDR_FROM_EUI64(ip6, eui64) do { \ 1201 ip6.addr[0] = PP_HTONL(0xfe800000); \ 1203 eui64_copy(eui64, ip6.addr[2]); \ 1210 int sif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64) {
1214 IN6_LLADDR_FROM_EUI64(ip6, our_eui64);
1215 netif_ip6_addr_set(pcb->netif, 0, &ip6);
1216 netif_ip6_addr_set_state(pcb->netif, 0, IP6_ADDR_PREFERRED);
1225 int cif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64) {
1229 netif_ip6_addr_set(pcb->netif, 0, IP6_ADDR_ANY6);
1230 netif_ip6_addr_set_state(pcb->netif, 0, IP6_ADDR_INVALID);
1237 int sif6up(ppp_pcb *pcb) {
1240 pcb->err_code = PPPERR_NONE;
1243 PPPDEBUG(LOG_DEBUG, (
"sif6up[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code));
1244 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
1253 int sif6down(ppp_pcb *pcb) {
1258 #
if PPP_IPV4_SUPPORT
1266 PPPDEBUG(LOG_DEBUG, (
"sif6down[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code));
1275 int sifnpmode(ppp_pcb *pcb,
int proto,
enum NPmode mode) {
1286 void netif_set_mtu(ppp_pcb *pcb,
int mtu) {
1288 pcb->netif->mtu = mtu;
1289 PPPDEBUG(LOG_INFO, (
"netif_set_mtu[%d]: mtu=%d\n", pcb->netif->num, mtu));
1295 int netif_get_mtu(ppp_pcb *pcb) {
1297 return pcb->netif->mtu;
1306 ccp_test(ppp_pcb *pcb, u_char *opt_ptr,
int opt_len,
int for_transmit)
1320 ccp_set(ppp_pcb *pcb,
u8_t isopen,
u8_t isup,
u8_t receive_method,
u8_t transmit_method)
1324 pcb->ccp_receive_method = receive_method;
1325 pcb->ccp_transmit_method = transmit_method;
1326 PPPDEBUG(LOG_DEBUG, (
"ccp_set[%d]: is_open=%d, is_up=%d, receive_method=%u, transmit_method=%u\n",
1327 pcb->netif->num, isopen, isup, receive_method, transmit_method));
1331 ccp_reset_comp(ppp_pcb *pcb)
1333 switch (pcb->ccp_transmit_method) {
1336 mppe_comp_reset(pcb, &pcb->mppe_comp);
1345 ccp_reset_decomp(ppp_pcb *pcb)
1347 switch (pcb->ccp_receive_method) {
1350 mppe_decomp_reset(pcb, &pcb->mppe_decomp);
1365 ccp_fatal_error(ppp_pcb *pcb)
1373 #if PPP_IDLETIMELIMIT 1378 int get_idle_time(ppp_pcb *pcb,
struct ppp_idle *ip) {
1393 int get_loop_output(
void) {
1398 #if PPP_PROTOCOLNAME 1400 struct protocol_list {
1403 } protocol_list[] = {
1405 { 0x23,
"OSI Network Layer" },
1406 { 0x25,
"Xerox NS IDP" },
1407 { 0x27,
"DECnet Phase IV" },
1408 { 0x29,
"Appletalk" },
1409 { 0x2b,
"Novell IPX" },
1410 { 0x2d,
"VJ compressed TCP/IP" },
1411 { 0x2f,
"VJ uncompressed TCP/IP" },
1412 { 0x31,
"Bridging PDU" },
1413 { 0x33,
"Stream Protocol ST-II" },
1414 { 0x35,
"Banyan Vines" },
1415 { 0x39,
"AppleTalk EDDP" },
1416 { 0x3b,
"AppleTalk SmartBuffered" },
1417 { 0x3d,
"Multi-Link" },
1418 { 0x3f,
"NETBIOS Framing" },
1419 { 0x41,
"Cisco Systems" },
1420 { 0x43,
"Ascom Timeplex" },
1421 { 0x45,
"Fujitsu Link Backup and Load Balancing (LBLB)" },
1422 { 0x47,
"DCA Remote Lan" },
1423 { 0x49,
"Serial Data Transport Protocol (PPP-SDTP)" },
1424 { 0x4b,
"SNA over 802.2" },
1426 { 0x4f,
"IP6 Header Compression" },
1427 { 0x51,
"KNX Bridging Data" },
1428 { 0x53,
"Encryption" },
1429 { 0x55,
"Individual Link Encryption" },
1431 { 0x59,
"PPP Muxing" },
1432 { 0x5b,
"Vendor-Specific Network Protocol" },
1433 { 0x61,
"RTP IPHC Full Header" },
1434 { 0x63,
"RTP IPHC Compressed TCP" },
1435 { 0x65,
"RTP IPHC Compressed non-TCP" },
1436 { 0x67,
"RTP IPHC Compressed UDP 8" },
1437 { 0x69,
"RTP IPHC Compressed RTP 8" },
1438 { 0x6f,
"Stampede Bridging" },
1440 { 0xc1,
"NTCITS IPI" },
1441 { 0xfb,
"single-link compression" },
1442 { 0xfd,
"Compressed Datagram" },
1443 { 0x0201,
"802.1d Hello Packets" },
1444 { 0x0203,
"IBM Source Routing BPDU" },
1445 { 0x0205,
"DEC LANBridge100 Spanning Tree" },
1446 { 0x0207,
"Cisco Discovery Protocol" },
1447 { 0x0209,
"Netcs Twin Routing" },
1448 { 0x020b,
"STP - Scheduled Transfer Protocol" },
1449 { 0x020d,
"EDP - Extreme Discovery Protocol" },
1450 { 0x0211,
"Optical Supervisory Channel Protocol" },
1451 { 0x0213,
"Optical Supervisory Channel Protocol" },
1452 { 0x0231,
"Luxcom" },
1453 { 0x0233,
"Sigma Network Systems" },
1454 { 0x0235,
"Apple Client Server Protocol" },
1455 { 0x0281,
"MPLS Unicast" },
1456 { 0x0283,
"MPLS Multicast" },
1457 { 0x0285,
"IEEE p1284.4 standard - data packets" },
1458 { 0x0287,
"ETSI TETRA Network Protocol Type 1" },
1459 { 0x0289,
"Multichannel Flow Treatment Protocol" },
1460 { 0x2063,
"RTP IPHC Compressed TCP No Delta" },
1461 { 0x2065,
"RTP IPHC Context State" },
1462 { 0x2067,
"RTP IPHC Compressed UDP 16" },
1463 { 0x2069,
"RTP IPHC Compressed RTP 16" },
1464 { 0x4001,
"Cray Communications Control Protocol" },
1465 { 0x4003,
"CDPD Mobile Network Registration Protocol" },
1466 { 0x4005,
"Expand accelerator protocol" },
1467 { 0x4007,
"ODSICP NCP" },
1468 { 0x4009,
"DOCSIS DLL" },
1469 { 0x400B,
"Cetacean Network Detection Protocol" },
1470 { 0x4021,
"Stacker LZS" },
1471 { 0x4023,
"RefTek Protocol" },
1472 { 0x4025,
"Fibre Channel" },
1473 { 0x4027,
"EMIT Protocols" },
1474 { 0x405b,
"Vendor-Specific Protocol (VSP)" },
1475 { 0x8021,
"Internet Protocol Control Protocol" },
1476 { 0x8023,
"OSI Network Layer Control Protocol" },
1477 { 0x8025,
"Xerox NS IDP Control Protocol" },
1478 { 0x8027,
"DECnet Phase IV Control Protocol" },
1479 { 0x8029,
"Appletalk Control Protocol" },
1480 { 0x802b,
"Novell IPX Control Protocol" },
1481 { 0x8031,
"Bridging NCP" },
1482 { 0x8033,
"Stream Protocol Control Protocol" },
1483 { 0x8035,
"Banyan Vines Control Protocol" },
1484 { 0x803d,
"Multi-Link Control Protocol" },
1485 { 0x803f,
"NETBIOS Framing Control Protocol" },
1486 { 0x8041,
"Cisco Systems Control Protocol" },
1487 { 0x8043,
"Ascom Timeplex" },
1488 { 0x8045,
"Fujitsu LBLB Control Protocol" },
1489 { 0x8047,
"DCA Remote Lan Network Control Protocol (RLNCP)" },
1490 { 0x8049,
"Serial Data Control Protocol (PPP-SDCP)" },
1491 { 0x804b,
"SNA over 802.2 Control Protocol" },
1492 { 0x804d,
"SNA Control Protocol" },
1493 { 0x804f,
"IP6 Header Compression Control Protocol" },
1494 { 0x8051,
"KNX Bridging Control Protocol" },
1495 { 0x8053,
"Encryption Control Protocol" },
1496 { 0x8055,
"Individual Link Encryption Control Protocol" },
1497 { 0x8057,
"IPv6 Control Protocol" },
1498 { 0x8059,
"PPP Muxing Control Protocol" },
1499 { 0x805b,
"Vendor-Specific Network Control Protocol (VSNCP)" },
1500 { 0x806f,
"Stampede Bridging Control Protocol" },
1501 { 0x8073,
"MP+ Control Protocol" },
1502 { 0x80c1,
"NTCITS IPI Control Protocol" },
1503 { 0x80fb,
"Single Link Compression Control Protocol" },
1504 { 0x80fd,
"Compression Control Protocol" },
1505 { 0x8207,
"Cisco Discovery Protocol Control" },
1506 { 0x8209,
"Netcs Twin Routing" },
1507 { 0x820b,
"STP - Control Protocol" },
1508 { 0x820d,
"EDPCP - Extreme Discovery Protocol Ctrl Prtcl" },
1509 { 0x8235,
"Apple Client Server Protocol Control" },
1510 { 0x8281,
"MPLSCP" },
1511 { 0x8285,
"IEEE p1284.4 standard - Protocol Control" },
1512 { 0x8287,
"ETSI TETRA TNP1 Control Protocol" },
1513 { 0x8289,
"Multichannel Flow Treatment Protocol" },
1514 { 0xc021,
"Link Control Protocol" },
1515 { 0xc023,
"Password Authentication Protocol" },
1516 { 0xc025,
"Link Quality Report" },
1517 { 0xc027,
"Shiva Password Authentication Protocol" },
1518 { 0xc029,
"CallBack Control Protocol (CBCP)" },
1519 { 0xc02b,
"BACP Bandwidth Allocation Control Protocol" },
1521 { 0xc05b,
"Vendor-Specific Authentication Protocol (VSAP)" },
1522 { 0xc081,
"Container Control Protocol" },
1523 { 0xc223,
"Challenge Handshake Authentication Protocol" },
1524 { 0xc225,
"RSA Authentication Protocol" },
1525 { 0xc227,
"Extensible Authentication Protocol" },
1526 { 0xc229,
"Mitsubishi Security Info Exch Ptcl (SIEP)" },
1527 { 0xc26f,
"Stampede Bridging Authorization Protocol" },
1528 { 0xc281,
"Proprietary Authentication Protocol" },
1529 { 0xc283,
"Proprietary Authentication Protocol" },
1530 { 0xc481,
"Proprietary Node ID Authentication Protocol" },
1537 const char * protocol_name(
int proto) {
1538 struct protocol_list *lp;
1540 for (lp = protocol_list; lp->proto != 0; ++lp) {
1541 if (proto == lp->proto) {
1549 #if PPP_STATS_SUPPORT 1560 void reset_link_stats(
int u) {
1561 if (!get_ppp_stats(u, &old_link_stats)) {
1564 gettimeofday(&start_time,
NULL);
1570 void update_link_stats(
int u) {
1574 if (!get_ppp_stats(u, &link_stats) || gettimeofday(&now,
NULL) < 0) {
1577 link_connect_time = now.tv_sec - start_time.tv_sec;
1578 link_stats_valid = 1;
1580 link_stats.bytes_in -= old_link_stats.bytes_in;
1581 link_stats.bytes_out -= old_link_stats.bytes_out;
1582 link_stats.pkts_in -= old_link_stats.pkts_in;
1583 link_stats.pkts_out -= old_link_stats.pkts_out;
1586 void print_link_stats() {
1590 if (link_stats_valid) {
1591 int t = (link_connect_time + 5) / 6;
1592 info(
"Connect time %d.%d minutes.", t/10, t%10);
1593 info(
"Sent %u bytes, received %u bytes.", link_stats.bytes_out, link_stats.bytes_in);
1594 link_stats_valid = 0;
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
void netif_set_link_down(struct netif *netif)
#define MEMCPY(dst, src, len)
void memp_free(memp_t type, void *mem)
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
#define MIB2_STATS_NETIF_ADD(n, x, val)
u8_t pbuf_free(struct pbuf *p)
void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg)
#define LINK_STATS_INC(x)
#define ip_addr_cmp(addr1, addr2)
#define LWIP_ASSERT(message, assertion)
void netif_remove(struct netif *netif)
#define MIB2_STATS_NETIF_INC(n, x)
void netif_set_link_up(struct netif *netif)
struct netif * netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
void * memp_malloc(memp_t type)
#define LWIP_UNUSED_ARG(x)
void sys_untimeout(sys_timeout_handler handler, void *arg)