Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib_xtcp/src/lwip_shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ xtcp_error_code_t shim_sendto(unsigned client_num, int32_t id, void* buffer_toke

xtcp_error_code_t shim_join_multicast_group(xtcp_ipaddr_t addr) {
xtcp_error_code_t result = XTCP_EINVAL;
#if LWIP_IGMP
ip_addr_t group_addr;
memcpy(&group_addr, addr, sizeof(ip_addr_t));

Expand All @@ -275,11 +276,13 @@ xtcp_error_code_t shim_join_multicast_group(xtcp_ipaddr_t addr) {
if (err == ERR_OK) {
result = XTCP_SUCCESS;
}
#endif
return result;
}

xtcp_error_code_t shim_leave_multicast_group(xtcp_ipaddr_t addr) {
xtcp_error_code_t result = XTCP_EINVAL;
#if LWIP_IGMP
ip_addr_t group_addr;
memcpy(&group_addr, addr, sizeof(ip_addr_t));

Expand All @@ -290,9 +293,18 @@ xtcp_error_code_t shim_leave_multicast_group(xtcp_ipaddr_t addr) {
if (err == ERR_OK) {
result = XTCP_SUCCESS;
}
#endif
return result;
}

int shim_is_igmp_enabled(void) {
#if LWIP_IGMP
return 1;
#else
return 0;
#endif
}

xtcp_host_t shim_request_host_by_name(unsigned client_num, const uint8_t hostname[], xtcp_ipaddr_t dns_server) {
xtcp_host_t result = { .ipaddr = {0}, .port_number = 0 };

Expand Down
1 change: 1 addition & 0 deletions lib_xtcp/src/lwip_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ xtcp_error_code_t shim_sendto(unsigned client_num, int32_t id, void* unsafe buff

xtcp_error_code_t shim_join_multicast_group(xtcp_ipaddr_t addr);
xtcp_error_code_t shim_leave_multicast_group(xtcp_ipaddr_t addr);
int shim_is_igmp_enabled(void);

xtcp_host_t shim_request_host_by_name(unsigned client_num, const uint8_t hostname[], xtcp_ipaddr_t dns_server);

Expand Down
8 changes: 8 additions & 0 deletions lib_xtcp/src/xtcp_lwip.xc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ static void ipv4_multicast_to_mac(const xtcp_ipaddr_t ipv4_addr,
macaddr_filter.appdata = 0;
}

static const xtcp_ipaddr_t all_hosts_mcast_group = {224, 0, 0, 1};

// this helper function is needed to allow null to be passed in when
// timestamps are not required (taking a pointer and casting it to unsafe
// appears to crash the compiler)
Expand Down Expand Up @@ -209,6 +211,12 @@ void xtcp_lwip(server xtcp_if i_xtcp[n_xtcp], static const unsigned n_xtcp,
memset(macaddr_filter.addr, 0xff, MACADDR_NUM_BYTES);
i_eth_cfg.add_macaddr_filter(index, 0, macaddr_filter);

if (shim_is_igmp_enabled()) {
// Add all hosts multicast group address, needed for IGMP
ipv4_multicast_to_mac(all_hosts_mcast_group, macaddr_filter);
i_eth_cfg.add_macaddr_filter(index, 0, macaddr_filter);
}

// Only allow ARP and IP packets to the stack
i_eth_cfg.add_ethertype_filter(index, ETHTYPE_ARP);
i_eth_cfg.add_ethertype_filter(index, ETHTYPE_IP);
Expand Down