From acde013522fc264f0898d300cc9d2ff796c1a006 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 8 Jan 2014 18:54:33 -0500 Subject: [PATCH] fix remaining known namespace violations for netinet/in.h the imr_, imsf_, ip6_, ip6m_, ipi_, ipi6_, SCM_, and SOL_ prefixes are not in the reserved namespace for this header. thus the constants and structures using them need to be protected under appropriate feature test macros. this also affects some headers which are permitted to include netinet/in.h, particularly netdb.h and arpa/inet.h. the SOL_ macros are moved to sys/socket.h where they are in the reserved namespace (SO*). they are still accessible via netinet/in.h since it includes sys/socket.h implicitly (which is permitted). the SCM_SRCRT macro is simply removed, since the definition used for it, IPV6_RXSRCRT is not defined anywhere. it could be re-added, this time in sys/socket.h, if the appropriate value can be determined; however, given that the erroneous definition was not caught, it is unlikely that any software actually attempts to use SCM_SRCRT. --- include/netinet/in.h | 36 ++++++++++++++---------------------- include/sys/socket.h | 4 ++++ 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/include/netinet/in.h b/include/netinet/in.h index db961442..587ef358 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -211,19 +211,6 @@ uint16_t ntohs(uint16_t); #define IP_MULTICAST_ALL 49 #define IP_UNICAST_IF 50 -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define MCAST_JOIN_GROUP 42 -#define MCAST_BLOCK_SOURCE 43 -#define MCAST_UNBLOCK_SOURCE 44 -#define MCAST_LEAVE_GROUP 45 -#define MCAST_JOIN_SOURCE_GROUP 46 -#define MCAST_LEAVE_SOURCE_GROUP 47 -#define MCAST_MSFILTER 48 - -#define MCAST_EXCLUDE 0 -#define MCAST_INCLUDE 1 -#endif - #define IP_RECVRETOPTS IP_RETOPTS #define IP_PMTUDISC_DONT 0 @@ -231,8 +218,6 @@ uint16_t ntohs(uint16_t); #define IP_PMTUDISC_DO 2 #define IP_PMTUDISC_PROBE 3 -#define SOL_IP 0 - #define IP_DEFAULT_MULTICAST_TTL 1 #define IP_DEFAULT_MULTICAST_LOOP 1 #define IP_MAX_MEMBERSHIPS 20 @@ -243,6 +228,19 @@ struct ip_opts char ip_opts[40]; }; +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + +#define MCAST_JOIN_GROUP 42 +#define MCAST_BLOCK_SOURCE 43 +#define MCAST_UNBLOCK_SOURCE 44 +#define MCAST_LEAVE_GROUP 45 +#define MCAST_JOIN_SOURCE_GROUP 46 +#define MCAST_LEAVE_SOURCE_GROUP 47 +#define MCAST_MSFILTER 48 + +#define MCAST_EXCLUDE 0 +#define MCAST_INCLUDE 1 + struct ip_mreq { struct in_addr imr_multiaddr; @@ -273,7 +271,6 @@ struct ip_msfilter { (sizeof(struct ip_msfilter) - sizeof(struct in_addr) \ + (numsrc) * sizeof(struct in_addr)) -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) struct group_req { uint32_t gr_interface; struct sockaddr_storage gr_group; @@ -295,7 +292,6 @@ struct group_filter { #define GROUP_FILTER_SIZE(numsrc) \ (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) \ + (numsrc) * sizeof(struct sockaddr_storage)) -#endif struct in_pktinfo { @@ -315,6 +311,7 @@ struct ip6_mtuinfo struct sockaddr_in6 ip6m_addr; uint32_t ip6m_mtu; }; +#endif #define IPV6_ADDRFORM 1 #define IPV6_2292PKTINFO 2 @@ -324,7 +321,6 @@ struct ip6_mtuinfo #define IPV6_2292PKTOPTIONS 6 #define IPV6_CHECKSUM 7 #define IPV6_2292HOPLIMIT 8 -#define SCM_SRCRT IPV6_RXSRCRT #define IPV6_NEXTHOP 9 #define IPV6_AUTHHDR 10 #define IPV6_UNICAST_HOPS 16 @@ -363,15 +359,11 @@ struct ip6_mtuinfo #define IPV6_RXHOPOPTS IPV6_HOPOPTS #define IPV6_RXDSTOPTS IPV6_DSTOPTS - #define IPV6_PMTUDISC_DONT 0 #define IPV6_PMTUDISC_WANT 1 #define IPV6_PMTUDISC_DO 2 #define IPV6_PMTUDISC_PROBE 3 -#define SOL_IPV6 41 -#define SOL_ICMPV6 58 - #define IPV6_RTHDR_LOOSE 0 #define IPV6_RTHDR_STRICT 1 diff --git a/include/sys/socket.h b/include/sys/socket.h index 82edd6f7..79a41cc3 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -207,6 +207,10 @@ struct linger #define SOL_SOCKET 1 #endif +#define SOL_IP 0 +#define SOL_IPV6 41 +#define SOL_ICMPV6 58 + #define SOL_RAW 255 #define SOL_DECNET 261 #define SOL_X25 262 -- 2.25.1