mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-01 04:12:07 +00:00
PPPoE now uses its own MEMP pool instead of the heap (moved struct pppoe_softc from ppp_oe.c to ppp_oe.h)
This commit is contained in:
parent
16434568b0
commit
5d0785e47a
@ -13,6 +13,10 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2010-05-16: Simon Goldschmidt
|
||||||
|
* opt.h, memp_std.h, memp.c, ppp_oe.h/.c: PPPoE now uses its own MEMP pool
|
||||||
|
instead of the heap (moved struct pppoe_softc from ppp_oe.c to ppp_oe.h)
|
||||||
|
|
||||||
2010-05-16: Simon Goldschmidt
|
2010-05-16: Simon Goldschmidt
|
||||||
* opt.h, memp_std.h, dns.h/.c: DNS_LOCAL_HOSTLIST_IS_DYNAMIC uses its own
|
* opt.h, memp_std.h, dns.h/.c: DNS_LOCAL_HOSTLIST_IS_DYNAMIC uses its own
|
||||||
MEMP pool instead of the heap
|
MEMP pool instead of the heap
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
#include "lwip/snmp_structs.h"
|
#include "lwip/snmp_structs.h"
|
||||||
#include "lwip/snmp_msg.h"
|
#include "lwip/snmp_msg.h"
|
||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
|
#include "netif/ppp_oe.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -82,6 +82,9 @@ LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE,
|
|||||||
#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||||
LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST")
|
LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST")
|
||||||
#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||||
|
#if PPP_SUPPORT && PPPOE_SUPPORT
|
||||||
|
LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
|
||||||
|
#endif /* PPP_SUPPORT && PPPOE_SUPPORT */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A list of pools of pbuf's used by LWIP.
|
* A list of pools of pbuf's used by LWIP.
|
||||||
|
@ -378,6 +378,14 @@
|
|||||||
#define MEMP_NUM_LOCALHOSTLIST 1
|
#define MEMP_NUM_LOCALHOSTLIST 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE
|
||||||
|
* interfaces (only used with PPPOE_SUPPORT==1)
|
||||||
|
*/
|
||||||
|
#ifndef MEMP_NUM_PPPOE_INTERFACES
|
||||||
|
#define MEMP_NUM_PPPOE_INTERFACES 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
|
* PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
|
||||||
*/
|
*/
|
||||||
|
@ -140,10 +140,36 @@ PACK_STRUCT_END
|
|||||||
/* two byte PPP protocol discriminator, then IP data */
|
/* two byte PPP protocol discriminator, then IP data */
|
||||||
#define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2)
|
#define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2)
|
||||||
|
|
||||||
struct pppoe_softc;
|
#ifndef PPPOE_MAX_AC_COOKIE_LEN
|
||||||
|
#define PPPOE_MAX_AC_COOKIE_LEN 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct pppoe_softc {
|
||||||
|
struct pppoe_softc *next;
|
||||||
|
struct netif *sc_ethif; /* ethernet interface we are using */
|
||||||
|
int sc_pd; /* ppp unit number */
|
||||||
|
void (*sc_linkStatusCB)(int pd, int up);
|
||||||
|
|
||||||
|
int sc_state; /* discovery phase or session connected */
|
||||||
|
struct eth_addr sc_dest; /* hardware address of concentrator */
|
||||||
|
u16_t sc_session; /* PPPoE session id */
|
||||||
|
|
||||||
|
#ifdef PPPOE_TODO
|
||||||
|
char *sc_service_name; /* if != NULL: requested name of service */
|
||||||
|
char *sc_concentrator_name; /* if != NULL: requested concentrator id */
|
||||||
|
#endif /* PPPOE_TODO */
|
||||||
|
u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
|
||||||
|
size_t sc_ac_cookie_len; /* length of cookie data */
|
||||||
|
#ifdef PPPOE_SERVER
|
||||||
|
u8_t *sc_hunique; /* content of host unique we must echo back */
|
||||||
|
size_t sc_hunique_len; /* length of host unique */
|
||||||
|
#endif
|
||||||
|
int sc_padi_retried; /* number of PADI retries already done */
|
||||||
|
int sc_padr_retried; /* number of PADR retries already done */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void pppoe_init(void);
|
#define pppoe_init() /* compatibility define, no initialization needed */
|
||||||
|
|
||||||
err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
|
err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
|
||||||
err_t pppoe_destroy(struct netif *ifp);
|
err_t pppoe_destroy(struct netif *ifp);
|
||||||
|
@ -72,12 +72,13 @@
|
|||||||
|
|
||||||
#if PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
#if PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
|
#include "netif/ppp_oe.h"
|
||||||
|
|
||||||
#include "ppp.h"
|
#include "ppp.h"
|
||||||
#include "pppdebug.h"
|
#include "pppdebug.h"
|
||||||
|
|
||||||
#include "lwip/timers.h"
|
#include "lwip/timers.h"
|
||||||
|
#include "lwip/memp.h"
|
||||||
#include "netif/ppp_oe.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -111,33 +112,6 @@
|
|||||||
#endif
|
#endif
|
||||||
static char pppoe_error_tmp[PPPOE_ERRORSTRING_LEN];
|
static char pppoe_error_tmp[PPPOE_ERRORSTRING_LEN];
|
||||||
|
|
||||||
#ifndef PPPOE_MAX_AC_COOKIE_LEN
|
|
||||||
#define PPPOE_MAX_AC_COOKIE_LEN 64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct pppoe_softc {
|
|
||||||
struct pppoe_softc *next;
|
|
||||||
struct netif *sc_ethif; /* ethernet interface we are using */
|
|
||||||
int sc_pd; /* ppp unit number */
|
|
||||||
void (*sc_linkStatusCB)(int pd, int up);
|
|
||||||
|
|
||||||
int sc_state; /* discovery phase or session connected */
|
|
||||||
struct eth_addr sc_dest; /* hardware address of concentrator */
|
|
||||||
u16_t sc_session; /* PPPoE session id */
|
|
||||||
|
|
||||||
#ifdef PPPOE_TODO
|
|
||||||
char *sc_service_name; /* if != NULL: requested name of service */
|
|
||||||
char *sc_concentrator_name; /* if != NULL: requested concentrator id */
|
|
||||||
#endif /* PPPOE_TODO */
|
|
||||||
u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
|
|
||||||
size_t sc_ac_cookie_len; /* length of cookie data */
|
|
||||||
#ifdef PPPOE_SERVER
|
|
||||||
u8_t *sc_hunique; /* content of host unique we must echo back */
|
|
||||||
size_t sc_hunique_len; /* length of host unique */
|
|
||||||
#endif
|
|
||||||
int sc_padi_retried; /* number of PADI retries already done */
|
|
||||||
int sc_padr_retried; /* number of PADR retries already done */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* input routines */
|
/* input routines */
|
||||||
static void pppoe_dispatch_disc_pkt(struct netif *, struct pbuf *);
|
static void pppoe_dispatch_disc_pkt(struct netif *, struct pbuf *);
|
||||||
@ -166,19 +140,13 @@ static struct pppoe_softc * pppoe_find_softc_by_hunique(u8_t *, size_t, struct n
|
|||||||
/** linked list of created pppoe interfaces */
|
/** linked list of created pppoe interfaces */
|
||||||
static struct pppoe_softc *pppoe_softc_list;
|
static struct pppoe_softc *pppoe_softc_list;
|
||||||
|
|
||||||
void
|
|
||||||
pppoe_init(void)
|
|
||||||
{
|
|
||||||
pppoe_softc_list = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
err_t
|
err_t
|
||||||
pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr)
|
pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr)
|
||||||
{
|
{
|
||||||
struct pppoe_softc *sc;
|
struct pppoe_softc *sc;
|
||||||
|
|
||||||
sc = mem_malloc(sizeof(struct pppoe_softc));
|
sc = (struct pppoe_softc *)memp_malloc(MEMP_PPPOE_IF);
|
||||||
if(!sc) {
|
if (sc == NULL) {
|
||||||
*scptr = NULL;
|
*scptr = NULL;
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
@ -232,7 +200,7 @@ pppoe_destroy(struct netif *ifp)
|
|||||||
mem_free(sc->sc_service_name);
|
mem_free(sc->sc_service_name);
|
||||||
}
|
}
|
||||||
#endif /* PPPOE_TODO */
|
#endif /* PPPOE_TODO */
|
||||||
mem_free(sc);
|
memp_free(MEMP_PPPOE_IF, sc);
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user