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.

TM4C1294NCPDT: Set Static IP address to "0.0.0.0"

Part Number: TM4C1294NCPDT

Hi.

I'm using TM4C1294NCPDT with TI-RTOS and NDK.

How can I set Static IP address to "0.0.0.0"?

When I set any IP address(e.g. "0.0.0.1") except of "0.0.0.0" I get:

and my device send UDP packets to network. 

But if I set "0.0.0.0", I get:

and my device doesn't send any packets.

Thanks in advance.

  • Hi,

     What is the reason you want to configure the IP address to 0.0.0.0? The 0.0.0.0 has special and different meaning depending on if you are a client or a server or a router. I think the below articles have some explanation. I will suggest you not use 0.0.0.0 in your network. You might also want to talk to your IT department if 0.0.0.0 is ok to use on your network. 

    https://www.howtogeek.com/225487/what-is-the-difference-between-127.0.0.1-and-0.0.0.0/

    https://en.wikipedia.org/wiki/0.0.0.0

  • Hi Charles.

    Thank you for response.

    We use some kind of "DHCP" in our own application for communication our consoles(computers) with different additional controllers. The DHCP that we use is slightly different from the standard DHCP. We use this method over 15 years with different kind of controllers and never had a problem. The question is, can we in some way to set IP to "0.0.0.0" on TM4C1294NCPDT controller?

     

    “You might also want to talk to your IT department if 0.0.0.0 is ok to use on your network.”

    How can I do this?

    Regards.

  • Hi IgDor,

     I'm not a TI-RTOS NDK expert. What might have happened is that the 0.0.0.0 is reserved for use as the gateway IP address which is typical in a network. I will need to check with our TI-RTOS expert. 

  • Thanks in advance.

  • Hi Charles.

    Any news about my question?

    Regards.

  • Hi IgDor,

      I had forwarded your question to our NDK expert. 

  • Hi IgDor,

    As Charles already pointed out to you, address 0.0.0.0 is a special address, and isn't really a valid address to be assigned to a host (except for some special cases, e.g. when a host is trying to obtain an IP address from a DHCP server).

    Anyway, it sounds like you want to use some custom version of DHCP, in order to get the IP address for your device?

    One option may be to not assign _any_ IP address to the device. You can do this by setting the IP address to be "none" in your configuration file.

    So, in this case your app won't run as a DHCP client (the NDK's DHCP client), and so won't try to obtain the IP address from a DHCP server in the "normal way."

    You could instead run the code to get the IP address from your customized DHCP server, however you might do it, and then once you have an IP address offer, you could add it as a static IP address on the device.

    Steve

  • Hi Steve.
    Thank you for response.

    I tried to, as you advised, set "none" as IP address:

    Unfortunately, in this case the Tiva doesn't send any message.

    If I marked the box "Obtain IP address automatically", the Tiva only  send the standard DHCP message from 0.0.0.0 address , but not any others  messages.

    If I set any others IP addresses(except of 0.0.0.0) e.g. 0.0.0.1 the Tiva starts to send our message.

    As I noted earlier we use our own kind of "DHCP". Earlier we used separate Ethernet controllers(e.g. W5100), and didn't have a problem.

    Is there some way to set IP 0.0.0.0 in TI NDK?

    Thanks in advance.

  • Steve is out of the office this week. He'll get back to you next week.

    Todd

  • Hi IgDor,

    I dug into this more today and I can now see that trying to assign an IP address of 0.0.0.0 is explicitly disallowed by the NDK stack. This can be seen in the NtAddNetwork() function, which is where an IP address is attempted to be bound:

    void *NtAddNetwork( void *hIF, uint32_t dwIP, uint32_t dwIPMask )
    {
    
    ...
        IPTrialAddress = dwIP; <- sets trial addr to 0.0.0.0
    
        /* Create the Binding */
        hBind = BindNew( hIF, dwIP, dwIPMask );
    
        /* If the binding was created successfully, test it */
        if( hBind )
        {
    ...
            /* If the global IPTrialAddress is now NULL, there was an error */
            if( !IPTrialAddress ) <- fails here since address is 0.0.0.1
            {
                /* Destroy the binding with the bad IP address */
                BindFree( hBind );
                hBind = 0;
            }
        }
    
    

    So, you cannot assign (bind) an address of zero in the NDK. The reasons for it being coded this way are most likely the same as those given by Charles in the above post.

    Steve

  • Hi Steve.
    Thank you for your answer.

    /* If the global IPTrialAddress is now NULL, there was an error */

    if( !IPTrialAddress )

    {…..

    Can I make changing in this function?

    What to do after that - recompile the NDK?

    Is it safe?

    One more question to you as Network expert:

    What another IP address for our custom DHCP we can use safely?

     Thanks in advance.

  • Hi IgDor,

    IgDor said:

    Can I make changing in this function?

    What to do after that - recompile the NDK?

    Yes, the NDK is an open source product; as such you are free to modify the code as you desire.

    However, please be aware that if you do choose to modify the code, and experience any issue, TI can no longer provide support for you (we can only support the NDK product as it is shipped by us).

    IgDor said:
    What another IP address for our custom DHCP we can use safely?

    Assuming you just want to use your own DHCP client to interact with your custom DHCP server, I don't see why you would need to bind/assign address 0.0.0.0; the NDK's DHCP client doesn't bind to that address.

    Instead, it just writes address 0.0.0.0 as the source IP address for the DHCP discover packet (etc.) that it sends out when soliciting a DHCP server.

    Once the DHCP server responds with a valid IP address, the NDK then binds that IP address.

    I would expect that you should be able to do the same or similar in the case of your custom DHCP client that's running on the target.

    Steve

  • Hi Steve.

    We made changing in function NtAddNetwork()

     if( !IPTrialAddress )

    {

    /* Destroy the binding with the bad IP address */

    ;//BindFree( hBind );

    //hBind = 0;

    }

    and rebuild NDK. After that, when SW start in debug mode, we see the message on the "Console" window "Network Added: If-1: 0.0.0.0" which was not before changing

    but unfortunately the TIVA still not sending any Ethernet message. Possibly there is else others checks in NDK.

    Anyway, thanks for your help.

    Best Regards.