Tool/software: TI-RTOS
My program opens 2 udp sockets: port #1: ip 192.168.1.16 and port 6000 on eth0 and port #2: ip 192.168.2.33 and port 6000 and
Then it joins port #1 to a multicast group 226.10.1.7 and port #2 to a multicast group 226.10.2.7.
Both Ethernett interfaces of the board are connected to a network switch. A PC is connected to the switch too.
The wireshark only shows IGMP messages from ip 192.168.2.33. It shows 4 messages: 2 for 226.10.1.7 and 2 for 226.10.2.7. It shows no messages from ip 192.168.1.16.
Following are the functions that open the socket and join to group.
ERROR_CODES_T UDP::Open (uint32_t ipAddr, uint16_t port)
{
SOCKET sock;
struct sockaddr_in sockAddress;
int sockOption;
// Create the socket.
sock = NDK_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock == INVALID_SOCKET)
{
return EC_FAIL;
}
// Bind the port to a socket
bzero(&sockAddress, sizeof(struct sockaddr_in));
sockAddress.sin_family = AF_INET;
sockAddress.sin_port = port;
sockAddress.sin_addr.s_addr = ipAddr;
if (SOCKET_ERROR == NDK_bind(sock, (struct sockaddr *)&sockAddress, sizeof(struct sockaddr_in)))
{
return EC_FAIL;
}
// Sets the socket option for broadcast packet.
sockOption = TRUE;
if (SOCKET_ERROR == NDK_setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (void *)&sockOption, sizeof(int)))
{
return EC_FAIL;
}
// Set the buffer size for output.
sockOption = 8192;
if (SOCKET_ERROR == NDK_setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &sockOption, sizeof(int)))
{
return EC_FAIL;
}
// Set the buffer size for input.
sockOption = 8192;
if (SOCKET_ERROR == NDK_setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &sockOption, sizeof(int)))
{
return EC_FAIL;
}
// Success.
socketPtr = sock;
state = OPENED;
return EC_SUCCESS;
} // Open
ERROR_CODES_T UDP::Join (uint32_t multIpAddr)
{
struct ip_mreq mreq;
// Create the structure for the Multicast address socket options.
bzero(&mreq, sizeof(struct ip_mreq));
mreq.imr_multiaddr.s_addr = multIpAddr;
mreq.imr_interface.s_addr = LocalIpAddr();
// Join the group.
if (SOCKET_ERROR == NDK_setsockopt(socketPtr, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(struct ip_mreq)))
{
return EC_FAIL;
}
return EC_SUCCESS;
} // Join
Do you see anything wrong with the code?
Have you seen this behaviour before?
Do you have any clue?
Installed itens:
CCS 7.2
GCC ARM Compiler 4.9.3
processor_sdk_rtos_am437x 4.00.00.04
am437x PDK v1.0.7
bios 6.46.05.55
xdctools 3.32.02.25_core
Board: AM437x Starter Kit
regards,
Marcio.