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.

CCS /处理器SDK-AM57X:About TI-RTOS support for IPv6

Part Number: PROCESSOR-SDK-AM57X


Tool/software: Code Composer Studio

My NDK version is 3.61.01.01. I use the TMDSIDK574 board. I want to support IPv6 in the NIMU_BasicExample_idkAM574x_armExampleproject project. But I added "Global.IPv6 = true" in the cfg file, and found that it is not possible to send IPv6 packets using sockets. I want to know how to statically configure IPv6 addresses and use sockets to send IPv6 packets. I read the "TI Network Developer's Kit (NDK) API
Reference Guide: G IP Version 6 (IPv6) Stack API" section. But it doesn't seem to work for me.

I want to know if you have used IPv6 in TI-RTOS. If you can help me, I would appreciate it.

  • Hi,

    thanks for your reply.
    The links you sent me seem to use BSD socket APIs. The project I use now is NIMU_BasicExample_idkAM574x_armExampleproject. I saw the following sentence in the "TI Network Developer's Kit (NDK) API Reference Guide":"The NDK no longer provides a Berkeley Software Distribution (BSD) API support layer. This layer is now provided by SlNetSock, which is part of the SimpleLink SDK. Applications can access the BSD APIs via SlNetSock, but applications must not include both the BSD headers and the NDK headers in the same compilation unit."

    So I copied the contents of the udpEchoIPv6.c and udpEchoHooksIPv6.c files into my project. I found that some header files and functions cannot be found, such as #include <sys/socket.h>, #include <netinet/in.h>, getaddrinfo(), inet_ntop(), etc.

    So I had to add some code to the project file.
    Void sock_udp_ipv6(UArg arg0, UArg arg1)
    {
    sleep(5);
    Task_Params params;
    Error_Block eb;
    SOCKET sock;
    int dev_index = 1;
    int status;
    struct addrinfo hints;
    struct addrinfo *results1 = NULL;
    int value;
    char port[8];
    IP6N srcaddress;
    static char src[] = "fe80::a00:9ff:fedc:aaaa";
    if(IPv6StringToIPAddress((char *)&src[0],(IP6N*)&srcaddress)==-1)
    {
    UART_printf("\error.\n");
    }
    IPv6Init();
    IPv6AddAddress(1, srcaddress, 64, INFINITE_LT, INFINITE_LT, 0);

    fdOpenSession (TaskSelf ());
    #if 1
    if ((sock = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET)
    {
    UART_printf("\n sssss.\n");
    return;
    }

    static char dst[] = "fe80::a00:9ff:fedc:abcd";
    struct sockaddr_in6 stSockAdr;

    stSockAdr.sin6_family = AF_INET6;
    stSockAdr.sin6_port = NDK_htons(8899);
    // inet_ntop(AF_INET6, (char *)&dst[0], &stSockAdr.sin6_addr, sizeof(stSockAdr.sin6_addr));
    if(IPv6StringToIPAddress((char *)&dst[0],(IP6N*)&stSockAdr.sin6_addr)==-1)
    {
    UART_printf("\error.\n");
    }

    struct timeval to;
    to.tv_sec = 3;
    to.tv_usec = 0;
    if(setsockopt( sock, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ))== SOCKET_ERROR){
    UART_printf("\n er.\n");
    }
    if(setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ))== SOCKET_ERROR){
    UART_printf("\n er.\n");
    }

    int slen = sizeof(stSockAdr);

    int result = 0,z = -5;
    char buffer[5] = "hello";
    while(1){
    result = sendto(sock,buffer,sizeof(buffer),0,(struct sockaddr *)&stSockAdr,slen);
    z = fdError();
    UART_printf("write %d bytes\n", result);
    UART_printf("z=%d bytes\n", z);

    }
    #endif
    // Close the file session
    fdCloseSession(TaskSelf());
    }

    But when debugging the sendto function, the following code was debugged.
    NETIF_DEVICE* NIMUFindByIndex (uint32_t index)
    {
    NETIF_DEVICE* ptr_device;

    /* Get the head of the list. */
    ptr_device = (NETIF_DEVICE *)list_get_head ((NDK_LIST_NODE**)&nimu_mcb.devices);
    while (ptr_device != NULL)
    {
    /* Did we get the match? */
    if (ptr_device->index == index)
    return ptr_device;

    /* Go to the next element. */
    ptr_device = (NETIF_DEVICE*)list_get_next ((NDK_LIST_NODE*)ptr_device);
    }

    /* No matching entry found. */
    return NULL;
    }
    Each time the NIMUFindByIndex function returns NULL, causing the sendto() function to execute sendto_error:

    sendto_error:
    /* Unlock the fd with error */
    fdint_unlockfd(pfd, error);

    llExit();

    return (SOCKET_ERROR);
    At this time, the sendto() function returns -1. The fdError() function returns 22.

  • Based on the links I shared, I think there are some configurations and build macro required to enable IPv6 in NDK.

    Have you added those?

  • Hi,
    According to some links you shared, I did some configuration. I can ping the board now. But I have some problems when using UDP sockets. I wrote a UDP client program on the PC, and a UDP server program is running on the board. The board can receive UDP data from the PC, but there is a problem when the board uses the sendto function to send data to the PC. The Sendto function can return the number of bytes of data sent, but the data sent by the board cannot be captured in PC wireshark. The return value of fdError() is 9 instead of 0.
    The following is the information printed through the board serial port:
    recv 14 bytes
    send 14 bytes
    fdError()=9

    The following is part of the program on the board:
    int result = 0,z = -5;

    nbytes = recvfrom(lSocket, buffer, UDPPACKETSIZE, MSG_WAITALL,
    (struct sockaddr *)&client_addr, &addrlen);
    UART_printf("recv %d bytes\n", nbytes);

    if (nbytes >= 0) {
    /* Echo the data back */
    result=sendto(lSocket, (char *)buffer, nbytes, 0,
    (struct sockaddr *)&client_addr, sizeof(client_addr));

    z = fdError();
    UART_printf("send %d bytes\n", result);
    UART_printf("fdError()=%d \n", z);

  • fdError 9 means that the file descriptor "lSocket" has been closed.