cancel
Showing results for 
Search instead for 
Did you mean: 

LwIP compilation errors/warnings when enabling IPv6 feature

STM32_ZA
ST Employee

Hi All,

You may encounter some LwIP compilation errors/warnings when enabling IPv6 feature due to compiler packing management implemented in the system\arch include files

1. EWARM warnings:

Warning[Pa039]: use of address of unaligned structure member \Middlewares\Third_Party\LwIP\src\netif\lowpan6_common.c 504

Workaround: Disable flag PACK_STRUCT_USE_INCLUDES  by uncommenting the #define PACK_STRUCT_USE_INCLUDES line in arch\cc.h include file

2. MDK-ARM errors:

../Middlewares/Third_Party/LwIP/src/netif/lowpan6_common.c(504): error: #167: argument of type "__packed u32_t *" is incompatible with parameter of type "void *restrict"

Workaround: Don’t packet the IPv6 struct by replacing #define PACK_STRUCT_BEGIN __packed by #define PACK_STRUCT_BEGIN in arch\cc.h

3. GNU compiler:

No errors/warnings

Regards,

1 REPLY 1
jiangpen
Associate II

I recently has one IPV6 issue, that IPV6 DNS request return failed.

LwIP works fine in IPv4, but when I enabled IPV6, the DNS resolve failed.

I set IPV6 DNS server, then using lwip_getaddrinfo, but lwip_getaddrinfo return failed.

 const char * googleDNS1="2001:4860:4860::8888";
 
 const char * googleDNS2="2001:4860:4860::8844";
 
 ip6_addr_t addrV6_1, addrV6_2;
 
 int ret1=ip6addr_aton(googleDNS1,&addrV6_1 );
 
 int ret2=ip6addr_aton(googleDNS2,&addrV6_2 );
 
 printf("DNS convert returns %d, %d\r\n", ret1, ret2);
 
 ip_addr_t dns_addr1,dns_addr2 ;
 
 dns_addr1.type=IPADDR_TYPE_V6;
 
 memcpy(&(dns_addr1.u_addr.ip6), &addrV6_1, sizeof(addrV6_1));
 
 dns_setserver(0, &dns_addr1);//google IPV6 primary, 2001:4860:4860::8888
 
 dns_addr2.type=IPADDR_TYPE_V6;
 
 memcpy(&(dns_addr2.u_addr.ip6), &addrV6_2, sizeof(addrV6_2));
 
 dns_setserver(1, &dns_addr2);//google IPV6 primary, 2001:4860:4860::8888
 
 PRINT_PPPOSIF("  our6_ipaddr = %s", ip6addr_ntoa(netif_ip6_addr(pppif, 0)))
///////////////////////////////////////////////////////////////////////////////////////////////////////
memset( &hints, 0, sizeof( hints ) );
        hints.ai_family   = AF_INET6;     /* IPv4 or IPv6 records (don't care). */
        hints.ai_socktype = SOCK_STREAM;   /* Connection-oriented byte stream.   */
        hints.ai_protocol = IPPROTO_TCP;   /* TCP transport layer protocol only. */
        char ports[5];
        itoa(port, ports, 10);
 
        int aiErr=0;
        if ( ( aiErr = lwip_getaddrinfo( pHostName,
                ports,
                                       &hints,
                                       &res ) ) != 0 )
        {
            DBGLOG(DBG_SUBSYS_IOT_UTILITIES, LOG_ERR, "lwip_getaddrinfo %d", aiErr);
        }
 
 
        tcpSocket = com_socket(res->ai_family,
                res->ai_socktype,
                res->ai_protocol);
        if(tcpSocket<0)
        {
            DBGLOG(DBG_SUBSYS_IOT_UTILITIES, LOG_ERR, "com_socket return %d, retrying...\r\n",
                                                tcpSocket);
        }
 
        if (tcpSocket >= 0)
        {
            socketStatus = com_connect( tcpSocket, res->ai_addr, res->ai_addrlen);
 
        }
sockets_wrapper.c    +87   Sockets_Connect           lwip_getaddrinfo 202
lwip_socket(825241910, 808465720/UNKNOWN, 959657522) = -1
sockets_wrapper.c    +96   Sockets_Connect           com_socket return -1, retrying...
 
sockets_wrapper.c    +106  Sockets_Connect           com_socket return -1, retrying...
 
ndns_tmr: dns_check_entries2l4ym2rlvj63k-ats.iot.ap-southeast-2.amazonaws.com
dns_tmr: dns_check_entries
dns_tmr: dns_check_entries
dns_tmr: dns_check_entries
dns_tmr: dns_check_entries
lwip_netconn_do_gethostbyname a2l4ym2rlvj63k-ats.iot.ap-southeast-2.amazonaws.com,1
dns_enqueue: "a2l4ym2rlvj63k-ats.iot.ap-southeast-2.amazonaws.com": use DNS entry 0
udp_bind(ipaddr = 0.0.0.0, port = 57204)
udp_bind: bound to 0.0.0.0, port 57204)
dns_enqueue: "a2l4ym2rlvj63k-ats.iot.ap-southeast-2.amazonaws.com": use DNS pcb 0
dns_send: dns_servers[0] "a2l4ym2rlvj63k-ats.iot.ap-southeast-2.amazonaws.com": request
pbuf_alloc(length=69)
pbuf_alloc(length=69) == 0x24012420
sending DNS request ID 868 for name "a2l4ym2rlvj63k-ats.iot.ap-southeast-2.amazonaws.com" to server 0
udp_send
pbuf_add_header: old 0x2401247c new 0x24012474 (8)
udp_send: added header in given pbuf 0x24012420
udp_send: sending datagram of length 77
udp_send: UDP packet length 77
inet_chksum_pseudo(): checksumming pbuf 0x24012420 (has next 0) 
inet_chksum_pseudo(): pbuf chain lwip_chksum()=9e47
udp_send: UDP checksum 0x61b8
udp_send: ip_output_if (,,,,0x11,)
pbuf_add_header: old 0x24012474 new 0x2401244c (40)
ip6_output_if: pp0
netif->output_ip6()
pbuf_alloc(length=0)
pbuf_alloc(length=0) == 0x24016258
pbuf_free(0x24016258)
pbuf_free: deallocating 0x24016258
pbuf_free(0x24012420)
pbuf_free: deallocating 0x24012420
lwip_netconn_do_gethostbyname returns,-5
dns_tmr: dns_check_entries
dns_send: dns_servers[0] "a2l4ym2rlvj63k-ats.iot.ap-southeast-2.amazonaws.com": request
pbuf_alloc(length=69)
pbuf_alloc(length=69) == 0x24012420
sending DNS request ID 868 for name "a2l4ym2rlvj63k-ats.iot.ap-southeast-2.amazonaws.com" to server 0
udp_send
pbuf_add_header: old 0x2401247c new 0x24012474 (8)
udp_send: added header in given pbuf 0x24012420
udp_send: sending datagram of length 77
udp_send: UDP packet length 77
inet_chksum_pseudo(): checksumming pbuf 0x24012420 (has next 0) 
inet_chksum_pseudo(): pbuf chain lwip_chksum()=9e47
udp_send: UDP checksum 0x61b8
udp_send: ip_output_if (,,,,0x11,)
pbuf_add_header: old 0x24012474 new 0x2401244c (40)
ip6_output_if: pp0
netif->output_ip6()
pbuf_alloc(length=0)
pbuf_alloc(length=0) == 0x24016258
pbuf_free(0x24016258)
pbuf_free: deallocating 0x24016258
pbuf_free(0x24012420)
pbuf_free: deallocating 0x24012420

may I know if I miss anything?