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.

MSP432E401Y: MSP432E401Y

Part Number: MSP432E401Y
Other Parts Discussed in Thread: CC3135, CC3120, SYSCONFIG

I am adding secure connection to the a/m configuration (WiFi and Ethernet with BOOST for WiFi hardware and simplelink wifi plugin) using:

SlNetSock_startSec(server, secAttribHdl,SLNETSOCK_SEC_BIND_CONTEXT_ONLY | SLNETSOCK_SEC_START_SECURITY_SESSION_ONLY);

The function call and the program succeed with Ethernet disconnected (i.e., when running on WiFi).

The very same call fails with code SL_RET_CODE_INTERFACE_CLOSED (-2021) when Ethernet is connected.

Note that any combination of interfaces works with unsecure connection.

I am using the default security options w/o certificates,, intercepting SL_ERROR_BSD_ESECSNOVERIFY and proceeding with data exchanges.

Regards,

Michael

  • Hi Michael,

    Could you tell me the following:

    1) What versions of the SimpleLink MSP432E4 SDK and SimpleLink Wi-Fi Plugin are you using?

    2) Are you using a Wi-Fi Boosterpack, and if so, CC3120 or CC3135? Or a custom board? 

    3) Have you flashed your Wi-Fi device with the latest service pack?

    4) Are you working from an existing example from the Wi-Fi Plugin, and if so, which one? Or are you using your own code? Could you post/send the relevant code snippet of your socket initialization and creation?

    Best,
    Kristen

  • Hello Kristen,

    SimpleLink SDK version 3_40_01_02

    SimpleLink WIFI plugin version 2_40_00_22

    Using CC3135 Boosterpack

    Have NOT flashed the sevice pack

    I started with TI"wifi_ethernet_sockets for freeRTOS"and added TLS.  WiFi works with TLS, Ethernet does not. As I mentioned,I amnot using any certificates on the client side (the application does not require server verification). I did not change any of the initialization, interface detection, etc. The behavior is independent of SLNETSOCK_SEC_ATTRIB_DISABLE_CERT_STORE

    Code snippet:

    while(1)
    {
    .........

    server =
    SlNetSock_create(SLNETSOCK_AF_INET, SLNETSOCK_SOCK_STREAM,
    SLNETSOCK_PROTO_TCP,
    0, SLNETSOCK_CREATE_IF_STATUS_CONNECTED);

    if(server < 0)
    {
    Display_printf(display, 0, 0, "Socket create failed\n, error %d\n", server);
    goto shutdown;

    }
    else
    {
    Display_printf(display, 0, 0, "Interface used: %d\n", SlNetSock_getIfID(server));
    }


    memset(&serverAddr, 0, sizeof(serverAddr));

    Network_IF_GetHostIP(HOSTURL, &hostIPaddr);
    serverAddr.sin_addr.s_addr = SlNetUtil_htonl(hostIPaddr);
    serverAddr.sin_port = SlNetUtil_htons(TCPPORT);
    serverAddr.sin_family = SLNETSOCK_AF_INET;

    retc =
    SlNetSock_connect(server, (const SlNetSock_Addr_t *)&serverAddr,
    sizeof(serverAddr));
    if(retc < 0)
    {
    Display_printf(display, 0, 0, "tcpHandler: connect failed, error %d\n", retc);
    goto restartConn;
    }
    else
    {
    Display_printf(display, 0, 0, "tcpHandler: connected\n");
    }

    #if DO_SECURE
    // create security attributes
    secAttribHdl = SlNetSock_secAttribCreate();
    memset(secAttribHdl, 0, sizeof(SlNetSockSecAttrib_t));

    retc = SlNetSock_secAttribSet(secAttribHdl,
    SLNETSOCK_SEC_ATTRIB_DISABLE_CERT_STORE, (void *)&serverNoVerify, sizeof(serverNoVerify));

    // add SNI TLS extension
    SlNetSock_secAttribSet(secAttribHdl, SLNETSOCK_SEC_ATTRIB_DOMAIN_NAME, HOSTURL, strlen(HOSTURL) + 1);

    // activate SSL - force "Client hello"
    retc =
    SlNetSock_startSec(server, secAttribHdl,
    SLNETSOCK_SEC_BIND_CONTEXT_ONLY | SLNETSOCK_SEC_START_SECURITY_SESSION_ONLY);

    if(retc < 0)
    {
    if (SL_ERROR_BSD_ESECSNOVERIFY != retc)
    {
    Display_printf(display, 0, 0, "startSec failed, error %d\n", retc);
    Display_printf(display, 0, 0, "Ethernet status: %d\n", SlNetIf_getState(SLNETIF_ID_2));
    goto restartConn;
    }
    }
    #endif // SECURE

    if((retc = SlNetSock_send(server, txBuf, sizeof(txBuf), 0)) < 0)

    etc....

  • Michael,

    I see that you're using SDK v3.40 with Wi-Fi Plugin v2.40. We have only verified the Wi-Fi Plugin with the accompanying SDK version, which is the SimpleLink MSP432E4 SDK v2.40.00.11

    Could try your code while using v2.40 of the MSP432E4 SDK?

    Best,
    Kristen

  • Please refer to the code snippet in a later message in this chain.

    I am using "wifi_ethernet_sockets for freeRTOS" example

    Not "all combinations" work:

    With Ethernet connected:

    If the device fails to establish a WiFi link (e.g., AP is turned off), Ethernet link successfully obtains IP address from a DHCP server, but fails to retrieve DNS server(s) information from the received (per Wireshark) DHCP packet

    Network_IF_GetHostIP(HOSTURL, &hostIPaddr) call fails with error -6152 (No DNS server specified).

    Ethernet link works as expected, when (lower priority) WiFi link has been successfully established. 

    I'd like to modify the example to work with either interface independently to configure / populate hardware for either in the product under development.

  • Kristen,

    I just did; same results.

    Regards,

    Michael

  • Apologies. It did not - the projects reverts to original version if both are present; it does not build if 3.40 is removed from the path (leaving only 2.40.

    The project is originally from the plugin directory; please advise.

    Regards,

    Michael

  • Hi,

    I configured the project to use SDK 2.40 and observed the following errors:

    For unsecure connection and non-existent access point (with Ethernet connected), the serial console shows host address resolution error:

    ========================================================================================================

    CONSOLE:

    Ethernet Interface connected and started

    Interface(s) not added yet

    Device came up in Station mode

    Interface used: 2  // Ethernet

    Error [-6152] at line [718] in function [Network_IF_GetHostIP]  // No DNS server was specified

    Device could not connect to test3200    // AP SSID

    END_CONSOLE

    For secure connection (per snippet in previous posting), the console shows:

    ==========================================================

    CONSOLE

    thernet Interface connected and started

    Interface(s) not added yet

    Device came up in Station mode

    [WLAN EVENT] STA Connected to the AP: test3200 , BSSID: 58:6d:8f:7:a4:fc

    [NETAPP EVENT] IP acquired by the device


    WiFi Interface has connected to test3200

    WiFi Interface IP Address is 192.168.1.141


    WiFi Interface connected and started

    Interface used: 2

    Get Host IP succeeded.
    Host: g-XXX.com IP: A.B.C.D

    tcpHandler: connected

    startSec failed, error -2024

    Ethernet status: 1

    END_CONSOLE

  • In other words, DHCP client appears to not populate DNS name(s) from DHCP server response, if WiFi is down.

    I added the DHCPOPT_DOMAIN_NAME_SERVERS option to TI provided example code; no effect:

    static void initIp(void *hCfg)
    {
    CI_SERVICE_DHCPC dhcpc;
    unsigned char DHCP_OPTIONS[] = { DHCPOPT_SUBNET_MASK | DHCPOPT_DOMAIN_NAME_SERVERS};

    /* Add global hostname to hCfg (to be claimed in all connected domains) */
    CfgAddEntry(hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
    strlen(hostName), (unsigned char *)hostName, NULL);

    /* Use DHCP to obtain IP address on interface 1 */
    memset(&dhcpc, 0, sizeof(dhcpc));
    dhcpc.cisargs.Mode = CIS_FLG_IFIDXVALID;
    dhcpc.cisargs.IfIdx = 1;
    dhcpc.cisargs.pCbSrv = &serviceReport;
    dhcpc.param.pOptions = DHCP_OPTIONS;
    dhcpc.param.len = 1;
    CfgAddEntry(hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 0,
    sizeof(dhcpc), (unsigned char *)&dhcpc, NULL);
    }

  • Michael,

    Sorry for the delay. I noticed that you're using the macro “SLNETSOCK_SEC_ATTRIB_DISABLE_CERT_STORE." You said that the behavior is independent of this, however the NS API Guide states that that macro is currently only supported on CC3xxx devices. How have you verified that the behavior truly is independent of this macro?

    Best,
    Kristen

  • Kristen,

    I am using CC3135.

    I verified the following:

    Over WiFi (Ethernet disconnected) - error free execution wit and without the macro

    Over Ethernet (WiFi connected to AP, Ethernet cable in) - failures as described

    Over Ethernet (Wifi not connected to AP - AP powered down) - DNS query fails. DNS address is set to 165.165.165.165 (0xa5a5a5a5) wvent though IP address is set correctly by DHCP

    Regards,

    Michael

  • Kristen,

    I built a project based on MSP432E4 SDK w/o WiFi plugin (Ethernet only); based on httpGet example.

    I "borrowed" the initialization and replaced the HTTP part with my own task connecting to the server and sending a request.

    The code is identical to the sequences quoted above, uses no certificates, etc.

    Non-secure mode is working.

    Secure mode:

    SlNetSock_startSec() returns error:
    SLNETERR_RET_CODE_DOESNT_SUPPORT_NON_MANDATORY_FXN (-2024L)

    Wireshark shows that the client does not issue "Client Hello" and if the device is allowed to proceed (forced to skip SlNetSock_startSec() error), server returns error 400 as expected (with "unencrypted HTTP detected over encrypted port").

    Regards,

    Michael

  • Hi Michael,

    I haven’t heard from you for a couple of days now, so I’m assuming you were able to resolve your issue.
    If this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information.
    If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

  • I am still waiting for a comment from TI; the status is as described in the thread.

  • Hi Michael,

    Very good. I have reached out to Kristen to see if she is able to jump back in and provide assistance.

  • Hi Michael,

    Apparently your latest question is out of Kristen's area of expertise, so I have another engineer that can help.  Unfortunately he is out until next Monday the 30th.  I will double check with hm on Monday that he takes a look at your question.

    I really apologize for the delays.

  • Hello Michael,

    Could you show me your netIPAddrHook function in the httpgethooks.c file? I suspect the issue you are experiencing might be related to starting with the httpGet example.

    The Ethernet initialization for use with security is a bit different, and the the httpGet does not perform this different initialization. There is an httpsGet example in newer versions of the SDK that does the security initialization.

    The real difference is in the code below:

    status = SlNetIf_add(SLNETIF_ID_2, "eth0",
                (const SlNetIf_Config_t *)&SlNetIfConfigNDKSec, IFPRI); //using SlNetIfConfigNDKSec instead of SlNetIfConfigNDK

    Regards,

    Dalton

  • Dalton,

    The interface is initialized by a call to "ti_net_SlNet_initConfig" in the following snippet:

    /*
    * ======== ti_net_config.c ========
    * Configured module definitions for NS
    *
    * DO NOT EDIT - This file is generated by the SysConfig tool.
    */


    /*
    * ======== ti.net/SlNet ========
    */
    #include <stdint.h>
    #include <stdlib.h>
    #include "string.h"

    #include <ti/net/slnetif.h>
    #include <ti/net/slnetutils.h>
    #include <ti/net/slnetsock.h>
    #include <ti/net/slnet.h>
    #include <ti/ndk/slnetif/slnetifndk.h>

    /* This generated function must be called after the network stack(s) are
    * initialized.
    */
    int32_t ti_net_SlNet_initConfig() {
    int32_t status;

    status = SlNetIf_init(0);

    if (status == 0) {
    status = SlNetSock_init(0);
    }

    if (status == 0) {
    SlNetUtil_init(0);
    }

    /* add CONFIG_SLNET_0 interface */
    if (status == 0) {
    status = SlNetIf_add(SLNETIF_ID_2, "eth0", (const SlNetIf_Config_t *)&SlNetIfConfigNDKSec, 5);
    }

    return (status);
    }

    This function is called in "netIPAddrHook"  function of httpgethooks.c I modified for security:

    /*
    * ======== httpgethooks.c ========
    */

    #include <stdlib.h>
    #include <stdint.h>
    #include <stdbool.h>

    #include <pthread.h>

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

    #include <ti/ndk/slnetif/slnetifndk.h>
    #include <ti/net/slnet.h>
    #include <ti/net/slnetif.h>
    #include <ti/net/slnetutils.h>

    #include <ti/display/Display.h>
    #include <ti/drivers/emac/EMACMSP432E4.h>


    #define TCPTASKSTACKSIZE 8192
    #define IFPRI 4 /* Ethernet interface priority */

    /* Prototypes */
    extern Display_Handle display;
    extern void *httpTask(void *arg0);

    extern void *TCPSocket(void *);

    uint8_t serverCA[] =

    #if 1 // ***** DigiCert Global Root ****
    "-----BEGIN CERTIFICATE-----\r\n"
    "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\r\n"
    "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\r\n"
    "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\r\n"
    "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\r\n"
    "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\r\n"
    "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\r\n"
    "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\r\n"
    "CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\r\n"
    "nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\r\n"
    "43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\r\n"
    "T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\r\n"
    "gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\r\n"
    "BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\r\n"
    "TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\r\n"
    "DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\r\n"
    "hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\r\n"
    "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\r\n"
    "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\r\n"
    "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\r\n"
    "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\r\n"
    "-----END CERTIFICATE-----";
    #endif


    uint16_t serverCALen = sizeof(serverCA);
    /*
    * ======== netIPAddrHook ========
    * user defined network IP address hook
    */
    void netIPAddrHook(uint32_t IPAddr, unsigned int IfIdx, unsigned int fAdd)
    {
    pthread_t thread;
    pthread_attr_t attrs;
    struct sched_param priParam;
    int retc;
    int detachState;
    uint32_t hostByteAddr;
    static bool createTask = true;
    int32_t status = 0;

    if (fAdd) {
    Display_printf(display, 0, 0, "Network Added: ");
    }
    else {
    Display_printf(display, 0, 0, "Network Removed: ");
    }

    /* print the IP address that was added/removed */
    hostByteAddr = NDK_ntohl(IPAddr);
    Display_printf(display, 0, 0, "If-%d:%d.%d.%d.%d\n", IfIdx,
    (uint8_t)(hostByteAddr>>24)&0xFF, (uint8_t)(hostByteAddr>>16)&0xFF,
    (uint8_t)(hostByteAddr>>8)&0xFF, (uint8_t)hostByteAddr&0xFF);

    /* initialize SlNet interface(s) */
    status = ti_net_SlNet_initConfig();
    if (status < 0)
    {
    Display_printf(display, 0, 0, "Failed to initialize SlNet interface(s)"
    "- status (%d)\n", status);
    exit(1);
    }

    if (fAdd && createTask) {
    /*
    * Create the Task that farms out incoming TCP connections.
    * arg0 will be the port that this task listens to.
    */

    /* Set priority and stack size attributes */
    pthread_attr_init(&attrs);
    priParam.sched_priority = 1;

    detachState = PTHREAD_CREATE_DETACHED;
    retc = pthread_attr_setdetachstate(&attrs, detachState);
    if (retc != 0) {
    Display_printf(display, 0, 0,
    "netIPAddrHook: pthread_attr_setdetachstate() failed\n");
    while (1);
    }

    pthread_attr_setschedparam(&attrs, &priParam);

    retc |= pthread_attr_setstacksize(&attrs, TCPTASKSTACKSIZE);
    if (retc != 0) {
    Display_printf(display, 0, 0,
    "netIPAddrHook: pthread_attr_setstacksize() failed\n");
    while (1);
    }

    retc = pthread_create(&thread, &attrs, TCPSocket, 0);
    if (retc != 0) {
    Display_printf(display, 0, 0,
    "netIPAddrHook: pthread_create() failed\n");
    while (1);
    }

    createTask = false;
    }
    }

    /*
    * ======== serviceReportHook ========
    * NDK service report hook
    */
    void serviceReportHook(uint32_t item, uint32_t status, uint32_t report, void *h)
    {
    static char *taskName[] = {"Telnet", "HTTP", "NAT", "DHCPS", "DHCPC", "DNS"};
    static char *reportStr[] = {"", "Running", "Updated", "Complete", "Fault"};
    static char *statusStr[] =
    {"Disabled", "Waiting", "IPTerm", "Failed","Enabled"};

    Display_printf(display, 0, 0, "Service Status: %-9s: %-9s: %-9s: %03d\n",
    taskName[item - 1], statusStr[status], reportStr[report / 256],
    report & 0xFF);
    }

    /*
    * ======== netOpenHook ========
    * NDK network open hook
    */
    void netOpenHook()
    {
    }

  • Hello Michael,

    Looks like SysConfig is generating the right function table call for you there. 

    When you are using this example are you just trying to get secure mode for Ethernet alone to work? You don't have the wifi plugin code at all in this test example?

    What I'm getting at is I'm wondering if the startSec() function is calling the wrong function table somehow.

    Can you place a break point in SlNetSock_startSec() at the point where it calls "return SLNETERR_RET_CODE_DOESNT_SUPPORT_NON_MANDATORY_FXN" as seen below:

    int32_t SlNetSock_startSec(int16_t sd, SlNetSockSecAttrib_t *secAttrib, uint8_t flags)
    {
        int32_t    retVal = SLNETERR_RET_CODE_OK;
        int16_t    realSd;
        uint8_t    sdFlags;
        SlNetIf_t *netIf;
        void      *sdContext;
    
        /* Check if the sd input exists and return it                            */
        retVal = SlNetSock_getVirtualSdConf(sd, &realSd, &sdFlags, &sdContext, &netIf);
    
        /* Check if sd found or if the non mandatory function exists             */
        if (SLNETERR_RET_CODE_OK != retVal)
        {
            return retVal;
        }
        if (NULL == (netIf->ifConf)->sockstartSec)
        {
            /* Non mandatory function doesn't exists, return error code          */
            return SLNETERR_RET_CODE_DOESNT_SUPPORT_NON_MANDATORY_FXN;
        }

    That's most likely where the function is failing, but it would be good to get positive confirmation on this. We are also interested in netIf in this error state. If you could put netIf->ifName in the expressions view of CSS when you hit this breakpoint I'd expect netIf->ifName to be set to "eth0" as that's what the code you posted above sets the ethernet stack's name to. If it's not that name this will put us on the right track to find the issue. 

    Also when going through this debugging step it will be helpful to change your link line in your project settings to use the debug version of the slnetsock library instead of release as shown below:

    ti/net/lib/ccs/m4f/slnetsock_debug.a

    Regards,

    Dalton

  • I found that although a wifi version will work in secure mode (TLS) without validating the server; Ethernet only version does not.
    I added CA certificate and the project works.
    Note, however, that the application does require TLS without server certificate validation I am aware of the limitations and recommendations).

    Using "wifi-ethernet-sockets" project I found that the wireless works without server certificate validation (sic!)...

    Besides:
    Ethernet will not work in any mode, if the wireless device in this project  is not associated with AP. Ethernet will work, (CA certificate required!) if AP is associated and Ethernet takes precedence per design.

    I would like to programmatically select the interface (wireless or Ethernet)...

  • Hello Michael,

    You can create a socket through the SlNetSock_create() function found in ti/net/slnetsock.h. The ifBitMap argument to that function will allow you to select which interface the socket is created on. However you can't switch the interface associated with a socket after it has already been created. 

    Is that what you're looking for?

    Regards,

    Dalton

  • Hello Dalton,

    This is what I am doing.

    Unfortunately I do not have access to hardware because of the lockdown and will have to wait before exploring this further.

    Please keep the thread active.

    Thanks for your help!

    Regards,

    Michael

**Attention** This is a public forum