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.

RTOS/TM4C1294NCPDT: How do I get access to the internal data of the DHCP client?

Part Number: TM4C1294NCPDT

Tool/software: TI-RTOS

I am in need of getting access to the internal data of the TI-RTOS DHCP client, such as lease time, lease time remaining, and other info to support testing of my device on a customers network.

I have a callback set up that gets invoked when there are certain DHCP status updates, such as when a new IP address is received, but the info provided is not really sufficient.

In the functions supporting DHCP in the following file:

C:\ti\tirtos_tivac_2_16_01_14\products\ndk_2_25_00_09\packages\ti\ndk\nettools\dhcp\dhcpsm.c

there is a pointer named pLease pointing to a data structure named DHCPLEASE which has the information I am looking for.

Is there any way to get access to this pointer or the DHCPLEASE data structure through the Cfg* interface, or any other set of functions?

If it is not possible, and I want to add some additional code to dhcpsm.c for supplying this info to my application, are there up-to-date instructions for building the NDK?

I have found the website below, but it seems out of date:

processors.wiki.ti.com/.../Rebuilding_the_NDK_Core

Thanks,
sjf

  • Hello sfj,

    You cannot access the DHCPLEASE data structure right now. This is because the DHCPLEASE is not included in the top level headers. It is only in dhcp.h. You will have to rebuild the ndk to get this to work, because you cannot include dhcp.h directly without tweaking it a bit. 

    Since you are on the tivac sdk you can navigate to the top level makefile in the tivac directory and call: 

    make -f tirtos.mak ndk

    You might have to set some of the make variables in tirtos.mak to your installed dependencies locations.

    Now to get the DHCPLEASE viewable by your app you will need to edit ti/ndk/nettols/dhcp/dhcp.h so that the top 2 includes are now

    #include <ti/ndk/inc/netmain.h>
    #include <ti/ndk/inc/_stack.h>

    After that you can rebuild the NDK.

    In your app you will need to place the following code:

    #include <ti/ndk/inc/netmain.h>
    #include <ti/ndk/inc/stkmain.h>
    #include <ti/ndk/nettools/dhcp/dhcp.h>
    
        CISARGS *pa;
        void *hCfgEntry;
        int rc = 0;
        rc = CfgGetEntry(0, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 1, &hCfgEntry);
        rc = CfgEntryInfo(hCfgEntry, 0, (unsigned char **)(&pa));
        DHCPLEASE *pLease = (DHCPLEASE *)pa->hService;

    You will then be able to traverse the pLease structure to get what you want. 

    Regards,

    Dalton

  • Thanks Dalton for the response.

    I added the code using the Cfg* functions that you showed, and then impatiently went ahead and compiled and ran without rebuilding the NDK. After first adjusting the include directories in the compiler settings so that dhcp.h was visible to my code, it not just compiled, but also appears to work during runtime. Right now, I am just copying out of the DHCPLEASE structure the lease times, and the current state. 

    I'll go ahead and do the recompile, but any deeper insight on why the NDK recompile is necessary? In a brief inspection of dhcp.h, it looks like the compiler has everything needed to work with the DHCPLEASE structure in my code.

    Thanks,

    sjf

  • Hello sjf,

    Yes the compiler should have everything it needs in dhcp.h. I actually over engineered the solution for you a bit, because the quicker solution is to do what you did and add the headers to the compiler link line. For the NDK we try to make it so that you do not need multiple "-I"s to compile it, so I defaulted to the fix that would allow that use case.  

    Did you need the DHCPLEASE struct for a runtime operation, or was it just useful as debugging/testing info? I ask because I'd like to make this a more supported feature (without having to include dhcp.h directly in your app), and we could expose this in our debugging tools if that was the extent of your need. 

    Regards,

    Dalton 

  • The info in the DHCPLEASE struct was originally intended to be used for testing, but it will likely become regular functionality.

    Thanks again for your help.