mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-26 12:41:05 +00:00
11160cb76f
The types u_char, u_short, u_int, u_long, ushort, uint, ulong, u_int8_t, u_int16_t, u_int32_t, u_int64_t, quad_t, and u_quad_t are BSDisms that have never been standardized. While glibc should continue to *provide* these types for compatibility's sake, its public headers should not use them. The meat of this change was mechanically generated by the following shell command: perl -pi~ -e ' s/\b(__)?u_char\b/unsigned char/g; s/\b(__)?u_?short\b/unsigned short/g; s/\b(__)?u_?int\b/unsigned int/g; s/\b(__)?u_?long\b/unsigned long/g; s/\b(__)?u_int8_t\b/uint8_t/g; s/\b(__)?u_int16_t\b/uint16_t/g; s/\b(__)?u_int32_t\b/uint32_t/g; s/\b(__)?u_int64_t\b/uint64_t/g; s/\b(__)?u_quad_t\b/uint64_t/g; s/\b(__)?quad_t\b/uint64_t/g; ' $(grep -lE -e '\<((__)?(quad_t|u(short|int|long|_(char|short|int([0-9]+_t)?|long|quad_t))))\>' \ $(grep -LE '\<(_(SYS|BITS)_TYPES_H|rpc/(rpc|rpc_msg|types|xdr)\.h)\>' \ $(find . \( -false $(sed 's/^/-o -name /' all-installed-headers) \ \) -printf '%P\n' | sort -u))) where 'all-installed-headers' was a list of the basenames of all installed header files, manually extracted from the Makefiles. Non-installed wrapper headers in include/ are also adjusted, for consistency. I then manually fixed up indentation and line-wrapping. sys/types.h and bits/types.h are excluded because they must continue to define the u_* types (under __USE_MISC) for compatibility with applications. They do not use these types themselves. All headers that (transitively) include rpc/types.h are also excluded, for three reasons. First, the u_* types are defined by rpc/types.h, unconditionally (not just under __USE_MISC) so they are logically part of the SunRPC API. Second, many of those headers appear to be machine-generated. Third, it's my understanding that we are getting rid of as much of SunRPC as possible in the near future. (The one file under sunrpc/ that's touched, sunrpc/rpc/rpc_des.h, does *not* include rpc/types.h. This may itself be a bug.) After changing from u_intNN_t to uintNN_t, a number of headers now need to include stdint.h to pick up those types. It might be more hygenic, namespace-wise, to use __uintNN_t instead, but none of these headers are bound by ISO or POSIX to do so, and it's unlikely that anyone using them will be bothered. (The two files that were using __-prefixed versions of the u_types, sysdeps/mach/hurd/net/route.h and sysdeps/unix/sysv/linux/net/route.h, both already also contained uses of the unprefixed versions.) Some of these files directly included features.h and/or sys/cdefs.h, which I removed, as the style generally seems to be to let sys/types.h do that for us. (This does not change the set of definitions exposed by any header; sys/types.h unconditionally includes both features.h and sys/cdefs.h.) One file included asm/types.h unnecessarily. * bits/in.h, gmon/sys/gmon.h, inet/netinet/igmp.h * inet/protocols/routed.h, inet/protocols/talkd.h * inet/protocols/timed.h, io/fts.h, nptl_db/thread_db.h * resolv/arpa/nameser.h, resolv/resolv.h, sunrpc/rpc/rpc_des.h * sysdeps/generic/netinet/if_ether.h * sysdeps/generic/netinet/in_systm.h * sysdeps/generic/netinet/ip.h, sysdeps/generic/netinet/tcp.h * sysdeps/gnu/netinet/ip_icmp.h, sysdeps/gnu/netinet/tcp.h * sysdeps/gnu/netinet/udp.h, sysdeps/mach/hurd/net/ethernet.h * sysdeps/mach/hurd/net/if_arp.h * sysdeps/mach/hurd/net/if_ppp.h * sysdeps/mach/hurd/net/route.h, sysdeps/mach/sys/reboot.h * sysdeps/unix/sysv/linux/bits/in.h * sysdeps/unix/sysv/linux/net/ethernet.h * sysdeps/unix/sysv/linux/net/if_arp.h * sysdeps/unix/sysv/linux/net/if_ppp.h * sysdeps/unix/sysv/linux/net/if_shaper.h * sysdeps/unix/sysv/linux/net/route.h * sysdeps/unix/sysv/linux/netinet/if_ether.h * sysdeps/unix/sysv/linux/netinet/if_fddi.h * sysdeps/unix/sysv/linux/netinet/if_tr.h * sysdeps/unix/sysv/linux/netipx/ipx.h * sysdeps/unix/sysv/linux/sys/acct.h * include/arpa/nameser.h, include/resolv.h: Change all uses of u_char to unsigned char, u_short and ushort to unsigned short, u_int and uint to unsigned int, u_long and ulong to unsigned long, u_int8_t to uint8_t, u_int16_t to uint16_t, u_int32_t to uint32_t, quad_t to int64_t, and u_int64_t and u_quad_t to uint64_t. * mach/sys/reboot.h: Remove two casts of integer literals to the types they already have. * bits/in.h: Correct error in description of IP_MULTICAST_LOOP. * sysdeps/unix/sysv/linux/bits/in.h: Likewise. * sysdeps/unix/sysv/linux/netinet/if_ether.h: Change a comment from referring to 'unsigned char' to 'uint8_t' for consistency with the macro definition below. * gmon/sys/gmon.h, inet/netinet/igmp.h, inet/protocols/talkd.h * io/fts.h, resolv/arpa/nameser.h, resolv/resolv.h * sunrpc/rpc/rpc_des.h, sysdeps/generic/netinet/ip.h * sysdeps/gnu/netinet/tcp.h, sysdeps/gnu/netinet/udp.h * sysdeps/mach/hurd/net/if_ppp.h, sysdeps/unix/sysv/linux/net/if_ppp.h * sysdeps/unix/sysv/linux/sys/acct.h * include/arpa/nameser.h, include/resolv.h: Fix indentation disrupted by mechanical edits. * inet/protocols/talkd.h, resolv/arpa/nameser.h * sysdeps/generic/netinet/in_systm.h * sysdeps/gnu/netinet/ip_icmp.h, sysdeps/gnu/netinet/tcp.h * sysdeps/gnu/netinet/udp.h * sysdeps/unix/sysv/linux/net/ethernet.h * sysdeps/unix/sysv/linux/net/if_arp.h * sysdeps/unix/sysv/linux/net/if_ppp.h * sysdeps/unix/sysv/linux/net/if_shaper.h * sysdeps/unix/sysv/linux/netinet/if_fddi.h * sysdeps/unix/sysv/linux/netinet/if_tr.h * sysdeps/unix/sysv/linux/netipx/ipx.h * sysdeps/unix/sysv/linux/sys/acct.h Include stdint.h for uintNN_t definitions. Don't include sys/cdefs.h, features.h, or asm/types.h directly.
303 lines
9.2 KiB
C
303 lines
9.2 KiB
C
/* Copyright (C) 1991-2016 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
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef __NETINET_IP_H
|
|
#define __NETINET_IP_H 1
|
|
|
|
#include <features.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
__BEGIN_DECLS
|
|
|
|
struct timestamp
|
|
{
|
|
uint8_t len;
|
|
uint8_t ptr;
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
unsigned int flags:4;
|
|
unsigned int overflow:4;
|
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
|
unsigned int overflow:4;
|
|
unsigned int flags:4;
|
|
#else
|
|
# error "Please fix <bits/endian.h>"
|
|
#endif
|
|
uint32_t data[9];
|
|
};
|
|
|
|
struct iphdr
|
|
{
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
unsigned int ihl:4;
|
|
unsigned int version:4;
|
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
|
unsigned int version:4;
|
|
unsigned int ihl:4;
|
|
#else
|
|
# error "Please fix <bits/endian.h>"
|
|
#endif
|
|
uint8_t tos;
|
|
uint16_t tot_len;
|
|
uint16_t id;
|
|
uint16_t frag_off;
|
|
uint8_t ttl;
|
|
uint8_t protocol;
|
|
uint16_t check;
|
|
uint32_t saddr;
|
|
uint32_t daddr;
|
|
/*The options start here. */
|
|
};
|
|
|
|
#ifdef __USE_MISC
|
|
/*
|
|
* Copyright (c) 1982, 1986, 1993
|
|
* The Regents of the University of California. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
* @(#)ip.h 8.1 (Berkeley) 6/10/93
|
|
*/
|
|
|
|
/*
|
|
* Definitions for internet protocol version 4.
|
|
* Per RFC 791, September 1981.
|
|
*/
|
|
|
|
/*
|
|
* Structure of an internet header, naked of options.
|
|
*/
|
|
struct ip
|
|
{
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
unsigned int ip_hl:4; /* header length */
|
|
unsigned int ip_v:4; /* version */
|
|
#endif
|
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
|
unsigned int ip_v:4; /* version */
|
|
unsigned int ip_hl:4; /* header length */
|
|
#endif
|
|
uint8_t ip_tos; /* type of service */
|
|
unsigned short ip_len; /* total length */
|
|
unsigned short ip_id; /* identification */
|
|
unsigned short ip_off; /* fragment offset field */
|
|
#define IP_RF 0x8000 /* reserved fragment flag */
|
|
#define IP_DF 0x4000 /* dont fragment flag */
|
|
#define IP_MF 0x2000 /* more fragments flag */
|
|
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
|
|
uint8_t ip_ttl; /* time to live */
|
|
uint8_t ip_p; /* protocol */
|
|
unsigned short ip_sum; /* checksum */
|
|
struct in_addr ip_src, ip_dst; /* source and dest address */
|
|
};
|
|
|
|
/*
|
|
* Time stamp option structure.
|
|
*/
|
|
struct ip_timestamp
|
|
{
|
|
uint8_t ipt_code; /* IPOPT_TS */
|
|
uint8_t ipt_len; /* size of structure (variable) */
|
|
uint8_t ipt_ptr; /* index of current entry */
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
unsigned int ipt_flg:4; /* flags, see below */
|
|
unsigned int ipt_oflw:4; /* overflow counter */
|
|
#endif
|
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
|
unsigned int ipt_oflw:4; /* overflow counter */
|
|
unsigned int ipt_flg:4; /* flags, see below */
|
|
#endif
|
|
uint32_t data[9];
|
|
};
|
|
#endif /* __USE_MISC */
|
|
|
|
#define IPVERSION 4 /* IP version number */
|
|
#define IP_MAXPACKET 65535 /* maximum packet size */
|
|
|
|
/*
|
|
* Definitions for Explicit Congestion Notification (ECN)
|
|
*
|
|
* Taken from RFC-3168, Section 5.
|
|
*/
|
|
|
|
#define IPTOS_ECN_MASK 0x03
|
|
#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
|
|
#define IPTOS_ECN_NOT_ECT 0x00
|
|
#define IPTOS_ECN_ECT1 0x01
|
|
#define IPTOS_ECN_ECT0 0x02
|
|
#define IPTOS_ECN_CE 0x03
|
|
|
|
/*
|
|
* Definitions for IP differentiated services code points (DSCP)
|
|
*
|
|
* Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3.
|
|
*/
|
|
|
|
#define IPTOS_DSCP_MASK 0xfc
|
|
#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
|
|
#define IPTOS_DSCP_AF11 0x28
|
|
#define IPTOS_DSCP_AF12 0x30
|
|
#define IPTOS_DSCP_AF13 0x38
|
|
#define IPTOS_DSCP_AF21 0x48
|
|
#define IPTOS_DSCP_AF22 0x50
|
|
#define IPTOS_DSCP_AF23 0x58
|
|
#define IPTOS_DSCP_AF31 0x68
|
|
#define IPTOS_DSCP_AF32 0x70
|
|
#define IPTOS_DSCP_AF33 0x78
|
|
#define IPTOS_DSCP_AF41 0x88
|
|
#define IPTOS_DSCP_AF42 0x90
|
|
#define IPTOS_DSCP_AF43 0x98
|
|
#define IPTOS_DSCP_EF 0xb8
|
|
|
|
/*
|
|
* In RFC 2474, Section 4.2.2.1, the Class Selector Codepoints subsume
|
|
* the old ToS Precedence values.
|
|
*/
|
|
|
|
#define IPTOS_CLASS_MASK 0xe0
|
|
#define IPTOS_CLASS(class) ((class) & IPTOS_CLASS_MASK)
|
|
#define IPTOS_CLASS_CS0 0x00
|
|
#define IPTOS_CLASS_CS1 0x20
|
|
#define IPTOS_CLASS_CS2 0x40
|
|
#define IPTOS_CLASS_CS3 0x60
|
|
#define IPTOS_CLASS_CS4 0x80
|
|
#define IPTOS_CLASS_CS5 0xa0
|
|
#define IPTOS_CLASS_CS6 0xc0
|
|
#define IPTOS_CLASS_CS7 0xe0
|
|
|
|
#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
|
|
|
|
/*
|
|
* Definitions for IP type of service (ip_tos) [deprecated; use DSCP
|
|
* and CS definitions above instead.]
|
|
*/
|
|
#define IPTOS_TOS_MASK 0x1E
|
|
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
|
|
#define IPTOS_LOWDELAY 0x10
|
|
#define IPTOS_THROUGHPUT 0x08
|
|
#define IPTOS_RELIABILITY 0x04
|
|
#define IPTOS_LOWCOST 0x02
|
|
#define IPTOS_MINCOST IPTOS_LOWCOST
|
|
|
|
/*
|
|
* Definitions for IP precedence (also in ip_tos) [also deprecated.]
|
|
*/
|
|
#define IPTOS_PREC_MASK IPTOS_CLASS_MASK
|
|
#define IPTOS_PREC(tos) IPTOS_CLASS(tos)
|
|
#define IPTOS_PREC_NETCONTROL IPTOS_CLASS_CS7
|
|
#define IPTOS_PREC_INTERNETCONTROL IPTOS_CLASS_CS6
|
|
#define IPTOS_PREC_CRITIC_ECP IPTOS_CLASS_CS5
|
|
#define IPTOS_PREC_FLASHOVERRIDE IPTOS_CLASS_CS4
|
|
#define IPTOS_PREC_FLASH IPTOS_CLASS_CS3
|
|
#define IPTOS_PREC_IMMEDIATE IPTOS_CLASS_CS2
|
|
#define IPTOS_PREC_PRIORITY IPTOS_CLASS_CS1
|
|
#define IPTOS_PREC_ROUTINE IPTOS_CLASS_CS0
|
|
|
|
/*
|
|
* Definitions for options.
|
|
*/
|
|
#define IPOPT_COPY 0x80
|
|
#define IPOPT_CLASS_MASK 0x60
|
|
#define IPOPT_NUMBER_MASK 0x1f
|
|
|
|
#define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
|
|
#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK)
|
|
#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK)
|
|
|
|
#define IPOPT_CONTROL 0x00
|
|
#define IPOPT_RESERVED1 0x20
|
|
#define IPOPT_DEBMEAS 0x40
|
|
#define IPOPT_MEASUREMENT IPOPT_DEBMEAS
|
|
#define IPOPT_RESERVED2 0x60
|
|
|
|
#define IPOPT_EOL 0 /* end of option list */
|
|
#define IPOPT_END IPOPT_EOL
|
|
#define IPOPT_NOP 1 /* no operation */
|
|
#define IPOPT_NOOP IPOPT_NOP
|
|
|
|
#define IPOPT_RR 7 /* record packet route */
|
|
#define IPOPT_TS 68 /* timestamp */
|
|
#define IPOPT_TIMESTAMP IPOPT_TS
|
|
#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
|
|
#define IPOPT_SEC IPOPT_SECURITY
|
|
#define IPOPT_LSRR 131 /* loose source route */
|
|
#define IPOPT_SATID 136 /* satnet id */
|
|
#define IPOPT_SID IPOPT_SATID
|
|
#define IPOPT_SSRR 137 /* strict source route */
|
|
#define IPOPT_RA 148 /* router alert */
|
|
|
|
/*
|
|
* Offsets to fields in options other than EOL and NOP.
|
|
*/
|
|
#define IPOPT_OPTVAL 0 /* option ID */
|
|
#define IPOPT_OLEN 1 /* option length */
|
|
#define IPOPT_OFFSET 2 /* offset within option */
|
|
#define IPOPT_MINOFF 4 /* min value of above */
|
|
|
|
#define MAX_IPOPTLEN 40
|
|
|
|
/* flag bits for ipt_flg */
|
|
#define IPOPT_TS_TSONLY 0 /* timestamps only */
|
|
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
|
|
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
|
|
|
|
/* bits for security (not byte swapped) */
|
|
#define IPOPT_SECUR_UNCLASS 0x0000
|
|
#define IPOPT_SECUR_CONFID 0xf135
|
|
#define IPOPT_SECUR_EFTO 0x789a
|
|
#define IPOPT_SECUR_MMMM 0xbc4d
|
|
#define IPOPT_SECUR_RESTR 0xaf13
|
|
#define IPOPT_SECUR_SECRET 0xd788
|
|
#define IPOPT_SECUR_TOPSECRET 0x6bc5
|
|
|
|
/*
|
|
* Internet implementation parameters.
|
|
*/
|
|
#define MAXTTL 255 /* maximum time to live (seconds) */
|
|
#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
|
|
#define IPFRAGTTL 60 /* time to live for frags, slowhz */
|
|
#define IPTTLDEC 1 /* subtracted when forwarding */
|
|
|
|
#define IP_MSS 576 /* default maximum segment size */
|
|
|
|
__END_DECLS
|
|
|
|
#endif /* netinet/ip.h */
|