This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bits/in.h portability: Patch and RFC


Any comments on this? It's been >40 days since I wrote this.

If you like, I could get linux/bits/in.h to #include_next generic/bits/in.h
and add the proper re-definitions after that.

On Sat, Apr 10, 2004 at 06:13:57PM +0200, Robert Millan wrote:
> 
> Hi!
> 
> I found some possible problem with the portability of the bits/in.h provided
> by Glibc. The sysdeps/unix/sysv/linux/bits/in.h version has a number of
> macros that aren't defined in sysdeps/generic/bits/in.h, and I suspect a
> number of them are not really Linux-specific (Particularly, IPV6_PKTINFO
> is defined on GNU/Linux and *BSD systems, and used unconditionaly by bind9)
> 
> Before I could dump cleanly the differences between both files, I had to do
> some fixes in linux/bits/in.h because due to cosmetical changes they were
> out of sync. I'm attaching a little patch (w/ChangeLog) that fixes this.
> 
> Once that is fixed, I could obtain a list of the actual differences between
> both files. It follows in unified diff format.
> 
> If you could commit the attached patch, and have a look at the below macros
> to give an indication on which of them are Linux-specific and which should
> be added to generic/bits/in.h, that'd be much appreciated.
> 
> --- generic/bits/in.h	2003-06-28 10:25:50.000000000 +0200
> +++ unix/sysv/linux/bits/in.h	2004-04-10 17:55:08.000000000 +0200
> @@ -1,4 +1,4 @@
> -/* Copyright (C) 1997, 2000 Free Software Foundation, Inc.
> +/* Copyright (C) 1991-1999, 2000 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
>     The GNU C Library is free software; you can redistribute it and/or
> @@ -16,34 +16,50 @@
>     Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
>     02111-1307 USA.  */
>  
> -/* Generic version.  */
> +/* Linux version.  */
>  
>  #ifndef _NETINET_IN_H
>  # error "Never use <bits/in.h> directly; include <netinet/in.h> instead."
>  #endif
>  
> -/* Link numbers.  */
> -#define	IMPLINK_IP		155
> -#define	IMPLINK_LOWEXPER	156
> -#define	IMPLINK_HIGHEXPER	158
> -
> -
>  /* Options for use with `getsockopt' and `setsockopt' at the IP level.
>     The first word in the comment at the right is the data type used;
>     "bool" means a boolean value stored in an `int'.  */
> -#define	IP_OPTIONS	1	/* ip_opts; IP per-packet options.  */
> -#define	IP_HDRINCL	2	/* int; Header is included with data.  */
> -#define	IP_TOS		3	/* int; IP type of service and precedence.  */
> -#define	IP_TTL		4	/* int; IP time to live.  */
> -#define	IP_RECVOPTS	5	/* bool; Receive all IP options w/datagram.  */
> -#define	IP_RECVRETOPTS	6	/* bool; Receive IP options for response.  */
> -#define	IP_RECVDSTADDR	7	/* bool; Receive IP dst addr w/datagram.  */
> -#define	IP_RETOPTS	8	/* ip_opts; Set/get IP per-packet options.  */
> -#define IP_MULTICAST_IF 9	/* in_addr; set/get IP multicast i/f */
> -#define IP_MULTICAST_TTL 10	/* u_char; set/get IP multicast ttl */
> -#define IP_MULTICAST_LOOP 11	/* i_char; set/get IP multicast loopback */
> -#define IP_ADD_MEMBERSHIP 12	/* ip_mreq; add an IP group membership */
> -#define IP_DROP_MEMBERSHIP 13	/* ip_mreq; drop an IP group membership */
> +#define        IP_OPTIONS      4       /* ip_opts; IP per-packet options.  */
> +#define        IP_HDRINCL      3       /* int; Header is included with data.  */
> +#define        IP_TOS          1       /* int; IP type of service and precedence.  */
> +#define        IP_TTL          2       /* int; IP time to live.  */
> +#define        IP_RECVOPTS     6       /* bool; Receive all IP options w/datagram.  */
> +/* For BSD compatibility.  */
> +#define        IP_RECVRETOPTS  IP_RETOPTS       /* bool; Receive IP options for response.  */
> +#define        IP_RETOPTS      7       /* ip_opts; Set/get IP per-packet options.  */
> +#define IP_MULTICAST_IF 32      /* in_addr; set/get IP multicast i/f */
> +#define IP_MULTICAST_TTL 33    /* u_char; set/get IP multicast ttl */
> +#define IP_MULTICAST_LOOP 34   /* i_char; set/get IP multicast loopback */
> +#define IP_ADD_MEMBERSHIP 35   /* ip_mreq; add an IP group membership */
> +#define IP_DROP_MEMBERSHIP 36  /* ip_mreq; drop an IP group membership */
> +
> +#define IP_ROUTER_ALERT    5	/* bool */
> +#define IP_PKTINFO         8	/* bool */
> +#define IP_PKTOPTIONS      9
> +#define IP_PMTUDISC        10	/* obsolete name? */
> +#define IP_MTU_DISCOVER    10	/* int; see below */
> +#define IP_RECVERR         11	/* bool */
> +#define IP_RECVTTL         12	/* bool */
> +#define IP_RECVTOS         13	/* bool */
> +
> +
> +/* IP_MTU_DISCOVER arguments.  */
> +#define IP_PMTUDISC_DONT   0	/* Never send DF frames.  */
> +#define IP_PMTUDISC_WANT   1	/* Use per route hints.  */
> +#define IP_PMTUDISC_DO     2	/* Always DF.  */
> +
> +/* To select the IP level.  */
> +#define SOL_IP	0
> +
> +#define IP_DEFAULT_MULTICAST_TTL        1
> +#define IP_DEFAULT_MULTICAST_LOOP       1
> +#define IP_MAX_MEMBERSHIPS              20
>  
>  /* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.
>     The `ip_dst' field is used for the first-hop gateway when using a
> @@ -61,9 +77,27 @@
>      struct in_addr imr_interface;	/* local IP address of interface */
>    };
>  
> -/* IPV6 socket options.  */
> +/* As above but including interface specification by index.  */
> +struct ip_mreqn
> +  {
> +    struct in_addr imr_multiaddr;	/* IP multicast address of group */
> +    struct in_addr imr_address;		/* local IP address of interface */
> +    int	imr_ifindex;			/* Interface index */
> +  };
> +
> +/* Structure used for IP_PKTINFO.  */
> +struct in_pktinfo
> +  {
> +    int ipi_ifindex;			/* Interface index  */
> +    struct in_addr ipi_spec_dst;	/* Routing destination address  */
> +    struct in_addr ipi_addr;		/* Header destination address  */
> +  };
> +
> +/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level.
> +   The first word in the comment at the right is the data type used;
> +   "bool" means a boolean value stored in an `int'.  */
>  #define IPV6_ADDRFORM		1
> -#define IPV6_RXINFO		2
> +#define IPV6_PKTINFO		2
>  #define IPV6_HOPOPTS		3
>  #define IPV6_DSTOPTS		4
>  #define IPV6_RTHDR		5
> @@ -71,16 +105,25 @@
>  #define IPV6_CHECKSUM		7
>  #define IPV6_HOPLIMIT		8
>  
> -#define IPV6_TXINFO		IPV6_RXINFO
> -#define SCM_SRCINFO		IPV6_TXINFO
>  #define SCM_SRCRT		IPV6_RXSRCRT
>  
> +#define IPV6_NEXTHOP		9
> +#define IPV6_AUTHHDR		10
>  #define IPV6_UNICAST_HOPS	16
>  #define IPV6_MULTICAST_IF	17
>  #define IPV6_MULTICAST_HOPS	18
>  #define IPV6_MULTICAST_LOOP	19
>  #define IPV6_JOIN_GROUP		20
>  #define IPV6_LEAVE_GROUP	21
> +#define IPV6_ROUTER_ALERT	22
> +#define IPV6_MTU_DISCOVER	23
> +#define IPV6_MTU		24
> +#define IPV6_RECVERR		25
> +#define IPV6_V6ONLY		26
> +#define IPV6_JOIN_ANYCAST	27
> +#define IPV6_LEAVE_ANYCAST	28
> +#define IPV6_IPSEC_POLICY	34
> +#define IPV6_XFRM_POLICY	35
>  
>  /* Obsolete synonyms for the above.  */
>  #define IPV6_ADD_MEMBERSHIP	IPV6_JOIN_GROUP
> @@ -88,6 +131,15 @@
>  #define IPV6_RXHOPOPTS		IPV6_HOPOPTS
>  #define IPV6_RXDSTOPTS		IPV6_DSTOPTS
>  
> +/* IPV6_MTU_DISCOVER values.  */
> +#define IPV6_PMTUDISC_DONT	0	/* Never send DF frames.  */
> +#define IPV6_PMTUDISC_WANT	1	/* Use per route hints.  */
> +#define IPV6_PMTUDISC_DO	2	/* Always DF.  */
> +
> +/* Socket level values for IPv6.  */
> +#define SOL_IPV6        41
> +#define SOL_ICMPV6      58
> +
>  /* Routing header options for IPv6.  */
>  #define IPV6_RTHDR_LOOSE	0	/* Hop doesn't need to be neighbour. */
>  #define IPV6_RTHDR_STRICT	1	/* Hop must be a neighbour.  */
> 
> -- 
> Robert Millan
> 
> "[..] but the delight and pride of Aule is in the deed of making, and in the
> thing made, and neither in possession nor in his own mastery; wherefore he
> gives and hoards not, and is free from care, passing ever on to some new work."
> 
>  -- J.R.R.T., Ainulindale (Silmarillion)

> 
> 2004-04-10  Robert Millan  <robertmh@gnu.org>
>  
> 	* sysdeps/unix/sysv/linux/bits/in.h: Cosmetic fixes to get in sync
> 	with sysdeps/generic/bits/in.h.
> 
> --- libc/sysdeps/unix/sysv/linux/bits/in.h.old	2004-04-10 17:54:51.000000000 +0200
> +++ libc/sysdeps/unix/sysv/linux/bits/in.h	2004-04-10 17:55:08.000000000 +0200
> @@ -25,13 +25,21 @@
>  /* Options for use with `getsockopt' and `setsockopt' at the IP level.
>     The first word in the comment at the right is the data type used;
>     "bool" means a boolean value stored in an `int'.  */
> -#define IP_TOS             1	/* int; IP type of service and precedence.  */
> -#define IP_TTL             2	/* int; IP time to live.  */
> -#define IP_HDRINCL         3	/* int; Header is included with data.  */
> -#define IP_OPTIONS         4	/* ip_opts; IP per-packet options.  */
> +#define        IP_OPTIONS      4       /* ip_opts; IP per-packet options.  */
> +#define        IP_HDRINCL      3       /* int; Header is included with data.  */
> +#define        IP_TOS          1       /* int; IP type of service and precedence.  */
> +#define        IP_TTL          2       /* int; IP time to live.  */
> +#define        IP_RECVOPTS     6       /* bool; Receive all IP options w/datagram.  */
> +/* For BSD compatibility.  */
> +#define        IP_RECVRETOPTS  IP_RETOPTS       /* bool; Receive IP options for response.  */
> +#define        IP_RETOPTS      7       /* ip_opts; Set/get IP per-packet options.  */
> +#define IP_MULTICAST_IF 32      /* in_addr; set/get IP multicast i/f */
> +#define IP_MULTICAST_TTL 33    /* u_char; set/get IP multicast ttl */
> +#define IP_MULTICAST_LOOP 34   /* i_char; set/get IP multicast loopback */
> +#define IP_ADD_MEMBERSHIP 35   /* ip_mreq; add an IP group membership */
> +#define IP_DROP_MEMBERSHIP 36  /* ip_mreq; drop an IP group membership */
> +
>  #define IP_ROUTER_ALERT    5	/* bool */
> -#define IP_RECVOPTS        6	/* bool */
> -#define IP_RETOPTS         7	/* bool */
>  #define IP_PKTINFO         8	/* bool */
>  #define IP_PKTOPTIONS      9
>  #define IP_PMTUDISC        10	/* obsolete name? */
> @@ -39,14 +47,7 @@
>  #define IP_RECVERR         11	/* bool */
>  #define IP_RECVTTL         12	/* bool */
>  #define IP_RECVTOS         13	/* bool */
> -#define IP_MULTICAST_IF    32	/* in_addr; set/get IP multicast i/f */
> -#define IP_MULTICAST_TTL   33	/* u_char; set/get IP multicast ttl */
> -#define IP_MULTICAST_LOOP  34	/* i_char; set/get IP multicast loopback */
> -#define IP_ADD_MEMBERSHIP  35	/* ip_mreq; add an IP group membership */
> -#define IP_DROP_MEMBERSHIP 36	/* ip_mreq; drop an IP group membership */
>  
> -/* For BSD compatibility.  */
> -#define IP_RECVRETOPTS	IP_RETOPTS
>  
>  /* IP_MTU_DISCOVER arguments.  */
>  #define IP_PMTUDISC_DONT   0	/* Never send DF frames.  */
> @@ -60,9 +61,9 @@
>  #define IP_DEFAULT_MULTICAST_LOOP       1
>  #define IP_MAX_MEMBERSHIPS              20
>  
> -/* Structure used to describe IP options for IP_OPTIONS. The `ip_dst'
> -   field is used for the first-hop gateway when using a source route
> -   (this gets put into the header proper).  */
> +/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.
> +   The `ip_dst' field is used for the first-hop gateway when using a
> +   source route (this gets put into the header proper).  */
>  struct ip_opts
>    {
>      struct in_addr ip_dst;	/* First hop; zero without source route.  */
> @@ -103,6 +104,9 @@
>  #define IPV6_PKTOPTIONS		6
>  #define IPV6_CHECKSUM		7
>  #define IPV6_HOPLIMIT		8
> +
> +#define SCM_SRCRT		IPV6_RXSRCRT
> +
>  #define IPV6_NEXTHOP		9
>  #define IPV6_AUTHHDR		10
>  #define IPV6_UNICAST_HOPS	16
> @@ -121,14 +125,11 @@
>  #define IPV6_IPSEC_POLICY	34
>  #define IPV6_XFRM_POLICY	35
>  
> -#define SCM_SRCRT		IPV6_RXSRCRT
> -
>  /* Obsolete synonyms for the above.  */
> -#define IPV6_RXHOPOPTS		IPV6_HOPOPTS
> -#define IPV6_RXDSTOPTS		IPV6_DSTOPTS
>  #define IPV6_ADD_MEMBERSHIP	IPV6_JOIN_GROUP
>  #define IPV6_DROP_MEMBERSHIP	IPV6_LEAVE_GROUP
> -
> +#define IPV6_RXHOPOPTS		IPV6_HOPOPTS
> +#define IPV6_RXDSTOPTS		IPV6_DSTOPTS
>  
>  /* IPV6_MTU_DISCOVER values.  */
>  #define IPV6_PMTUDISC_DONT	0	/* Never send DF frames.  */


-- 
Robert Millan

"[..] but the delight and pride of Aule is in the deed of making, and in the
thing made, and neither in possession nor in his own mastery; wherefore he
gives and hoards not, and is free from care, passing ever on to some new work."

 -- J.R.R.T., Ainulindale (Silmarillion)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]