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.

CC3220: simplelink 1_60_00_04 gethostbyname

Part Number: CC3220

hi

i think there may be a problem with the implementation in ti/net/bsd/netdb.c.  the returned hostent structure is not built correctly.

by comparison, the implementation in ti/drivers/net/wifi/source/netdb.c  works fine

that caused confusion when linking with the slnetsock library

ron

  • i have another issue with inet_pton, which is implemented by SlNetUtil_inetPton : it doesnt detect an invalid input, such as a DNS address. it uses strtoul which simply returns 0.0.0.0 as a valid IP address.
  • Hi Ron,

    What issue are you seeing in the hostent structure?

    In regards to SlNetUtil_inetPton, do you mean if you pass it non-decimal text in the IPv4 format?

    Best regards,
    Sarah
  • hi

    the h_addr_list should be an array of pointers, not a double pointer.

    as to SlNetUtil_inetPton, when inputing non decimal text it should return 0, not 1.

    ron

  • Hi Ron,

    Thanks for noting this. We'll get bugs filed for the next release.

    Best regards,
    Sarah
  • Hello! 

    Jumping in here as I noticed switching to CC3220 SDK 2.10 and having problems with gathostbyname().  I think it's more broken now! (or my code depended on broken 1.60.)

    I think it will now (SDK 2.10) actually return h_addr_list pointing directly at a struct in_addr_t, not a pointer to one (h_addr_list[0], i.e. there's a level of indirection missing?  This will quite probably trap on access if dereferenced.  Currently I need to use     ip = ((struct in_addr *)(he->h_addr_list))->s_addr; wheras the correct address would be in (struct in_addr*)he->h_addr_list[0])->sd_addr (he being the struct hostentry * returned.)  The code being obviously specific to this SDK + version.

    As gethostbyname() is using a shared buffer, would much prefer getaddrinfo().  This is declared in ti/net/bsd/netdb.h, but I cannot find an implementation.  This function is present onthe MSP432 SDK, I am quite sure.

    The following will now trap on the memcpy:

    #if CC32XX
    int ipaddr_aton(const char * s, struct in_addr * dest)
    {
        /* This only has gethostbyname() (not gethostbyaddr() either.)
         */
        int rval = -1;
        struct hostent * host = gethostbyname(s);
        if (host && host->h_addrtype == AF_INET) { /* AF_INET6 "could be" */
            rval = host->h_length;
            if (dest && host->h_length == 4) {
                memcpy(dest, host->h_addr_list[0], 4);
            }
        }
        return rval;
    }
    #else