EIPStackGroup / OpENer

OpENer is an EtherNet/IP stack for I/O adapter devices. It supports multiple I/O and explicit connections and includes objects and services for making EtherNet/IP-compliant products as defined in the ODVA specification.
Other
691 stars 264 forks source link

Not configured for off-subnet multicast - Endianness mismatch? #484

Open nvienhuy opened 1 year ago

nvienhuy commented 1 year ago

Hi all,

The stack rejects to open a T->O multicast cycle connection with the status: Not configured for off-subnet multicast.

During a debugging session, I noticed that it fails at the off-subnet multicast routing check during the ForwardOpenRoutine. Specifically, the originator_ip value is 0xC0A8023A (translate to 192.168.2.58), the interface_ip is 0x4202A8C0 (translate to 66.2.168.192), and the interface_mask is 0x00FFFFFF (translate to 0.255.255.255).

My machine is little-endian, and I believe the stack was developed with big-endian systems in mind.

Should I call htonl() on the originator_ip or the interface_ip and the interface_mask? And where is the appropriate place to do it?

In the NetworkHandlerInitialize() function I find the following: g_network_status.ip_address = g_tcpip.interface_configuration.ip_address; g_network_status.network_mask = g_tcpip.interface_configuration.network_mask;

Should I do it here by changing it to: g_network_status.ip_address = htonl(g_tcpip.interface_configuration.ip_address); g_network_status.network_mask = htonl(g_tcpip.interface_configuration.network_mask);

MartinMelikMerkumians commented 10 months ago

Hi,

no, the stack wasn't developed with focus on big endian. I mainly develop on a little endian machine, and I didn't had this issue. Data should be stored in the native endianess, however data transmission is a bit mixed in ENIP. Most data is sent as little endian, with the exception of TCP/IP information, which is sent in big endian.

As multicasts works for me and the CT does not complain in my tests, I would assume there is another error here.