This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Raw sockets for ARP: protocol 0x806



I'm trying to use Raw Ethernet Sockets to implement the ARP protocol. In the Ethernet header of an ARP packet, the Type is 0x806. However, socket() returns an error if I use 0x806 for the protocol, because it thinks that's IPv6. What should I pass for the protocol parameter of socket()?

This is for the ADAS S28, SYS/BIOS 6_35_04_50, ndk_2_22_03_20.

  • Hi Tim,

    Tim Scherer said:

    I'm trying to use Raw Ethernet Sockets to implement the ARP protocol.

    The NDK already has an ARP protocol implementation, please see NDK Reference Guide Appendix A.7 (spru524i).  

    Tim Scherer said:

    In the Ethernet header of an ARP packet, the Type is 0x806. However, socket() returns an error if I use 0x806 for the protocol, because it thinks that's IPv6. 

    There is a bug in the documentation; 0x806 is the correct value for an ARP packet and 0x86DD is used for IPv6.  You can verify this in the NIMUReceivePacket function in the <NDK install dir>/packages/ti/ndk/stack/nimu/nimu.c file.  Can you elaborate on the error you are receiving?  Do you have any logs/screenshots to explain the behavior?  

    Regards,

    -- Emmanuel

  • I would love to use ARP from the NDK. Does LLIAddStaticEntry(), or another function, send ARP packets on the network to see if the given IP address is in use?

    As for my original question, it seems to be more than a documentation error. socket() returns EINVAL when protocol is 0x806 (==ETHERTYPE_IPv6). From RawEthSockPcbAttach() in rawethsock_pcb.c:

        switch (ps->Protocol)

        {
            case 0:
            case ETHERTYPE_IP:
            case ETHERTYPE_IPv6:
            case ETHERTYPE_VLAN:
            case ETHERTYPE_PPPOECTL:
            case ETHERTYPE_PPPOEDATA:
                return EINVAL;
        }

  • Hi Tim, 

    Which NIMU driver are you using with the NDK?  Can you post your socket code?

    Thanks,

    -- Emmanuel

  • You can reproduce it like this:


    SOCKET sock = socket(AF_RAWETH, SOCK_RAWETH, 0x806);

    After this, sock will be INVALID_SOCKET.

    I don't know which NIMU driver we're using, but I don't think this issue involves the driver layer - please correct me if I'm wrong.

  • Hi Tim, 

    Tim Scherer said:

    SOCKET sock = socket(AF_RAWETH, SOCK_RAWETH, 0x806);

    When using AF_RAWETH, the protocol can be set to any custom protocol type for a raw Ehternet socket.  Standard types like IP, IPv6, VLAN, PPoE Control and PPoE Data cannot be used.  Please see page 89-90 of the NDK reference guide.  

    Regards,

    -- Emmanuel

  • Hi Emmanuel,


    ARP is not one of the protocols excluded in the NDK reference guide. The NDK rejects 0x806 because it thinks incorrectly that 0x806 means IPv6. Please see RawEthSockPcbAttach() in rawethsock_pcb.c.

    Tim

  • Hi Tim,

    Thanks for the clarification.  You are correct, ETHERTYPE_IPv6 is defined as 0x806 when it should be 0x86DD.  A bug has been filed to fix this issue (SDOCM00113020).  In the meantime, you can change ETHERTYPE_IPv6 in the source and rebuild the product.  ETHERTYPE_IPv6 is defined in:

    <NDK install dir>packages/ti/ndk/inc/stack/inc/rawethif.h

    NDK rebuild instructions: http://processors.wiki.ti.com/index.php/Rebuilding_The_NDK_Core_Using_Gmake

    Regards, 

    -- Emmanuel