diff --git a/srcs/lwip/src/arch_linux/include/lwipopts.h b/srcs/lwip/src/arch_linux/include/lwipopts.h index 588902a..7a5ba53 100644 --- a/srcs/lwip/src/arch_linux/include/lwipopts.h +++ b/srcs/lwip/src/arch_linux/include/lwipopts.h @@ -146,7 +146,7 @@ * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. * (requires NO_SYS==0) */ -#define MEMP_NUM_SYS_TIMEOUT 8 +#define MEMP_NUM_SYS_TIMEOUT 320 /** * MEMP_NUM_NETBUF: the number of struct netbufs. @@ -177,7 +177,7 @@ /** * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ -#define PBUF_POOL_SIZE 8 +#define PBUF_POOL_SIZE 320 /* --------------------------------- diff --git a/srcs/lwip/src/core/netif.c b/srcs/lwip/src/core/netif.c index 088b50e..da3850a 100644 --- a/srcs/lwip/src/core/netif.c +++ b/srcs/lwip/src/core/netif.c @@ -390,14 +390,14 @@ netif_add(struct netif *netif, struct netif *netif2; int num_netifs; do { - if (netif->num == 255) { + if (netif->num == USHRT_MAX) { netif->num = 0; } num_netifs = 0; for (netif2 = netif_list; netif2 != NULL; netif2 = netif2->next) { LWIP_ASSERT("netif already added", netif2 != netif); num_netifs++; - LWIP_ASSERT("too many netifs, max. supported number is 255", num_netifs <= 255); + LWIP_ASSERT("too many netifs, max. supported number is 255", num_netifs <= (USHRT_MAX)); if (netif2->num == netif->num) { netif->num++; break; @@ -405,10 +405,10 @@ netif_add(struct netif *netif, } } while (netif2 != NULL); } - if (netif->num == 254) { + if (netif->num == USHRT_MAX - 1) { netif_num = 0; } else { - netif_num = (u8_t)(netif->num + 1); + netif_num = (u16_t)(netif->num + 1); } /* add this netif to the list */ @@ -1651,8 +1651,7 @@ netif_null_output_ip4(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipa * * @param name the name of the netif */ -u8_t -netif_name_to_index(const char *name) +u16_t netif_name_to_index(const char *name) { struct netif *netif = netif_find(name); if (netif != NULL) { @@ -1691,7 +1690,7 @@ netif_index_to_name(u8_t idx, char *name) * @param idx index of netif to find */ struct netif * -netif_get_by_index(u8_t idx) +netif_get_by_index(u16_t idx) { struct netif *netif; diff --git a/srcs/lwip/src/include/lwip/ip.h b/srcs/lwip/src/include/lwip/ip.h index 653c3b2..4bfc86e 100644 --- a/srcs/lwip/src/include/lwip/ip.h +++ b/srcs/lwip/src/include/lwip/ip.h @@ -78,7 +78,7 @@ extern "C" { ip_addr_t local_ip; \ ip_addr_t remote_ip; \ /* Bound netif index */ \ - u8_t netif_idx; \ + u16_t netif_idx; \ /* Socket options */ \ u8_t so_options; \ /* Type Of Service */ \ diff --git a/srcs/lwip/src/include/lwip/netif.h b/srcs/lwip/src/include/lwip/netif.h index 9a16ded..f972329 100644 --- a/srcs/lwip/src/include/lwip/netif.h +++ b/srcs/lwip/src/include/lwip/netif.h @@ -347,7 +347,7 @@ struct netif { char name[2]; /** number of this interface. Used for @ref if_api and @ref netifapi_netif, * as well as for IPv6 zones */ - u8_t num; + u16_t num; #if LWIP_IPV6_AUTOCONFIG /** is this netif enabled for IPv6 autoconfiguration */ u8_t ip6_autoconfig_enabled; @@ -552,12 +552,12 @@ err_t netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t #define NETIF_RESET_HINTS(netif) #endif /* LWIP_NETIF_USE_HINTS */ -u8_t netif_name_to_index(const char *name); +u16_t netif_name_to_index(const char *name); char * netif_index_to_name(u8_t idx, char *name); -struct netif* netif_get_by_index(u8_t idx); +struct netif* netif_get_by_index(u16_t idx); -/* Interface indexes always start at 1 per RFC 3493, section 4, num starts at 0 (internal index is 0..254)*/ -#define netif_get_index(netif) ((u8_t)((netif)->num + 1)) +/* Interface indexes always start at 1 per RFC 3493, section 4, num starts at 0 (internal index is 0..65535)*/ +#define netif_get_index(netif) ((u16_t)((netif)->num + 1)) #define NETIF_NO_INDEX (0) /** diff --git a/srcs/lwip/src/include/lwip/pbuf.h b/srcs/lwip/src/include/lwip/pbuf.h index e5daf96..72cf3c9 100644 --- a/srcs/lwip/src/include/lwip/pbuf.h +++ b/srcs/lwip/src/include/lwip/pbuf.h @@ -218,7 +218,7 @@ struct pbuf { LWIP_PBUF_REF_T ref; /** For incoming packets, this contains the input netif's index */ - u8_t if_idx; + u16_t if_idx; /** In case the user needs to store data custom data on a pbuf */ LWIP_PBUF_CUSTOM_DATA diff --git a/srcs/lwip/src/netif/ppp/ppp.c b/srcs/lwip/src/netif/ppp/ppp.c index bc125eb..9f71771 100644 --- a/srcs/lwip/src/netif/ppp/ppp.c +++ b/srcs/lwip/src/netif/ppp/ppp.c @@ -277,7 +277,7 @@ err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff) { return ERR_ALREADY; } - PPPDEBUG(LOG_DEBUG, ("ppp_connect[%d]: holdoff=%d\n", pcb->netif->num, holdoff)); + PPPDEBUG(LOG_DEBUG, ("ppp_connect[%u]: holdoff=%d\n", pcb->netif->num, holdoff)); magic_randomize(); @@ -369,7 +369,7 @@ ppp_close(ppp_pcb *pcb, u8_t nocarrier) * take a little longer time, but is a safer choice from FSM point of view. */ if (nocarrier && pcb->phase == PPP_PHASE_RUNNING) { - PPPDEBUG(LOG_DEBUG, ("ppp_close[%d]: carrier lost -> lcp_lowerdown\n", pcb->netif->num)); + PPPDEBUG(LOG_DEBUG, ("ppp_close[%u]: carrier lost -> lcp_lowerdown\n", pcb->netif->num)); lcp_lowerdown(pcb); /* forced link termination, this will force link protocol to disconnect. */ link_terminated(pcb); @@ -377,7 +377,7 @@ ppp_close(ppp_pcb *pcb, u8_t nocarrier) } /* Disconnect */ - PPPDEBUG(LOG_DEBUG, ("ppp_close[%d]: kill_link -> lcp_close\n", pcb->netif->num)); + PPPDEBUG(LOG_DEBUG, ("ppp_close[%u]: kill_link -> lcp_close\n", pcb->netif->num)); /* LCP soft close request. */ lcp_close(pcb, "User request"); return ERR_OK; @@ -400,7 +400,7 @@ err_t ppp_free(ppp_pcb *pcb) { return ERR_CONN; } - PPPDEBUG(LOG_DEBUG, ("ppp_free[%d]\n", pcb->netif->num)); + PPPDEBUG(LOG_DEBUG, ("ppp_free[%u]\n", pcb->netif->num)); netif_remove(pcb->netif); @@ -518,7 +518,7 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc || (protocol == PPP_IPV6 && !pcb->if6_up) #endif /* PPP_IPV6_SUPPORT */ ) { - PPPDEBUG(LOG_ERR, ("ppp_netif_output[%d]: link not up\n", pcb->netif->num)); + PPPDEBUG(LOG_ERR, ("ppp_netif_output[%u]: link not up\n", pcb->netif->num)); goto err_rte_drop; } @@ -726,7 +726,7 @@ ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, vo /** Initiate LCP open request */ void ppp_start(ppp_pcb *pcb) { - PPPDEBUG(LOG_DEBUG, ("ppp_start[%d]\n", pcb->netif->num)); + PPPDEBUG(LOG_DEBUG, ("ppp_start[%u]\n", pcb->netif->num)); /* Clean data not taken care by anything else, mostly shared data. */ #if PPP_STATS_SUPPORT @@ -745,12 +745,12 @@ void ppp_start(ppp_pcb *pcb) { new_phase(pcb, PPP_PHASE_ESTABLISH); lcp_open(pcb); lcp_lowerup(pcb); - PPPDEBUG(LOG_DEBUG, ("ppp_start[%d]: finished\n", pcb->netif->num)); + PPPDEBUG(LOG_DEBUG, ("ppp_start[%u]: finished\n", pcb->netif->num)); } /** Called when link failed to setup */ void ppp_link_failed(ppp_pcb *pcb) { - PPPDEBUG(LOG_DEBUG, ("ppp_link_failed[%d]\n", pcb->netif->num)); + PPPDEBUG(LOG_DEBUG, ("ppp_link_failed[%u]\n", pcb->netif->num)); new_phase(pcb, PPP_PHASE_DEAD); pcb->err_code = PPPERR_OPEN; pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb); @@ -758,7 +758,7 @@ void ppp_link_failed(ppp_pcb *pcb) { /** Called when link is normally down (i.e. it was asked to end) */ void ppp_link_end(ppp_pcb *pcb) { - PPPDEBUG(LOG_DEBUG, ("ppp_link_end[%d]\n", pcb->netif->num)); + PPPDEBUG(LOG_DEBUG, ("ppp_link_end[%u]\n", pcb->netif->num)); new_phase(pcb, PPP_PHASE_DEAD); if (pcb->err_code == PPPERR_NONE) { pcb->err_code = PPPERR_CONNECT; @@ -779,7 +779,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) { magic_randomize(); if (pb->len < 2) { - PPPDEBUG(LOG_ERR, ("ppp_input[%d]: packet too short\n", pcb->netif->num)); + PPPDEBUG(LOG_ERR, ("ppp_input[%u]: packet too short\n", pcb->netif->num)); goto drop; } protocol = (((u8_t *)pb->payload)[0] << 8) | ((u8_t*)pb->payload)[1]; @@ -876,7 +876,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) { #if PPP_IPV4_SUPPORT case PPP_IP: /* Internet Protocol */ - PPPDEBUG(LOG_INFO, ("ppp_input[%d]: ip in pbuf len=%d\n", pcb->netif->num, pb->tot_len)); + PPPDEBUG(LOG_INFO, ("ppp_input[%u]: ip in pbuf len=%d\n", pcb->netif->num, pb->tot_len)); ip4_input(pb, pcb->netif); return; #endif /* PPP_IPV4_SUPPORT */ @@ -962,7 +962,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) { ppp_warn("Unsupported protocol 0x%x received", protocol); #endif /* PPP_DEBUG */ if (pbuf_add_header(pb, sizeof(protocol))) { - PPPDEBUG(LOG_WARNING, ("ppp_input[%d]: Dropping (pbuf_add_header failed)\n", pcb->netif->num)); + PPPDEBUG(LOG_WARNING, ("ppp_input[%u]: Dropping (pbuf_add_header failed)\n", pcb->netif->num)); goto drop; } lcp_sprotrej(pcb, (u8_t*)pb->payload, pb->len); @@ -994,9 +994,9 @@ err_t ppp_write(ppp_pcb *pcb, struct pbuf *p) { } void ppp_link_terminated(ppp_pcb *pcb) { - PPPDEBUG(LOG_DEBUG, ("ppp_link_terminated[%d]\n", pcb->netif->num)); + PPPDEBUG(LOG_DEBUG, ("ppp_link_terminated[%u]\n", pcb->netif->num)); pcb->link_cb->disconnect(pcb, pcb->link_ctx_cb); - PPPDEBUG(LOG_DEBUG, ("ppp_link_terminated[%d]: finished.\n", pcb->netif->num)); + PPPDEBUG(LOG_DEBUG, ("ppp_link_terminated[%u]: finished.\n", pcb->netif->num)); } @@ -1010,7 +1010,7 @@ void ppp_link_terminated(ppp_pcb *pcb) { */ void new_phase(ppp_pcb *pcb, int p) { pcb->phase = p; - PPPDEBUG(LOG_DEBUG, ("ppp phase changed[%d]: phase=%d\n", pcb->netif->num, pcb->phase)); + PPPDEBUG(LOG_DEBUG, ("ppp phase changed[%u]: phase=%d\n", pcb->netif->num, pcb->phase)); #if PPP_NOTIFY_PHASE if (pcb->notify_phase_cb != NULL) { pcb->notify_phase_cb(pcb, p, pcb->ctx_cb); @@ -1030,7 +1030,7 @@ int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp) { pcb->link_cb->send_config(pcb, pcb->link_ctx_cb, accm, pcomp, accomp); } - PPPDEBUG(LOG_INFO, ("ppp_send_config[%d]\n", pcb->netif->num) ); + PPPDEBUG(LOG_INFO, ("ppp_send_config[%u]\n", pcb->netif->num) ); return 0; } @@ -1045,7 +1045,7 @@ int ppp_recv_config(ppp_pcb *pcb, int mru, u32_t accm, int pcomp, int accomp) { pcb->link_cb->recv_config(pcb, pcb->link_ctx_cb, accm, pcomp, accomp); } - PPPDEBUG(LOG_INFO, ("ppp_recv_config[%d]\n", pcb->netif->num)); + PPPDEBUG(LOG_INFO, ("ppp_recv_config[%u]\n", pcb->netif->num)); return 0; } @@ -1161,7 +1161,7 @@ int sifup(ppp_pcb *pcb) { pcb->err_code = PPPERR_NONE; netif_set_link_up(pcb->netif); - PPPDEBUG(LOG_DEBUG, ("sifup[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code)); + PPPDEBUG(LOG_DEBUG, ("sifup[%u]: err_code=%d\n", pcb->netif->num, pcb->err_code)); pcb->link_status_cb(pcb, pcb->err_code, pcb->ctx_cb); return 1; } @@ -1184,7 +1184,7 @@ int sifdown(ppp_pcb *pcb) { /* make sure the netif link callback is called */ netif_set_link_down(pcb->netif); } - PPPDEBUG(LOG_DEBUG, ("sifdown[%d]: err_code=%d\n", pcb->netif->num, pcb->err_code)); + PPPDEBUG(LOG_DEBUG, ("sifdown[%u]: err_code=%d\n", pcb->netif->num, pcb->err_code)); return 1; } @@ -1315,7 +1315,7 @@ int sifnpmode(ppp_pcb *pcb, int proto, enum NPmode mode) { void netif_set_mtu(ppp_pcb *pcb, int mtu) { pcb->netif->mtu = mtu; - PPPDEBUG(LOG_INFO, ("netif_set_mtu[%d]: mtu=%d\n", pcb->netif->num, mtu)); + PPPDEBUG(LOG_INFO, ("netif_set_mtu[%u]: mtu=%d\n", pcb->netif->num, mtu)); } /* diff --git a/srcs/pppoe/vcpe_pppoe.c b/srcs/pppoe/vcpe_pppoe.c index 4b4e67b..78a4d75 100644 --- a/srcs/pppoe/vcpe_pppoe.c +++ b/srcs/pppoe/vcpe_pppoe.c @@ -305,7 +305,7 @@ int pppoe_session_create(PUSER_INFO_CONTEXT pUser) { ppp_set_auth(ppp, PPPAUTHTYPE_ANY, pUser->user_info.pppoe_user, pUser->user_info.pppoe_passwd); - dzlog_debug("Create PPPoE netif %p: %u(%c%c:%d, %c%c:%d)\n", + dzlog_debug("Create PPPoE netif %p: %u(%c%c:%u, %c%c:%u)\n", ppp, pUser->userid, ppp_netif->name[0],