buglwIP - A Lightweight TCP/IP stack - Bugs: bug #44069, udp_sendto and similar don't...

 
 

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

bug #44069: udp_sendto and similar don't accept const destination addresses

Submitter:  chrysn <chrysn>
Submitted:  Thu 22 Jan 2015 05:25:48 PM UTC
   
 
Category:  UDP Severity:  3 - Normal
Item Group:  Change Request Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

Sun 22 Feb 2015 08:51:23 PM UTC, comment #3: 

Done, thanks for the patch and the hints. I've continued the work on IPv6 etc.

Simon Goldschmidt <goldsimon>
Group administrator
Sat 24 Jan 2015 11:27:04 PM UTC, comment #2: 

i've now prepared a patch on master, which was created in a slightly more systematic way (by going through all header files that mention ip_addr_t).

it has shown that the api change not only affects the ip_send functions, but also the udp and raw recv functions; still, i think it's the right thing to do.

i've just discovered how to run the unit tests, and not yet added the const qualifiers to the unit tests. the tests don't cover the api header, dhcp and some other parts of lwip that are not used in my projects. is there a kind of reference program that builds larger parts of lwip which i can use for testing? (not that i'd expect anything else but compiler warnings/errors, but still...) with such a reference, i could go through the files i haven't touched yet, and files that affect ip6_addr_t.

i'm unsure about the inet_ntoa macros. they include a cast, that would previously have stripped a const qualifier. as that is not required any more because ipaddr_ntoa now has a const argument anyway, is there any reason for the cast to be still present?

chrysn <chrysn>
Thu 22 Jan 2015 08:24:01 PM UTC, comment #1: 

Yes, the idea of making it const sounds good. Also, it's a good time for such a break.

Simon Goldschmidt <goldsimon>
Group administrator
Thu 22 Jan 2015 05:25:48 PM UTC, original submission:  

functions like udp_sendto take address arguments which they
conceptionally won't modify, but do not declare them as const. this
causes issues with libraries like libcoap that treat their addresses,
which might be shared among different parts of the program, as const.

the attached patch is more a suggestion for discussion than a complete solution, for once because it's atop DEVEL-1_4_1, and then because it is not comprehensive (eg. tcp is not touched).

the only potential issue it shows is the api change in netif_output_fn -- while adding `const` to an api is usually not an issue, starting to require `const` in the netif_output_fn  could be. the issue is mitigated by many applications using etharp_output.

would a patch adding this more comprehensively on master be accepted?

chrysn <chrysn>

 

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

Attached Files
file #32906:  0001-api-break-qualify-ip_addr_t-as-const-where-feasible.patch added by chrysn (32KiB - application/octet-stream - a fresh patch based on master with a structured approach)
file #32898:  0001-udp-ip-const-declaration-for-destination-addresses.patch added by chrysn (14KiB - application/octet-stream - sample patch onto DEVEL-1_4_1 solving this for udp_sendto and related functions)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by chrysn (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-02-22 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2015-01-24 chrysn Attached File- Added 0001-api-break-qualify-ip_addr_t-as-const-where-feasible.patch, #32906
    2015-01-22 chrysn Attached File- Added 0001-udp-ip-const-declaration-for-destination-addresses.patch, #32898

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code