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: Internal DNS server in AP mode

Part Number: CC3220

Hi,

I was wondering if it was possible to STOP the internal DNS server when the device is in AP mode.

According to the manual it should work, but I keep gettting the error -6212, which translates to SL_ERROR_NET_APP_INCORRECT_APP_MASK.

The code I tried is:

RetVal = sl_NetAppStop(SL_NETAPP_DNS_SERVER_ID);

I am using a CC3220S by the way.

Best regards,

Salvatore

  • Hi Salvatore,

    It looks that you found a bug. I see same behaviour at SF with latest SDK (2.20) and latest ServicePack. Error message is returned regardless device is in STA or AP mode.

    Please wait for answer from TI.

    Jan
  • Hi Salvatore,

    This is a known issue that the SL_NETAPP_DNS_SERVER_ID config is not persistent. As a workaround, we suggest calling sl_NetAppStop with another app like mDNS or something you are not using. For example:

    sl_NetAppStop(SL_NETAPP_MDNS_ID | SL_NETAPP_DNS_SERVER_ID);

    Best regards,

    Sarah

  • Hi Sarah,

    I tried what you wrote.
    The error code does not appear anymore, that is true. However, the DNS service is NOT stopped !
    When I try to open a socket on port 53, I get the error -99, which stands for SLNETERR_BSD_EADDRNOTAVAIL.
    In other words, the DNS server still is running!
    To be sure about it, I also tried to send a DNS request to port 53, and I got a response; the DNS server is NOT stopped at all.
    I tried what you said once with the mDNS service enabled, and once with the mDNS service disabled; the result is the same.

    Best regards,
    Salvatore
  • Hi Salvatore,

    Stopping the DNS server worked for me. Keep in mind that sl_NetAppStop only works for the mode the network processor is currently in (station or AP).

    I tested this with the out_of_box application. With the out_of_box as-is and the DNS running by default, before provisioning, I connected to the CC3220 as an AP and successfully navigated to mysimplelink.net. I tried the same steps with the DNS stopped as described and mysimplelink.net could not resolve.
    I also was able to bind a socket on port 53. What API were you using that returned SLNETERR_BSD_EADDRNOTAVAIL?

    Best regards,
    Sarah

  • Hi Sarah,

    the out_of_box example works fine as you say.

    I am not sure how you tested to stop the DNS, because that is not inside the out_of_box example, right ?

    My code is the following; (please not that for clarity of reading I took out a lot of error handling here)

    // boot rountine at startup...
    if (sl_Start(0, 0, 0) < 0) { /*removed*/ }  
    if (sl_WlanSetMode(ROLE_AP) < 0) { /*removed*/ }
    if (sl_Stop(0) < 0) { /*removed*/ }
    if (sl_Start(0, 0, 0) < 0) { /*removed*/ }
    
    // some other startup config API calls, taken over from example code in "network_terminal" example
    // try to disable the DNS server which is running on port 53 //if (sl_NetAppStop(SL_NETAPP_DNS_SERVER_ID) < 0) { /*removed*/ } // <-- this FAILS if (sl_NetAppStop(SL_NETAPP_MDNS_ID | SL_NETAPP_DNS_SERVER_ID) < 0) { /*removed*/ } // <-- this WORKS // For changes to take affect, we restart the NWP RetVal = sl_Stop(0xFF); ASSERT_ON_ERROR(RetVal, DEVICE_ERROR); RetVal = sl_Start(0, 0, 0); ASSERT_ON_ERROR(RetVal, DEVICE_ERROR); //... // try to run a server on port 53 s = sl_Socket(AF_INET, SOCK_DGRAM, SL_IPPROTO_UDP); if (s < 0) { /*removed*/ } memset(&localAddr, 0, sizeof(SlSockAddrIn_t)); localAddr.sin_family = AF_INET; localAddr.sin_addr.s_addr = htonl(INADDR_ANY); localAddr.sin_port = htons(DNSPORT); status = sl_Bind(server, (SlSockAddr_t *)&localAddr, sizeof(SlSockAddrIn_t)); if (status < 0) { /*removed*/ } // <-- THIS LINE GIVES error -99 (SLNETERR_BSD_EADDRNOTAVAIL) when I use port 53

    If I use port 54, then it works fine. My conclusion is thus that the DNS server is still running.

    Are you using the same versions as I do ? I am using the latest SDK (2.20) and latest ServicePack.

    Could you post your test code that show how it works for you ? Perhaps there is another API call that you used when setting up the NWP ?

    BR,

    Salvatore

  • Hi Salvatore,

    Yes, I am using SDK 2.20 and the latest servicepack.

    To the out_of_box, I added the fix code to the end of the ConfigureSimpleLinkToDefaultState() above the final sl_Stop:

    ret = sl_NetAppStop(SL_NETAPP_DNS_SERVER_ID | SL_NETAPP_MDNS_ID);
    ASSERT_ON_ERROR(ret);
    
    ret = sl_NetAppStart(SL_NETAPP_MDNS_ID);
    ASSERT_ON_ERROR(ret);

    I also added this code to HandleStrtEvt before provisioning is started:

    SlSockAddrIn_t  Addr;
    SlSockAddrIn_t  LocalAddr;
    _i16 AddrSize = sizeof(SlSockAddrIn_t);
    _i16 SockID;
    _i16 Status;
    LocalAddr.sin_family = SL_AF_INET;
    LocalAddr.sin_port = sl_Htons(53);
    LocalAddr.sin_addr.s_addr = 0;
    SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
    ASSERT_ON_ERROR(SockID);
    Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
    ASSERT_ON_ERROR(Status);

    Do you see a similar result?

    Best regards,

    Sarah

  • Hi Salvatore,

    Were you able to verify this fix?

    Best regards,
    Sarah