mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-11 19:13:44 +00:00
task #13907: PPP cleanups: Move PPP mempools out of lwIP core to PPP code
This commit is contained in:
parent
b8b83c2994
commit
ffa340a68c
@ -61,6 +61,7 @@
|
||||
#include "lwip/api.h"
|
||||
|
||||
#include "netif/ppp/ppp_opts.h"
|
||||
#include "netif/ppp/ppp_impl.h"
|
||||
|
||||
/* Compile-time sanity checks for configuration errors.
|
||||
* These can be done independently of LWIP_DEBUG, without penalty.
|
||||
@ -346,7 +347,10 @@ lwip_init(void)
|
||||
#if LWIP_DNS
|
||||
dns_init();
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
#if PPP_SUPPORT
|
||||
ppp_init();
|
||||
#endif
|
||||
|
||||
#if LWIP_TIMERS
|
||||
sys_timeouts_init();
|
||||
#endif /* LWIP_TIMERS */
|
||||
|
@ -55,10 +55,6 @@
|
||||
#include "lwip/ip_frag.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "netif/ppp/ppp.h"
|
||||
#include "netif/ppp/pppos.h"
|
||||
#include "netif/ppp/pppoe.h"
|
||||
#include "netif/ppp/pppol2tp.h"
|
||||
#include "lwip/nd6.h"
|
||||
#include "lwip/ip6_frag.h"
|
||||
#include "lwip/mld6.h"
|
||||
|
@ -33,9 +33,6 @@
|
||||
#ifndef LWIP_HDR_MEMP_H
|
||||
#define LWIP_HDR_MEMP_H
|
||||
|
||||
/* needed by memp_std.h */
|
||||
#include "netif/ppp/ppp_opts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -94,19 +94,6 @@ LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE,
|
||||
LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST")
|
||||
#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
|
||||
#if PPP_SUPPORT
|
||||
LWIP_MEMPOOL(PPP_PCB, MEMP_NUM_PPP_PCB, sizeof(ppp_pcb), "PPP_PCB")
|
||||
#if PPPOS_SUPPORT
|
||||
LWIP_MEMPOOL(PPPOS_PCB, MEMP_NUM_PPPOS_INTERFACES, sizeof(pppos_pcb), "PPPOS_PCB")
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
#if PPPOE_SUPPORT
|
||||
LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
#if PPPOL2TP_SUPPORT
|
||||
LWIP_MEMPOOL(PPPOL2TP_PCB, MEMP_NUM_PPPOL2TP_INTERFACES, sizeof(pppol2tp_pcb), "PPPOL2TP_PCB")
|
||||
#endif /* PPPOL2TP_SUPPORT */
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
||||
#if LWIP_IPV6 && LWIP_ND6_QUEUEING
|
||||
LWIP_MEMPOOL(ND6_QUEUE, MEMP_NUM_ND6_QUEUE, sizeof(struct nd6_q_entry), "ND6_QUEUE")
|
||||
#endif /* LWIP_IPV6 && LWIP_ND6_QUEUEING */
|
||||
|
@ -378,6 +378,13 @@ struct pppd_stats {
|
||||
* PPP private functions
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Functions called from lwIP core.
|
||||
*/
|
||||
|
||||
/* initialize the PPP subsystem */
|
||||
int ppp_init(void);
|
||||
|
||||
/*
|
||||
* Functions called from PPP link protocols.
|
||||
|
@ -135,6 +135,18 @@
|
||||
/*** LOCAL DEFINITIONS ***/
|
||||
/*************************/
|
||||
|
||||
/* Memory pools */
|
||||
#if PPPOS_SUPPORT
|
||||
LWIP_MEMPOOL_PROTOTYPE(PPPOS_PCB);
|
||||
#endif
|
||||
#if PPPOE_SUPPORT
|
||||
LWIP_MEMPOOL_PROTOTYPE(PPPOE_IF);
|
||||
#endif
|
||||
#if PPPOL2TP_SUPPORT
|
||||
LWIP_MEMPOOL_PROTOTYPE(PPPOL2TP_PCB);
|
||||
#endif
|
||||
LWIP_MEMPOOL_DECLARE(PPP_PCB, MEMP_NUM_PPP_PCB, sizeof(ppp_pcb), "PPP_PCB")
|
||||
|
||||
/* FIXME: add stats per PPP session */
|
||||
#if PPP_STATS_SUPPORT
|
||||
static struct timeval start_time; /* Time when link was started. */
|
||||
@ -352,7 +364,7 @@ err_t ppp_free(ppp_pcb *pcb) {
|
||||
|
||||
err = pcb->link_cb->free(pcb, pcb->link_ctx_cb);
|
||||
|
||||
memp_free(MEMP_PPP_PCB, pcb);
|
||||
LWIP_MEMPOOL_FREE(PPP_PCB, pcb);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -561,6 +573,24 @@ err:
|
||||
/*** PRIVATE FUNCTION DEFINITIONS ***/
|
||||
/************************************/
|
||||
|
||||
/* Initialize the PPP subsystem. */
|
||||
int ppp_init(void)
|
||||
{
|
||||
#if PPPOS_SUPPORT
|
||||
LWIP_MEMPOOL_INIT(PPPOS_PCB);
|
||||
#endif
|
||||
#if PPPOE_SUPPORT
|
||||
LWIP_MEMPOOL_INIT(PPPOE_IF);
|
||||
#endif
|
||||
#if PPPOL2TP_SUPPORT
|
||||
LWIP_MEMPOOL_INIT(PPPOL2TP_PCB);
|
||||
#endif
|
||||
|
||||
LWIP_MEMPOOL_INIT(PPP_PCB);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new PPP control block.
|
||||
*
|
||||
@ -579,7 +609,7 @@ ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, vo
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pcb = (ppp_pcb*)memp_malloc(MEMP_PPP_PCB);
|
||||
pcb = (ppp_pcb*)LWIP_MEMPOOL_ALLOC(PPP_PCB);
|
||||
if (pcb == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -636,7 +666,7 @@ ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, vo
|
||||
IP4_ADDR_ANY, IP4_ADDR_BROADCAST, IP4_ADDR_ANY,
|
||||
#endif /* LWIP_IPV4 */
|
||||
(void *)pcb, ppp_netif_init_cb, NULL)) {
|
||||
memp_free(MEMP_PPP_PCB, pcb);
|
||||
LWIP_MEMPOOL_FREE(PPP_PCB, pcb);
|
||||
PPPDEBUG(LOG_ERR, ("ppp_new: netif_add failed\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -86,6 +86,9 @@
|
||||
#include "netif/ppp/ipcp.h"
|
||||
#include "netif/ppp/pppoe.h"
|
||||
|
||||
/* Memory pool */
|
||||
LWIP_MEMPOOL_DECLARE(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
|
||||
|
||||
/* Add a 16 bit unsigned value to a buffer pointed to by PTR */
|
||||
#define PPPOE_ADD_16(PTR, VAL) \
|
||||
*(PTR)++ = (u8_t)((VAL) / 256); \
|
||||
@ -174,14 +177,14 @@ ppp_pcb *pppoe_create(struct netif *pppif,
|
||||
LWIP_UNUSED_ARG(service_name);
|
||||
LWIP_UNUSED_ARG(concentrator_name);
|
||||
|
||||
sc = (struct pppoe_softc *)memp_malloc(MEMP_PPPOE_IF);
|
||||
sc = (struct pppoe_softc *)LWIP_MEMPOOL_ALLOC(PPPOE_IF);
|
||||
if (sc == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ppp = ppp_new(pppif, &pppoe_callbacks, sc, link_status_cb, ctx_cb);
|
||||
if (ppp == NULL) {
|
||||
memp_free(MEMP_PPPOE_IF, sc);
|
||||
LWIP_MEMPOOL_FREE(PPPOE_IF, sc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -306,7 +309,7 @@ pppoe_destroy(ppp_pcb *ppp, void *ctx)
|
||||
mem_free(sc->sc_service_name);
|
||||
}
|
||||
#endif /* PPPOE_TODO */
|
||||
memp_free(MEMP_PPPOE_IF, sc);
|
||||
LWIP_MEMPOOL_FREE(PPPOE_IF, sc);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -74,6 +74,9 @@
|
||||
#endif
|
||||
#endif /* PPPOL2TP_AUTH_SUPPORT */
|
||||
|
||||
/* Memory pool */
|
||||
LWIP_MEMPOOL_DECLARE(PPPOL2TP_PCB, MEMP_NUM_PPPOL2TP_INTERFACES, sizeof(pppol2tp_pcb), "PPPOL2TP_PCB")
|
||||
|
||||
/* callbacks called from PPP core */
|
||||
static err_t pppol2tp_write(ppp_pcb *ppp, void *ctx, struct pbuf *p);
|
||||
static err_t pppol2tp_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *p, u_short protocol);
|
||||
@ -124,7 +127,7 @@ ppp_pcb *pppol2tp_create(struct netif *pppif,
|
||||
goto ipaddr_check_failed;
|
||||
}
|
||||
|
||||
l2tp = (pppol2tp_pcb *)memp_malloc(MEMP_PPPOL2TP_PCB);
|
||||
l2tp = (pppol2tp_pcb *)LWIP_MEMPOOL_ALLOC(PPPOL2TP_PCB);
|
||||
if (l2tp == NULL) {
|
||||
goto memp_malloc_l2tp_failed;
|
||||
}
|
||||
@ -157,7 +160,7 @@ ppp_pcb *pppol2tp_create(struct netif *pppif,
|
||||
ppp_new_failed:
|
||||
udp_remove(udp);
|
||||
udp_new_failed:
|
||||
memp_free(MEMP_PPPOL2TP_PCB, l2tp);
|
||||
LWIP_MEMPOOL_FREE(PPPOL2TP_PCB, l2tp);
|
||||
memp_malloc_l2tp_failed:
|
||||
ipaddr_check_failed:
|
||||
return NULL;
|
||||
@ -254,7 +257,7 @@ static err_t pppol2tp_destroy(ppp_pcb *ppp, void *ctx) {
|
||||
if (l2tp->udp != NULL) {
|
||||
udp_remove(l2tp->udp);
|
||||
}
|
||||
memp_free(MEMP_PPPOL2TP_PCB, l2tp);
|
||||
LWIP_MEMPOOL_FREE(PPPOL2TP_PCB, l2tp);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,9 @@
|
||||
#include "netif/ppp/pppos.h"
|
||||
#include "netif/ppp/vj.h"
|
||||
|
||||
/* Memory pool */
|
||||
LWIP_MEMPOOL_DECLARE(PPPOS_PCB, MEMP_NUM_PPPOS_INTERFACES, sizeof(pppos_pcb), "PPPOS_PCB")
|
||||
|
||||
/* callbacks called from PPP core */
|
||||
static err_t pppos_write(ppp_pcb *ppp, void *ctx, struct pbuf *p);
|
||||
static err_t pppos_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *pb, u16_t protocol);
|
||||
@ -173,14 +176,14 @@ ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb,
|
||||
pppos_pcb *pppos;
|
||||
ppp_pcb *ppp;
|
||||
|
||||
pppos = (pppos_pcb *)memp_malloc(MEMP_PPPOS_PCB);
|
||||
pppos = (pppos_pcb *)LWIP_MEMPOOL_ALLOC(PPPOS_PCB);
|
||||
if (pppos == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ppp = ppp_new(pppif, &pppos_callbacks, pppos, link_status_cb, ctx_cb);
|
||||
if (ppp == NULL) {
|
||||
memp_free(MEMP_PPPOS_PCB, pppos);
|
||||
LWIP_MEMPOOL_FREE(PPPOS_PCB, pppos);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -421,7 +424,7 @@ pppos_destroy(ppp_pcb *ppp, void *ctx)
|
||||
pppos_input_free_current_packet(pppos);
|
||||
#endif /* PPP_INPROC_IRQ_SAFE */
|
||||
|
||||
memp_free(MEMP_PPPOS_PCB, pppos);
|
||||
LWIP_MEMPOOL_FREE(PPPOS_PCB, pppos);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user