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.

Using LLIAddStaticEntry to set Static MAC for NDK

Hi,

I am using CCSV4 with SYS/BIOS 6.30.02.42 and NDK 2.20.04.26 on the EVMC6472.  I am trying to set the default IP address for a given MAC so that ARP's will not be needed to connect to the external device and communicate using UDP.  The call to LLIAddStaticEntry() always returns -1, indicating an error and I'm not sure why.  I call the function as follows:

UINT8 myMAC[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};

char * myIPAddr = "195.162.1.50";

tmp = LLIAddStaticEntry(myIPAddr, myMAC);

It looks like the function call gets hung up in RtCreate() at line 543 of lli.c before returning with an error.  The return value of RtCreate() indicates an error.  I am calling this function within the network start function specified by the pfnStart argument to NC_NetStart().  Therefore, BIOS has already started and all the network configuration steps are complete.

Any suggestions as to why I cannot set a static ARP entry?

Nick

 

  • Nick,

    You may want to try doing this via the NDK's configuration API "CfgAddEntry()".  It should be something like the following:

            bzero(&RT, sizeof(RT));
            RT.IPDestAddr = 0;
            RT.IPDestMask = 0;
            RT.IPGateAddr = inet_addr("195.162.1.50");

            CfgAddEntry(hCfg, CFGTAG_ROUTE, 0, 0,
                    sizeof(CI_ROUTE), (UINT8 *)&RT, 0);

    You can find out more about the NDK's configuration in the document "spru524_pg.pdf".

    Steve

  • Steve,

    I want to make sure I'm getting the correct function call setup in doing this.  I'm thinking I will want something more along the lines of:

            bzero(&RT, sizeof(RT));
            RT.IPDestAddr = inet_addr(195.162.1.50); // the desired destination IP address
            RT.IPDestMask = 0xffffffff; // mask to show this is a host route (from host to some destination)
            RT.IPGateAddr = inet_addr(LocalIPAddr); // the DSP's IP address 

    Then the same CfgAddEntry() call as you mentioned above. 

    However, this doesn't set the MAC address for the given destination. To clarify, I know the IP address and MAC of a destination.  These are static and will not change; therefore I want to add an entry to the NDK's ARP table specifying these values and preempting an actual ARP being sent.  I was looking to the LLIAddStaticEntry() function at first since it sets both the MAC and IP address for a given destination.  I noticed that CFGTAG_CLIENT for CfgAddEntry() has a MacAddr field but I'm not sure I need all the DHCP/DNS support that the programmer's guide mentions.

    Does CfgAddEntry() need to be called to add a route before LLIAddStaticEntry() will return without an error?

    Nick

     

  • Nick,

    I may have jumped the gun about the call to CfgAddEntry().  You should be able to call LLIAddStaticEntry() how you want.  I think the next step here is to debug the RtCreate() call and determine why it's failing.

    Can you put breakpoints in the function RtCreate(), in the file src/stack/route/route.c, at each of the places where it returns 0?  And see which one it's hitting?

    Also, there's an example of calling LLIAddStaticEntry() in the code for the NDK's telnet console.  Looking at this may help you to see why this one works, but your is not working.  You can find it in the file src/tools/console/conlli.c at line 150:

     

                if( !LLIAddStaticEntry( in1.s_addr, mac_address ) )

    Steve

  • Nick,

    Just wanted to check in on this one.  Were you ever able to try this?

    Steve

  • Steve,

    I found the source of the problem was calling LLIAddStaticEntry() as follows:

    myIPAddr = "195.162.1.50";
    myMAC = {0x00, 0x01, 0x00, 0xca, 0x0b, 0x80};
    LLIAddStaticEntry(myIPAddr, myMAC);   

    I forgot to call inet_addr(myIPAddr) and therefore all the lower level functions returned with errors since the IP address wasn't valid.  LLIAddStaticEntry() works fine now and returns 0 as expected.

    Thanks!

    Nick

     

  • Great news, no problem!

    Steve