107 #include "netif/ppp/ppp_opts.h" 122 #include "netif/ppp/ppp_impl.h" 125 #include "netif/ppp/fsm.h" 126 #include "netif/ppp/lcp.h" 127 #include "netif/ppp/magic.h" 130 #include "netif/ppp/upap.h" 133 #include "netif/ppp/chap-new.h" 136 #include "netif/ppp/eap.h" 139 #include "netif/ppp/ccp.h" 142 #include "netif/ppp/mppe.h" 145 #include "netif/ppp/ecp.h" 148 #include "netif/ppp/vj.h" 151 #include "netif/ppp/ipcp.h" 154 #include "netif/ppp/ipv6cp.h" 171 #if LWIP_PPP_API && LWIP_MPU_COMPATIBLE 177 #if PPP_STATS_SUPPORT 178 static struct timeval start_time;
179 static struct pppd_stats old_link_stats;
180 struct pppd_stats link_stats;
181 unsigned link_connect_time;
182 int link_stats_valid;
190 const struct protent*
const protocols[] = {
223 static void ppp_do_connect(
void *arg);
226 static err_t ppp_netif_output_ip4(
struct netif *
netif,
struct pbuf *pb,
const ip4_addr_t *ipaddr);
229 static err_t ppp_netif_output_ip6(
struct netif *
netif,
struct pbuf *pb,
const ip6_addr_t *ipaddr);
237 void ppp_set_auth(ppp_pcb *pcb, u8_t authtype,
const char *user,
const char *passwd) {
239 pcb->settings.refuse_pap = !(authtype & PPPAUTHTYPE_PAP);
242 pcb->settings.refuse_chap = !(authtype & PPPAUTHTYPE_CHAP);
244 pcb->settings.refuse_mschap = !(authtype & PPPAUTHTYPE_MSCHAP);
245 pcb->settings.refuse_mschap_v2 = !(authtype & PPPAUTHTYPE_MSCHAP_V2);
249 pcb->settings.refuse_eap = !(authtype & PPPAUTHTYPE_EAP);
251 pcb->settings.user = user;
252 pcb->settings.passwd = passwd;
258 void ppp_set_mppe(ppp_pcb *pcb, u8_t flags) {
259 if (flags == PPP_MPPE_DISABLE) {
260 pcb->settings.require_mppe = 0;
264 pcb->settings.require_mppe = 1;
265 pcb->settings.refuse_mppe_stateful = !(flags & PPP_MPPE_ALLOW_STATEFUL);
266 pcb->settings.refuse_mppe_40 = !!(flags & PPP_MPPE_REFUSE_40);
267 pcb->settings.refuse_mppe_128 = !!(flags & PPP_MPPE_REFUSE_128);
272 void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb) {
273 pcb->notify_phase_cb = notify_phase_cb;
274 notify_phase_cb(pcb, pcb->phase, pcb->ctx_cb);
289 err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff) {
290 if (pcb->phase != PPP_PHASE_DEAD) {
294 PPPDEBUG(LOG_DEBUG, (
"ppp_connect[%d]: holdoff=%d\n", pcb->netif->num, holdoff));
301 new_phase(pcb, PPP_PHASE_HOLDOFF);
302 sys_timeout((u32_t)(holdoff*1000), ppp_do_connect, pcb);
315 err_t ppp_listen(ppp_pcb *pcb) {
316 if (pcb->phase != PPP_PHASE_DEAD) {
320 PPPDEBUG(LOG_DEBUG, (
"ppp_listen[%d]\n", pcb->netif->num));
322 if (pcb->link_cb->listen) {
323 new_phase(pcb, PPP_PHASE_INITIALIZE);
324 pcb->link_cb->listen(pcb, pcb->link_ctx_cb);
343 ppp_close(ppp_pcb *pcb, u8_t nocarrier)
345 pcb->err_code = PPPERR_USER;
348 if (pcb->phase == PPP_PHASE_HOLDOFF) {
349 sys_untimeout(ppp_do_connect, pcb);
350 new_phase(pcb, PPP_PHASE_DEAD);
354 if (pcb->phase == PPP_PHASE_DEAD) {
355 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
360 if (pcb->phase >= PPP_PHASE_TERMINATE) {
365 if (pcb->phase < PPP_PHASE_ESTABLISH) {
366 new_phase(pcb, PPP_PHASE_DISCONNECT);
367 ppp_link_terminated(pcb);
378 if (nocarrier && pcb->phase == PPP_PHASE_RUNNING) {
379 PPPDEBUG(LOG_DEBUG, (
"ppp_close[%d]: carrier lost -> lcp_lowerdown\n", pcb->netif->num));
382 link_terminated(pcb);
387 PPPDEBUG(LOG_DEBUG, (
"ppp_close[%d]: kill_link -> lcp_close\n", pcb->netif->num));
389 lcp_close(pcb,
"User request");
403 err_t ppp_free(ppp_pcb *pcb) {
405 if (pcb->phase != PPP_PHASE_DEAD) {
409 PPPDEBUG(LOG_DEBUG, (
"ppp_free[%d]\n", pcb->netif->num));
413 err = pcb->link_cb->free(pcb, pcb->link_ctx_cb);
422 ppp_ioctl(ppp_pcb *pcb, u8_t
cmd,
void *arg)
429 case PPPCTLG_UPSTATUS:
433 *(
int *)arg = (
int)(0
443 case PPPCTLG_ERRCODE:
447 *(
int *)arg = (
int)(pcb->err_code);
463 static void ppp_do_connect(
void *arg) {
464 ppp_pcb *pcb = (ppp_pcb*)arg;
466 LWIP_ASSERT(
"pcb->phase == PPP_PHASE_DEAD || pcb->phase == PPP_PHASE_HOLDOFF", pcb->phase == PPP_PHASE_DEAD || pcb->phase == PPP_PHASE_HOLDOFF);
468 new_phase(pcb, PPP_PHASE_INITIALIZE);
469 pcb->link_cb->connect(pcb, pcb->link_ctx_cb);
476 netif->
name[0] =
'p';
477 netif->
name[1] =
'p';
480 netif->output = ppp_netif_output_ip4;
483 netif->output_ip6 = ppp_netif_output_ip6;
486 #if LWIP_NETIF_HOSTNAME 497 static err_t ppp_netif_output_ip4(
struct netif *
netif,
struct pbuf *pb,
const ip4_addr_t *ipaddr) {
500 return ppp_netif_output(netif, pb, PPP_IP);
513 static err_t ppp_netif_output_ip6(
struct netif *
netif,
struct pbuf *pb,
const ip6_addr_t *ipaddr) {
515 return ppp_netif_output(netif, pb, PPP_IPV6);
520 ppp_pcb *pcb = (ppp_pcb*)netif->
state;
522 struct pbuf *fpb = NULL;
527 || (protocol == PPP_IP && !pcb->if4_up)
530 || (protocol == PPP_IPV6 && !pcb->if6_up)
533 PPPDEBUG(LOG_ERR, (
"ppp_netif_output[%d]: link not up\n", pcb->netif->num));
539 if (pcb->settings.require_mppe && pcb->ccp_transmit_method != CI_MPPE) {
540 PPPDEBUG(LOG_ERR, (
"ppp_netif_output[%d]: MPPE required, not up\n", pcb->netif->num));
550 if (protocol == PPP_IP && pcb->vj_enabled) {
551 switch (vj_compress_tcp(&pcb->vj_comp, &pb)) {
556 case TYPE_COMPRESSED_TCP:
560 protocol = PPP_VJC_COMP;
562 case TYPE_UNCOMPRESSED_TCP:
566 protocol = PPP_VJC_UNCOMP;
569 PPPDEBUG(LOG_WARNING, (
"ppp_netif_output[%d]: bad IP packet\n", pcb->netif->num));
570 LINK_STATS_INC(link.proterr);
571 LINK_STATS_INC(link.drop);
572 MIB2_STATS_NETIF_INC(pcb->netif, ifoutdiscards);
579 switch (pcb->ccp_transmit_method) {
584 if ((err = mppe_compress(pcb, &pcb->mppe_comp, &pb, protocol)) !=
ERR_OK) {
585 LINK_STATS_INC(link.memerr);
586 LINK_STATS_INC(link.drop);
587 MIB2_STATS_NETIF_INC(netif, ifoutdiscards);
601 PPPDEBUG(LOG_ERR, (
"ppp_netif_output[%d]: bad CCP transmit method\n", pcb->netif->num));
606 err = pcb->link_cb->netif_output(pcb, pcb->link_ctx_cb, pb, protocol);
611 LINK_STATS_INC(link.rterr);
612 LINK_STATS_INC(link.drop);
613 MIB2_STATS_NETIF_INC(netif, ifoutdiscards);
637 #if LWIP_PPP_API && LWIP_MPU_COMPATIBLE 661 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) {
663 const struct protent *protp;
668 if (link_status_cb == NULL) {
677 memset(pcb, 0,
sizeof(ppp_pcb));
681 pcb->settings.pap_timeout_time = UPAP_DEFTIMEOUT;
682 pcb->settings.pap_max_transmits = UPAP_DEFTRANSMITS;
684 pcb->settings.pap_req_timeout = UPAP_DEFREQTIME;
689 pcb->settings.chap_timeout_time = CHAP_DEFTIMEOUT;
690 pcb->settings.chap_max_transmits = CHAP_DEFTRANSMITS;
692 pcb->settings.chap_rechallenge_time = CHAP_DEFRECHALLENGETIME;
697 pcb->settings.eap_req_time = EAP_DEFREQTIME;
698 pcb->settings.eap_allow_req = EAP_DEFALLOWREQ;
700 pcb->settings.eap_timeout_time = EAP_DEFTIMEOUT;
701 pcb->settings.eap_max_transmits = EAP_DEFTRANSMITS;
705 pcb->settings.lcp_loopbackfail = LCP_DEFLOOPBACKFAIL;
706 pcb->settings.lcp_echo_interval = LCP_ECHOINTERVAL;
707 pcb->settings.lcp_echo_fails = LCP_MAXECHOFAILS;
709 pcb->settings.fsm_timeout_time = FSM_DEFTIMEOUT;
710 pcb->settings.fsm_max_conf_req_transmits = FSM_DEFMAXCONFREQS;
711 pcb->settings.fsm_max_term_transmits = FSM_DEFMAXTERMREQS;
712 pcb->settings.fsm_max_nak_loops = FSM_DEFMAXNAKLOOPS;
715 MIB2_INIT_NETIF(pppif, snmp_ifType_ppp, 0);
718 IP4_ADDR_ANY4, IP4_ADDR_BROADCAST, IP4_ADDR_ANY4,
720 (
void *)pcb, ppp_netif_init_cb, NULL)) {
722 PPPDEBUG(LOG_ERR, (
"ppp_new: netif_add failed\n"));
726 pcb->link_cb = callbacks;
727 pcb->link_ctx_cb = link_ctx_cb;
728 pcb->link_status_cb = link_status_cb;
729 pcb->ctx_cb = ctx_cb;
734 for (i = 0; (protp = protocols[i]) != NULL; ++i) {
738 new_phase(pcb, PPP_PHASE_DEAD);
743 void ppp_start(ppp_pcb *pcb) {
744 PPPDEBUG(LOG_DEBUG, (
"ppp_start[%d]\n", pcb->netif->num));
747 #if PPP_STATS_SUPPORT 748 link_stats_valid = 0;
751 pcb->mppe_keys_set = 0;
752 memset(&pcb->mppe_comp, 0,
sizeof(pcb->mppe_comp));
753 memset(&pcb->mppe_decomp, 0,
sizeof(pcb->mppe_decomp));
756 vj_compress_init(&pcb->vj_comp);
760 new_phase(pcb, PPP_PHASE_ESTABLISH);
763 PPPDEBUG(LOG_DEBUG, (
"ppp_start[%d]: finished\n", pcb->netif->num));
767 void ppp_link_failed(ppp_pcb *pcb) {
768 PPPDEBUG(LOG_DEBUG, (
"ppp_link_failed[%d]\n", pcb->netif->num));
769 new_phase(pcb, PPP_PHASE_DEAD);
770 pcb->err_code = PPPERR_OPEN;
771 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
775 void ppp_link_end(ppp_pcb *pcb) {
776 PPPDEBUG(LOG_DEBUG, (
"ppp_link_end[%d]\n", pcb->netif->num));
777 new_phase(pcb, PPP_PHASE_DEAD);
778 if (pcb->err_code == PPPERR_NONE) {
779 pcb->err_code = PPPERR_CONNECT;
781 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
788 void ppp_input(ppp_pcb *pcb,
struct pbuf *pb) {
790 #if PPP_DEBUG && PPP_PROTOCOLNAME 797 PPPDEBUG(LOG_ERR, (
"ppp_input[%d]: packet too short\n", pcb->netif->num));
800 protocol = (((u8_t *)pb->
payload)[0] << 8) | ((u8_t*)pb->
payload)[1];
803 ppp_dump_packet(pcb,
"rcvd", (
unsigned char *)pb->
payload, pb->
len);
808 LINK_STATS_INC(link.recv);
809 MIB2_STATS_NETIF_INC(pcb->netif, ifinucastpkts);
810 MIB2_STATS_NETIF_ADD(pcb->netif, ifinoctets, pb->
tot_len);
815 if (protocol != PPP_LCP && pcb->lcp_fsm.state != PPP_FSM_OPENED) {
816 ppp_dbglog(
"Discarded non-LCP packet when LCP not open");
824 if (pcb->phase <= PPP_PHASE_AUTHENTICATE
825 && !(protocol == PPP_LCP
827 || protocol == PPP_LQR
830 || protocol == PPP_PAP
833 || protocol == PPP_CHAP
836 || protocol == PPP_EAP
839 ppp_dbglog(
"discarding proto 0x%x in phase %d", protocol, pcb->phase);
851 if (pcb->settings.require_mppe && protocol != PPP_COMP && protocol < 0x8000) {
852 PPPDEBUG(LOG_ERR, (
"ppp_input[%d]: MPPE required, received unencrypted data!\n", pcb->netif->num));
857 if (protocol == PPP_COMP) {
860 switch (pcb->ccp_receive_method) {
863 if (mppe_decompress(pcb, &pcb->mppe_decomp, &pb) !=
ERR_OK) {
869 PPPDEBUG(LOG_ERR, (
"ppp_input[%d]: bad CCP receive method\n", pcb->netif->num));
884 protocol = (pl[0] << 8) | pl[1];
894 PPPDEBUG(LOG_INFO, (
"ppp_input[%d]: ip in pbuf len=%d\n", pcb->netif->num, pb->
tot_len));
895 ip4_input(pb, pcb->netif);
901 PPPDEBUG(LOG_INFO, (
"ppp_input[%d]: ip6 in pbuf len=%d\n", pcb->netif->num, pb->
tot_len));
902 ip6_input(pb, pcb->netif);
912 PPPDEBUG(LOG_INFO, (
"ppp_input[%d]: vj_comp in pbuf len=%d\n", pcb->netif->num, pb->
tot_len));
913 if (pcb->vj_enabled && vj_uncompress_tcp(&pb, &pcb->vj_comp) >= 0) {
914 ip4_input(pb, pcb->netif);
918 PPPDEBUG(LOG_WARNING, (
"ppp_input[%d]: Dropping VJ compressed\n", pcb->netif->num));
926 PPPDEBUG(LOG_INFO, (
"ppp_input[%d]: vj_un in pbuf len=%d\n", pcb->netif->num, pb->
tot_len));
927 if (pcb->vj_enabled && vj_uncompress_uncomp(pb, &pcb->vj_comp) >= 0) {
928 ip4_input(pb, pcb->netif);
932 PPPDEBUG(LOG_WARNING, (
"ppp_input[%d]: Dropping VJ uncompressed\n", pcb->netif->num));
938 const struct protent *protp;
943 for (i = 0; (protp = protocols[i]) != NULL; ++i) {
944 if (protp->protocol == protocol) {
945 pb = ppp_singlebuf(pb);
946 (*protp->input)(pcb, (u8_t*)pb->
payload, pb->
len);
962 if (protocol == (protp->protocol & ~0x8000)
963 && protp->datainput != NULL) {
964 (*protp->datainput)(pcb, pb->
payload, pb->
len);
972 pname = protocol_name(protocol);
974 ppp_warn(
"Unsupported protocol '%s' (0x%x) received", pname, protocol);
977 ppp_warn(
"Unsupported protocol 0x%x received", protocol);
980 lcp_sprotrej(pcb, (u8_t*)pb->
payload, pb->
len);
986 LINK_STATS_INC(link.drop);
987 MIB2_STATS_NETIF_INC(pcb->netif, ifindiscards);
994 struct pbuf *ppp_singlebuf(
struct pbuf *p) {
1005 (
"ppp_singlebuf: unable to alloc new buf (%d)\n", p->
tot_len));
1009 for(b = p, pl = (u8_t*)q->
payload; b != NULL; b = b->
next) {
1027 err_t ppp_write(ppp_pcb *pcb,
struct pbuf *p) {
1028 #if PRINTPKT_SUPPORT 1029 ppp_dump_packet(pcb,
"sent", (
unsigned char *)p->
payload+2, p->
len-2);
1031 return pcb->link_cb->write(pcb, pcb->link_ctx_cb, p);
1034 void ppp_link_terminated(ppp_pcb *pcb) {
1035 PPPDEBUG(LOG_DEBUG, (
"ppp_link_terminated[%d]\n", pcb->netif->num));
1036 pcb->link_cb->disconnect(pcb, pcb->link_ctx_cb);
1037 PPPDEBUG(LOG_DEBUG, (
"ppp_link_terminated[%d]: finished.\n", pcb->netif->num));
1049 void new_phase(ppp_pcb *pcb,
int p) {
1051 PPPDEBUG(LOG_DEBUG, (
"ppp phase changed[%d]: phase=%d\n", pcb->netif->num, pcb->phase));
1052 #if PPP_NOTIFY_PHASE 1053 if (pcb->notify_phase_cb != NULL) {
1054 pcb->notify_phase_cb(pcb, p, pcb->ctx_cb);
1063 int ppp_send_config(ppp_pcb *pcb,
int mtu, u32_t accm,
int pcomp,
int accomp) {
1067 if (pcb->link_cb->send_config) {
1068 pcb->link_cb->send_config(pcb, pcb->link_ctx_cb, accm, pcomp, accomp);
1071 PPPDEBUG(LOG_INFO, (
"ppp_send_config[%d]\n", pcb->netif->num) );
1079 int ppp_recv_config(ppp_pcb *pcb,
int mru, u32_t accm,
int pcomp,
int accomp) {
1082 if (pcb->link_cb->recv_config) {
1083 pcb->link_cb->recv_config(pcb, pcb->link_ctx_cb, accm, pcomp, accomp);
1086 PPPDEBUG(LOG_INFO, (
"ppp_recv_config[%d]\n", pcb->netif->num));
1090 #if PPP_IPV4_SUPPORT 1094 int sifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr, u32_t netmask) {
1095 ip4_addr_t ip, nm, gw;
1097 ip4_addr_set_u32(&ip, our_adr);
1098 ip4_addr_set_u32(&nm, netmask);
1099 ip4_addr_set_u32(&gw, his_adr);
1100 netif_set_addr(pcb->netif, &ip, &nm, &gw);
1109 int cifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr) {
1113 netif_set_addr(pcb->netif, IP4_ADDR_ANY4, IP4_ADDR_BROADCAST, IP4_ADDR_ANY4);
1123 int sifproxyarp(ppp_pcb *pcb, u32_t his_adr) {
1134 int cifproxyarp(ppp_pcb *pcb, u32_t his_adr) {
1145 int sdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2) {
1149 ip_addr_set_ip4_u32(&ns, ns1);
1150 dns_setserver(0, &ns);
1151 ip_addr_set_ip4_u32(&ns, ns2);
1152 dns_setserver(1, &ns);
1160 int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2) {
1161 const ip_addr_t *nsa;
1165 nsa = dns_getserver(0);
1166 ip_addr_set_ip4_u32(&nsb, ns1);
1167 if (ip_addr_cmp(nsa, &nsb)) {
1168 dns_setserver(0, IP_ADDR_ANY);
1170 nsa = dns_getserver(1);
1171 ip_addr_set_ip4_u32(&nsb, ns2);
1172 if (ip_addr_cmp(nsa, &nsb)) {
1173 dns_setserver(1, IP_ADDR_ANY);
1184 int sifvjcomp(ppp_pcb *pcb,
int vjcomp,
int cidcomp,
int maxcid) {
1185 pcb->vj_enabled = vjcomp;
1186 pcb->vj_comp.compressSlot = cidcomp;
1187 pcb->vj_comp.maxSlotIndex = maxcid;
1188 PPPDEBUG(LOG_INFO, (
"sifvjcomp[%d]: VJ compress enable=%d slot=%d max slot=%d\n",
1189 pcb->netif->num, vjcomp, cidcomp, maxcid));
1197 int sifup(ppp_pcb *pcb) {
1199 pcb->err_code = PPPERR_NONE;
1202 PPPDEBUG(LOG_DEBUG, (
"sifup[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code));
1203 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
1212 int sifdown(ppp_pcb *pcb) {
1217 #
if PPP_IPV6_SUPPORT
1225 PPPDEBUG(LOG_DEBUG, (
"sifdown[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code));
1238 u32_t get_mask(u32_t addr) {
1242 addr = lwip_htonl(addr);
1243 if (IP_CLASSA(addr)) {
1244 nmask = IP_CLASSA_NET;
1245 }
else if (IP_CLASSB(addr)) {
1246 nmask = IP_CLASSB_NET;
1248 nmask = IP_CLASSC_NET;
1252 mask = PP_HTONL(0xffffff00UL) | lwip_htonl(nmask);
1262 return IPADDR_BROADCAST;
1266 #if PPP_IPV6_SUPPORT 1267 #define IN6_LLADDR_FROM_EUI64(ip6, eui64) do { \ 1268 ip6.addr[0] = PP_HTONL(0xfe800000); \ 1270 eui64_copy(eui64, ip6.addr[2]); \ 1277 int sif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64) {
1281 IN6_LLADDR_FROM_EUI64(ip6, our_eui64);
1282 netif_ip6_addr_set(pcb->netif, 0, &ip6);
1283 netif_ip6_addr_set_state(pcb->netif, 0, IP6_ADDR_PREFERRED);
1292 int cif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64) {
1296 netif_ip6_addr_set(pcb->netif, 0, IP6_ADDR_ANY6);
1297 netif_ip6_addr_set_state(pcb->netif, 0, IP6_ADDR_INVALID);
1304 int sif6up(ppp_pcb *pcb) {
1307 pcb->err_code = PPPERR_NONE;
1310 PPPDEBUG(LOG_DEBUG, (
"sif6up[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code));
1311 pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb);
1320 int sif6down(ppp_pcb *pcb) {
1325 #
if PPP_IPV4_SUPPORT
1333 PPPDEBUG(LOG_DEBUG, (
"sif6down[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code));
1342 int sifnpmode(ppp_pcb *pcb,
int proto,
enum NPmode mode) {
1353 void netif_set_mtu(ppp_pcb *pcb,
int mtu) {
1355 pcb->netif->mtu = mtu;
1356 PPPDEBUG(LOG_INFO, (
"netif_set_mtu[%d]: mtu=%d\n", pcb->netif->num, mtu));
1362 int netif_get_mtu(ppp_pcb *pcb) {
1364 return pcb->netif->mtu;
1373 ccp_test(ppp_pcb *pcb, u_char *opt_ptr,
int opt_len,
int for_transmit)
1387 ccp_set(ppp_pcb *pcb, u8_t isopen, u8_t isup, u8_t receive_method, u8_t transmit_method)
1391 pcb->ccp_receive_method = receive_method;
1392 pcb->ccp_transmit_method = transmit_method;
1393 PPPDEBUG(LOG_DEBUG, (
"ccp_set[%d]: is_open=%d, is_up=%d, receive_method=%u, transmit_method=%u\n",
1394 pcb->netif->num, isopen, isup, receive_method, transmit_method));
1398 ccp_reset_comp(ppp_pcb *pcb)
1400 switch (pcb->ccp_transmit_method) {
1403 mppe_comp_reset(pcb, &pcb->mppe_comp);
1412 ccp_reset_decomp(ppp_pcb *pcb)
1414 switch (pcb->ccp_receive_method) {
1417 mppe_decomp_reset(pcb, &pcb->mppe_decomp);
1432 ccp_fatal_error(ppp_pcb *pcb)
1440 #if PPP_IDLETIMELIMIT 1445 int get_idle_time(ppp_pcb *pcb,
struct ppp_idle *ip) {
1460 int get_loop_output(
void) {
1465 #if PPP_PROTOCOLNAME 1467 struct protocol_list {
1470 }
const protocol_list[] = {
1472 { 0x23,
"OSI Network Layer" },
1473 { 0x25,
"Xerox NS IDP" },
1474 { 0x27,
"DECnet Phase IV" },
1475 { 0x29,
"Appletalk" },
1476 { 0x2b,
"Novell IPX" },
1477 { 0x2d,
"VJ compressed TCP/IP" },
1478 { 0x2f,
"VJ uncompressed TCP/IP" },
1479 { 0x31,
"Bridging PDU" },
1480 { 0x33,
"Stream Protocol ST-II" },
1481 { 0x35,
"Banyan Vines" },
1482 { 0x39,
"AppleTalk EDDP" },
1483 { 0x3b,
"AppleTalk SmartBuffered" },
1484 { 0x3d,
"Multi-Link" },
1485 { 0x3f,
"NETBIOS Framing" },
1486 { 0x41,
"Cisco Systems" },
1487 { 0x43,
"Ascom Timeplex" },
1488 { 0x45,
"Fujitsu Link Backup and Load Balancing (LBLB)" },
1489 { 0x47,
"DCA Remote Lan" },
1490 { 0x49,
"Serial Data Transport Protocol (PPP-SDTP)" },
1491 { 0x4b,
"SNA over 802.2" },
1493 { 0x4f,
"IP6 Header Compression" },
1494 { 0x51,
"KNX Bridging Data" },
1495 { 0x53,
"Encryption" },
1496 { 0x55,
"Individual Link Encryption" },
1498 { 0x59,
"PPP Muxing" },
1499 { 0x5b,
"Vendor-Specific Network Protocol" },
1500 { 0x61,
"RTP IPHC Full Header" },
1501 { 0x63,
"RTP IPHC Compressed TCP" },
1502 { 0x65,
"RTP IPHC Compressed non-TCP" },
1503 { 0x67,
"RTP IPHC Compressed UDP 8" },
1504 { 0x69,
"RTP IPHC Compressed RTP 8" },
1505 { 0x6f,
"Stampede Bridging" },
1507 { 0xc1,
"NTCITS IPI" },
1508 { 0xfb,
"single-link compression" },
1509 { 0xfd,
"Compressed Datagram" },
1510 { 0x0201,
"802.1d Hello Packets" },
1511 { 0x0203,
"IBM Source Routing BPDU" },
1512 { 0x0205,
"DEC LANBridge100 Spanning Tree" },
1513 { 0x0207,
"Cisco Discovery Protocol" },
1514 { 0x0209,
"Netcs Twin Routing" },
1515 { 0x020b,
"STP - Scheduled Transfer Protocol" },
1516 { 0x020d,
"EDP - Extreme Discovery Protocol" },
1517 { 0x0211,
"Optical Supervisory Channel Protocol" },
1518 { 0x0213,
"Optical Supervisory Channel Protocol" },
1519 { 0x0231,
"Luxcom" },
1520 { 0x0233,
"Sigma Network Systems" },
1521 { 0x0235,
"Apple Client Server Protocol" },
1522 { 0x0281,
"MPLS Unicast" },
1523 { 0x0283,
"MPLS Multicast" },
1524 { 0x0285,
"IEEE p1284.4 standard - data packets" },
1525 { 0x0287,
"ETSI TETRA Network Protocol Type 1" },
1526 { 0x0289,
"Multichannel Flow Treatment Protocol" },
1527 { 0x2063,
"RTP IPHC Compressed TCP No Delta" },
1528 { 0x2065,
"RTP IPHC Context State" },
1529 { 0x2067,
"RTP IPHC Compressed UDP 16" },
1530 { 0x2069,
"RTP IPHC Compressed RTP 16" },
1531 { 0x4001,
"Cray Communications Control Protocol" },
1532 { 0x4003,
"CDPD Mobile Network Registration Protocol" },
1533 { 0x4005,
"Expand accelerator protocol" },
1534 { 0x4007,
"ODSICP NCP" },
1535 { 0x4009,
"DOCSIS DLL" },
1536 { 0x400B,
"Cetacean Network Detection Protocol" },
1537 { 0x4021,
"Stacker LZS" },
1538 { 0x4023,
"RefTek Protocol" },
1539 { 0x4025,
"Fibre Channel" },
1540 { 0x4027,
"EMIT Protocols" },
1541 { 0x405b,
"Vendor-Specific Protocol (VSP)" },
1542 { 0x8021,
"Internet Protocol Control Protocol" },
1543 { 0x8023,
"OSI Network Layer Control Protocol" },
1544 { 0x8025,
"Xerox NS IDP Control Protocol" },
1545 { 0x8027,
"DECnet Phase IV Control Protocol" },
1546 { 0x8029,
"Appletalk Control Protocol" },
1547 { 0x802b,
"Novell IPX Control Protocol" },
1548 { 0x8031,
"Bridging NCP" },
1549 { 0x8033,
"Stream Protocol Control Protocol" },
1550 { 0x8035,
"Banyan Vines Control Protocol" },
1551 { 0x803d,
"Multi-Link Control Protocol" },
1552 { 0x803f,
"NETBIOS Framing Control Protocol" },
1553 { 0x8041,
"Cisco Systems Control Protocol" },
1554 { 0x8043,
"Ascom Timeplex" },
1555 { 0x8045,
"Fujitsu LBLB Control Protocol" },
1556 { 0x8047,
"DCA Remote Lan Network Control Protocol (RLNCP)" },
1557 { 0x8049,
"Serial Data Control Protocol (PPP-SDCP)" },
1558 { 0x804b,
"SNA over 802.2 Control Protocol" },
1559 { 0x804d,
"SNA Control Protocol" },
1560 { 0x804f,
"IP6 Header Compression Control Protocol" },
1561 { 0x8051,
"KNX Bridging Control Protocol" },
1562 { 0x8053,
"Encryption Control Protocol" },
1563 { 0x8055,
"Individual Link Encryption Control Protocol" },
1564 { 0x8057,
"IPv6 Control Protocol" },
1565 { 0x8059,
"PPP Muxing Control Protocol" },
1566 { 0x805b,
"Vendor-Specific Network Control Protocol (VSNCP)" },
1567 { 0x806f,
"Stampede Bridging Control Protocol" },
1568 { 0x8073,
"MP+ Control Protocol" },
1569 { 0x80c1,
"NTCITS IPI Control Protocol" },
1570 { 0x80fb,
"Single Link Compression Control Protocol" },
1571 { 0x80fd,
"Compression Control Protocol" },
1572 { 0x8207,
"Cisco Discovery Protocol Control" },
1573 { 0x8209,
"Netcs Twin Routing" },
1574 { 0x820b,
"STP - Control Protocol" },
1575 { 0x820d,
"EDPCP - Extreme Discovery Protocol Ctrl Prtcl" },
1576 { 0x8235,
"Apple Client Server Protocol Control" },
1577 { 0x8281,
"MPLSCP" },
1578 { 0x8285,
"IEEE p1284.4 standard - Protocol Control" },
1579 { 0x8287,
"ETSI TETRA TNP1 Control Protocol" },
1580 { 0x8289,
"Multichannel Flow Treatment Protocol" },
1581 { 0xc021,
"Link Control Protocol" },
1582 { 0xc023,
"Password Authentication Protocol" },
1583 { 0xc025,
"Link Quality Report" },
1584 { 0xc027,
"Shiva Password Authentication Protocol" },
1585 { 0xc029,
"CallBack Control Protocol (CBCP)" },
1586 { 0xc02b,
"BACP Bandwidth Allocation Control Protocol" },
1588 { 0xc05b,
"Vendor-Specific Authentication Protocol (VSAP)" },
1589 { 0xc081,
"Container Control Protocol" },
1590 { 0xc223,
"Challenge Handshake Authentication Protocol" },
1591 { 0xc225,
"RSA Authentication Protocol" },
1592 { 0xc227,
"Extensible Authentication Protocol" },
1593 { 0xc229,
"Mitsubishi Security Info Exch Ptcl (SIEP)" },
1594 { 0xc26f,
"Stampede Bridging Authorization Protocol" },
1595 { 0xc281,
"Proprietary Authentication Protocol" },
1596 { 0xc283,
"Proprietary Authentication Protocol" },
1597 { 0xc481,
"Proprietary Node ID Authentication Protocol" },
1604 const char * protocol_name(
int proto) {
1605 const struct protocol_list *lp;
1607 for (lp = protocol_list; lp->proto != 0; ++lp) {
1608 if (proto == lp->proto) {
1616 #if PPP_STATS_SUPPORT 1627 void reset_link_stats(
int u) {
1628 if (!get_ppp_stats(u, &old_link_stats)) {
1631 gettimeofday(&start_time, NULL);
1637 void update_link_stats(
int u) {
1641 if (!get_ppp_stats(u, &link_stats) || gettimeofday(&now, NULL) < 0) {
1644 link_connect_time = now.tv_sec - start_time.tv_sec;
1645 link_stats_valid = 1;
1647 link_stats.bytes_in -= old_link_stats.bytes_in;
1648 link_stats.bytes_out -= old_link_stats.bytes_out;
1649 link_stats.pkts_in -= old_link_stats.pkts_in;
1650 link_stats.pkts_out -= old_link_stats.pkts_out;
1653 void print_link_stats() {
1657 if (link_stats_valid) {
1658 int t = (link_connect_time + 5) / 6;
1659 info(
"Connect time %d.%d minutes.", t/10, t%10);
1660 info(
"Sent %u bytes, received %u bytes.", link_stats.bytes_out, link_stats.bytes_in);
1661 link_stats_valid = 0;
#define LWIP_MEMPOOL_INIT(name)
#define LWIP_MEMPOOL_ALLOC(name)
struct netif * netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
#define LWIP_MEMPOOL_PROTOTYPE(name)
#define LWIP_MEMPOOL_FREE(name, x)
void netif_set_link_down(struct netif *netif)
#define LWIP_MEMPOOL_DECLARE(name, num, size, desc)
void netif_remove(struct netif *netif)
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
#define LWIP_UNUSED_ARG(x)
u8_t pbuf_free(struct pbuf *p)
void netif_set_link_up(struct netif *netif)