buglwIP - A Lightweight TCP/IP stack - Bugs: bug #63312, sockets bug? Port endianness

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #63312: sockets bug? Port endianness

Submitter:  bmcdonnell_npm
Submitted:  Thu 03 Nov 2022 08:04:25 PM UTC
   
 
Category:  sockets/netconn Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  Other

Fri 04 Nov 2022 09:19:16 PM UTC, comment #2: 

It seems I was mistaken; it is conventional to use htons on the port passed to bind. Please close this bug report.

bmcdonnell_npm
Thu 03 Nov 2022 08:12:49 PM UTC, comment #1: 

Apparently this forum won't let me attach a zip file. I used the "lwip_dhcp_freertos_cm7" example.

bmcdonnell_npm
Thu 03 Nov 2022 08:04:25 PM UTC, original submission:  

My socket-based IPv4 only program doesn't work with lwIP. It seems that there is an endian issue with the UDP/TCP ports. As shown in the attached screenshot, I have to modify lwIP's IP4ADDR_PORT_TO_SOCKADDR() and SOCKADDR4_TO_IP4ADDR_PORT() macros by removing the byte swaps on the ports (i.e. removing lwip_htons() and lwip_ntohs()), to make my program work, and for the TCP/UDP ports to show as expected in Wireshark. Is this an lwIP bug, or is there somehow something wrong with my configuration?

Details:

The attached zip contains sample code from NXP for their i.MX RT1170 Evaluation Kit (board URL below). The included lwIP appears to be based on the 2.2.0 development branch. It does not include my sockets code, nor the patch to lwIP in my screenshot.

https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/i-mx-rt1170-evaluation-kit:MIMXRT1170-EVK

I checked out the sample using MCUXpresso IDE v11.6.1 (Quickstart Panel -> Import SDK example(s)).

Relevant lwipopts:
#define LWIP_SOCKET  1
#define LWIP_IPV4    1
#define LWIP_IPV6    0

Via platform #defines / #ifdefs:
BYTE_ORDER == _LITTLE_ENDIAN == 1234

bmcdonnell_npm

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by yarrick (Updated the item)
  • -email is unavailable- added by bmcdonnell_npm (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-11-07 yarrick StatusNone Invalid
        Open/ClosedOpen Closed
    2022-11-03 bmcdonnell_npm Attached File- Added lwip-git-diff.png, #53926

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code