mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-16 05:06:54 +08:00
Replace mem_malloc call by memp_malloc, and use a new MEMP_NUM_IGMP_GROUP option (see opt.h to define the value). It will avoid potential fragmentation problems, use a counter to know how many times a group is used on an netif, and free it when all applications leave it. MEMP_NUM_IGMP_GROUP got 8 as default value (and init.c got a sanity check if LWIP_IGMP!=0).
This commit is contained in:
@@ -36,9 +36,9 @@
|
||||
#define __LWIP_IGMP_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/inet.h"
|
||||
|
||||
/* IGMP support available? */
|
||||
#if defined(LWIP_IGMP) && (LWIP_IGMP > 0)
|
||||
#if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -70,17 +70,17 @@ extern "C" {
|
||||
#define IGMP_ADD_MAC_FILTER 1
|
||||
|
||||
/* Group membership states */
|
||||
#define NON_MEMBER 0
|
||||
#define DELAYING_MEMBER 1
|
||||
#define IDLE_MEMBER 2
|
||||
#define IGMP_GROUP_NON_MEMBER 0
|
||||
#define IGMP_GROUP_DELAYING_MEMBER 1
|
||||
#define IGMP_GROUP_IDLE_MEMBER 2
|
||||
|
||||
/*
|
||||
* IGMP packet format.
|
||||
*/
|
||||
struct igmp_msg {
|
||||
u8_t igmp_msgtype;
|
||||
u8_t igmp_maxresp;
|
||||
u16_t igmp_checksum;
|
||||
u8_t igmp_msgtype;
|
||||
u8_t igmp_maxresp;
|
||||
u16_t igmp_checksum;
|
||||
struct ip_addr igmp_group_address;
|
||||
};
|
||||
|
||||
@@ -98,11 +98,12 @@ struct igmp_msg {
|
||||
|
||||
struct igmp_group {
|
||||
struct igmp_group *next;
|
||||
struct netif *interface;
|
||||
struct ip_addr group_address;
|
||||
u8_t last_reporter_flag; /* signifies we were the last person to report */
|
||||
u8_t group_state;
|
||||
u16_t timer;
|
||||
struct netif *interface;
|
||||
struct ip_addr group_address;
|
||||
u8_t last_reporter_flag; /* signifies we were the last person to report */
|
||||
u8_t group_state;
|
||||
u16_t timer;
|
||||
u8_t use; /* counter of simultaneous uses */
|
||||
};
|
||||
|
||||
|
||||
@@ -115,6 +116,8 @@ struct igmp_group *igmp_lookfor_group(struct netif *ifp, struct ip_addr *addr);
|
||||
|
||||
struct igmp_group *igmp_lookup_group(struct netif *ifp, struct ip_addr *addr);
|
||||
|
||||
err_t igmp_remove_group(struct igmp_group *group);
|
||||
|
||||
void igmp_input( struct pbuf *p, struct netif *inp, struct ip_addr *dest);
|
||||
|
||||
err_t igmp_joingroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
|
||||
@@ -125,7 +128,7 @@ void igmp_tmr(void);
|
||||
|
||||
void igmp_timeout( struct igmp_group *group);
|
||||
|
||||
void igmp_start_timer( struct igmp_group *group,u8_t max_time);
|
||||
void igmp_start_timer( struct igmp_group *group, u8_t max_time);
|
||||
|
||||
void igmp_stop_timer( struct igmp_group *group);
|
||||
|
||||
|
||||
@@ -53,6 +53,10 @@ LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg),
|
||||
LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE")
|
||||
#endif /* ARP_QUEUEING */
|
||||
|
||||
#if LWIP_IGMP
|
||||
LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP")
|
||||
#endif /* LWIP_IGMP */
|
||||
|
||||
#if NO_SYS==0
|
||||
LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT")
|
||||
#endif /* NO_SYS==0 */
|
||||
|
||||
@@ -221,6 +221,16 @@
|
||||
#define MEMP_NUM_ARP_QUEUE 30
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_IGMP_GROUP: The number of multicast groups whose network interfaces
|
||||
* can be members et the same time (one per netif - allsystems group -, plus one
|
||||
* per netif membership).
|
||||
* (requires the LWIP_IGMP option)
|
||||
*/
|
||||
#ifndef MEMP_NUM_IGMP_GROUP
|
||||
#define MEMP_NUM_IGMP_GROUP 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts.
|
||||
* (requires NO_SYS==0)
|
||||
|
||||
Reference in New Issue
Block a user