]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
PPPoE now uses its own MEMP pool instead of the heap (moved struct pppoe_softc from...
authorgoldsimon <goldsimon>
Sun, 16 May 2010 14:34:16 +0000 (14:34 +0000)
committergoldsimon <goldsimon>
Sun, 16 May 2010 14:34:16 +0000 (14:34 +0000)
CHANGELOG
src/core/memp.c
src/include/lwip/memp_std.h
src/include/lwip/opt.h
src/include/netif/ppp_oe.h
src/netif/ppp/ppp_oe.c

index 360de32cd0661b787c889cde874655f0201573aa..46b807e656e3e820ec9aea829b3226ce59979731 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,10 @@ HISTORY
 
   ++ 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
   * opt.h, memp_std.h, dns.h/.c: DNS_LOCAL_HOSTLIST_IS_DYNAMIC uses its own
     MEMP pool instead of the heap
index d69f4b0779f2bb7a89e8670ae2cecd6c28164a17..4da879a57b46766b499ea70c1f8342302219a417 100644 (file)
@@ -57,6 +57,7 @@
 #include "lwip/snmp_structs.h"
 #include "lwip/snmp_msg.h"
 #include "lwip/dns.h"
+#include "netif/ppp_oe.h"
 
 #include <string.h>
 
index 448d6f9107cac95c157f75400b2d1c4861b4a6e0..c64f7b8835adabd0a99671b755db09d468431cad 100644 (file)
@@ -82,6 +82,9 @@ LWIP_MEMPOOL(NETDB,          MEMP_NUM_NETDB,           NETDB_ELEM_SIZE,
 #if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
 LWIP_MEMPOOL(LOCALHOSTLIST,  MEMP_NUM_LOCALHOSTLIST,   LOCALHOSTLIST_ELEM_SIZE,       "LOCALHOSTLIST")
 #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.
index 9617eaaa7747d64e4dc2899ff66706c24bc351eb..d4e74d4aa4a00ac726faac0ceafbc7b3f1ce323e 100644 (file)
 #define MEMP_NUM_LOCALHOSTLIST          1
 #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. 
  */
index 6182fad71397cf3c2ee7d55611337321302e5b05..e1cdfa51991f67b8ff1be7c425a4334a6cb79c9f 100644 (file)
@@ -140,10 +140,36 @@ PACK_STRUCT_END
 /* two byte PPP protocol discriminator, then IP data */
 #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_destroy(struct netif *ifp);
index 962a9ea8b72dbe26113f451d0baf0dec49a1d6db..5e9cbcef67ea3fb88819f6cc882cdc4a646e02f8 100644 (file)
 
 #if PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */
 
+#include "netif/ppp_oe.h"
+
 #include "ppp.h"
 #include "pppdebug.h"
 
 #include "lwip/timers.h"
-
-#include "netif/ppp_oe.h"
+#include "lwip/memp.h"
 
 #include <string.h>
 #include <stdio.h>
 #endif
 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 */
 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 */
 static struct pppoe_softc *pppoe_softc_list;
 
-void
-pppoe_init(void)
-{
-  pppoe_softc_list = NULL;
-}
-
 err_t
 pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr)
 {
   struct pppoe_softc *sc;
 
-  sc = mem_malloc(sizeof(struct pppoe_softc));
-  if(!sc) {
+  sc = (struct pppoe_softc *)memp_malloc(MEMP_PPPOE_IF);
+  if (sc == NULL) {
     *scptr = NULL;
     return ERR_MEM;
   }
@@ -232,7 +200,7 @@ pppoe_destroy(struct netif *ifp)
     mem_free(sc->sc_service_name);
   }
 #endif /* PPPOE_TODO */
-  mem_free(sc);
+  memp_free(MEMP_PPPOE_IF, sc);
 
   return ERR_OK;
 }