实现接收组播信息,需要看udp.c,udp_input 是处理接数据的函数。要实现接收组播数据,要在在lwipopts.h中定义LWIP_IGMP
void
udp_input(struct pbuf *p, struct netif *inp)
{...
if ((pcb->local_port == dest) &&
((!broadcast && ip_addr_isany(&pcb->local_ip)) ||
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)) ||
#if LWIP_IGMP
ip_addr_ismulticast(&(iphdr->dest)) ||
#endif
#if IP_SOF_BROADCAST_RECV
(broadcast && (pcb->so_options & SOF_BROADCAST)))) {
#else
(broadcast))) {
#endif
local_match = 1;
if ((uncon_pcb == NULL) &&
((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) {
uncon_pcb = pcb;
}
}
#define LWIP_IGMP 1
#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000UL)) == ntohl(0xe0000000UL))
如果在udp_input还是没有数据,从底层调用开始追溯 数据流(程序调用流程) void LwIP_Init(void) =>netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input); =>err_t ethernet_input(struct pbuf *p, struct netif *netif) =>err_t ip_input(struct pbuf *p, struct netif *inp) =>void udp_input(struct pbuf *p, struct netif *inp)
|