Deleted Added
full compact
in.h (95099) in.h (95336)
1/*
2 * Copyright (c) 1982, 1986, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)in.h 8.3 (Berkeley) 1/3/94
1/*
2 * Copyright (c) 1982, 1986, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)in.h 8.3 (Berkeley) 1/3/94
34 * $FreeBSD: head/sys/netinet/in.h 95099 2002-04-20 02:24:35Z mike $
34 * $FreeBSD: head/sys/netinet/in.h 95336 2002-04-24 01:26:11Z mike $
35 */
36
37#ifndef _NETINET_IN_H_
38#define _NETINET_IN_H_
39
35 */
36
37#ifndef _NETINET_IN_H_
38#define _NETINET_IN_H_
39
40#include <sys/cdefs.h>
40#include <sys/_types.h>
41#include <sys/_types.h>
42#include <machine/endian.h>
41
43
44/* Protocols common to RFC 1700, POSIX, and X/Open. */
45#define IPPROTO_IP 0 /* dummy for IP */
46#define IPPROTO_ICMP 1 /* control message protocol */
47#define IPPROTO_TCP 6 /* tcp */
48#define IPPROTO_UDP 17 /* user datagram protocol */
49
50#define INADDR_ANY (u_int32_t)0x00000000
51#define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */
52
53#ifndef _UINT8_T_DECLARED
54typedef __uint8_t uint8_t;
55#define _UINT8_T_DECLARED
56#endif
57
58#ifndef _UINT16_T_DECLARED
59typedef __uint16_t uint16_t;
60#define _UINT16_T_DECLARED
61#endif
62
63#ifndef _UINT32_T_DECLARED
64typedef __uint32_t uint32_t;
65#define _UINT32_T_DECLARED
66#endif
67
68#ifndef _IN_ADDR_T_DECLARED
69typedef uint32_t in_addr_t;
70#define _IN_ADDR_T_DECLARED
71#endif
72
73#ifndef _IN_PORT_T_DECLARED
74typedef uint16_t in_port_t;
75#define _IN_PORT_T_DECLARED
76#endif
77
78#ifdef _BSD_SA_FAMILY_T_
79typedef _BSD_SA_FAMILY_T_ sa_family_t;
80#undef _BSD_SA_FAMILY_T_
81#endif
82
83/* Internet address (a structure for historical reasons). */
84#ifndef _STRUCT_IN_ADDR_DECLARED
85struct in_addr {
86 in_addr_t s_addr;
87};
88#define _STRUCT_IN_ADDR_DECLARED
89#endif
90
91/* Socket address, internet style. */
92struct sockaddr_in {
93 uint8_t sin_len;
94 sa_family_t sin_family;
95 in_port_t sin_port;
96 struct in_addr sin_addr;
97 char sin_zero[8];
98};
99
100#ifndef _KERNEL
101
102#ifndef _BYTEORDER_PROTOTYPED
103#define _BYTEORDER_PROTOTYPED
104__BEGIN_DECLS
105uint32_t htonl(uint32_t);
106uint16_t htons(uint16_t);
107uint32_t ntohl(uint32_t);
108uint16_t ntohs(uint16_t);
109__END_DECLS
110#endif
111
112#ifndef _BYTEORDER_FUNC_DEFINED
113#define _BYTEORDER_FUNC_DEFINED
114#define htonl(x) __htonl(x)
115#define htons(x) __htons(x)
116#define ntohl(x) __ntohl(x)
117#define ntohs(x) __ntohs(x)
118#endif
119
120#endif /* !_KERNEL */
121
122#if __POSIX_VISIBLE >= 200112
123#define IPPROTO_RAW 255 /* raw IP packet */
124#define INET_ADDRSTRLEN 16
125#endif
126
127#if __BSD_VISIBLE
42/*
43 * Constants and structures defined by the internet system,
44 * Per RFC 790, September 1981, and numerous additions.
45 */
46
47/*
48 * Protocols (RFC 1700)
49 */
128/*
129 * Constants and structures defined by the internet system,
130 * Per RFC 790, September 1981, and numerous additions.
131 */
132
133/*
134 * Protocols (RFC 1700)
135 */
50#define IPPROTO_IP 0 /* dummy for IP */
51#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */
136#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */
52#define IPPROTO_ICMP 1 /* control message protocol */
53#define IPPROTO_IGMP 2 /* group mgmt protocol */
54#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
55#define IPPROTO_IPV4 4 /* IPv4 encapsulation */
56#define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */
137#define IPPROTO_IGMP 2 /* group mgmt protocol */
138#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
139#define IPPROTO_IPV4 4 /* IPv4 encapsulation */
140#define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */
57#define IPPROTO_TCP 6 /* tcp */
58#define IPPROTO_ST 7 /* Stream protocol II */
59#define IPPROTO_EGP 8 /* exterior gateway protocol */
60#define IPPROTO_PIGP 9 /* private interior gateway */
61#define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */
62#define IPPROTO_NVPII 11 /* network voice protocol*/
63#define IPPROTO_PUP 12 /* pup */
64#define IPPROTO_ARGUS 13 /* Argus */
65#define IPPROTO_EMCON 14 /* EMCON */
66#define IPPROTO_XNET 15 /* Cross Net Debugger */
67#define IPPROTO_CHAOS 16 /* Chaos*/
141#define IPPROTO_ST 7 /* Stream protocol II */
142#define IPPROTO_EGP 8 /* exterior gateway protocol */
143#define IPPROTO_PIGP 9 /* private interior gateway */
144#define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */
145#define IPPROTO_NVPII 11 /* network voice protocol*/
146#define IPPROTO_PUP 12 /* pup */
147#define IPPROTO_ARGUS 13 /* Argus */
148#define IPPROTO_EMCON 14 /* EMCON */
149#define IPPROTO_XNET 15 /* Cross Net Debugger */
150#define IPPROTO_CHAOS 16 /* Chaos*/
68#define IPPROTO_UDP 17 /* user datagram protocol */
69#define IPPROTO_MUX 18 /* Multiplexing */
70#define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */
71#define IPPROTO_HMP 20 /* Host Monitoring */
72#define IPPROTO_PRM 21 /* Packet Radio Measurement */
73#define IPPROTO_IDP 22 /* xns idp */
74#define IPPROTO_TRUNK1 23 /* Trunk-1 */
75#define IPPROTO_TRUNK2 24 /* Trunk-2 */
76#define IPPROTO_LEAF1 25 /* Leaf-1 */

--- 74 unchanged lines hidden (view full) ---

151#define IPPROTO_GMTP 100 /* GMTP*/
152#define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */
153/* 101-254: Partly Unassigned */
154#define IPPROTO_PIM 103 /* Protocol Independent Mcast */
155#define IPPROTO_PGM 113 /* PGM */
156/* 255: Reserved */
157/* BSD Private, local use, namespace incursion */
158#define IPPROTO_DIVERT 254 /* divert pseudo-protocol */
151#define IPPROTO_MUX 18 /* Multiplexing */
152#define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */
153#define IPPROTO_HMP 20 /* Host Monitoring */
154#define IPPROTO_PRM 21 /* Packet Radio Measurement */
155#define IPPROTO_IDP 22 /* xns idp */
156#define IPPROTO_TRUNK1 23 /* Trunk-1 */
157#define IPPROTO_TRUNK2 24 /* Trunk-2 */
158#define IPPROTO_LEAF1 25 /* Leaf-1 */

--- 74 unchanged lines hidden (view full) ---

233#define IPPROTO_GMTP 100 /* GMTP*/
234#define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */
235/* 101-254: Partly Unassigned */
236#define IPPROTO_PIM 103 /* Protocol Independent Mcast */
237#define IPPROTO_PGM 113 /* PGM */
238/* 255: Reserved */
239/* BSD Private, local use, namespace incursion */
240#define IPPROTO_DIVERT 254 /* divert pseudo-protocol */
159#define IPPROTO_RAW 255 /* raw IP packet */
160#define IPPROTO_MAX 256
161
162/* last return value of *_input(), meaning "all job for this pkt is done". */
163#define IPPROTO_DONE 257
164
165/*
166 * Local port number conventions:
167 *

--- 129 unchanged lines hidden (view full) ---

297#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
298#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
299#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
300#define IN_MULTICAST(i) IN_CLASSD(i)
301
302#define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
303#define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
304
241#define IPPROTO_MAX 256
242
243/* last return value of *_input(), meaning "all job for this pkt is done". */
244#define IPPROTO_DONE 257
245
246/*
247 * Local port number conventions:
248 *

--- 129 unchanged lines hidden (view full) ---

378#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
379#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
380#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
381#define IN_MULTICAST(i) IN_CLASSD(i)
382
383#define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
384#define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
385
305#define INADDR_ANY (u_int32_t)0x00000000
306#define INADDR_LOOPBACK (u_int32_t)0x7f000001
386#define INADDR_LOOPBACK (u_int32_t)0x7f000001
307#define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */
308#ifndef _KERNEL
309#define INADDR_NONE 0xffffffff /* -1 return */
310#endif
311
312#define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */
313#define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */
314#define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */
315#define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff /* 224.0.0.255 */
316
317#define IN_LOOPBACKNET 127 /* official! */
318
319/*
387#ifndef _KERNEL
388#define INADDR_NONE 0xffffffff /* -1 return */
389#endif
390
391#define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */
392#define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */
393#define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */
394#define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff /* 224.0.0.255 */
395
396#define IN_LOOPBACKNET 127 /* official! */
397
398/*
320 * Socket address, internet style.
321 */
322struct sockaddr_in {
323 u_char sin_len;
324 u_char sin_family;
325 u_short sin_port;
326 struct in_addr sin_addr;
327 char sin_zero[8];
328};
329
330#define INET_ADDRSTRLEN 16
331
332/*
333 * Options for use with [gs]etsockopt at the IP level.
334 * First word of comment is data type; bool is stored in int.
335 */
336#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
337#define IP_HDRINCL 2 /* int; header is included with data */
338#define IP_TOS 3 /* int; IP type of service and preced. */
339#define IP_TTL 4 /* int; IP time to live */
340#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */

--- 150 unchanged lines hidden (view full) ---

491 { "directed-broadcast", CTLTYPE_INT }, \
492 { "intr-queue-maxlen", CTLTYPE_INT }, \
493 { "intr-queue-drops", CTLTYPE_INT }, \
494 { "stats", CTLTYPE_STRUCT }, \
495 { "accept_sourceroute", CTLTYPE_INT }, \
496 { "fastforwarding", CTLTYPE_INT }, \
497}
498
399 * Options for use with [gs]etsockopt at the IP level.
400 * First word of comment is data type; bool is stored in int.
401 */
402#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
403#define IP_HDRINCL 2 /* int; header is included with data */
404#define IP_TOS 3 /* int; IP type of service and preced. */
405#define IP_TTL 4 /* int; IP time to live */
406#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */

--- 150 unchanged lines hidden (view full) ---

557 { "directed-broadcast", CTLTYPE_INT }, \
558 { "intr-queue-maxlen", CTLTYPE_INT }, \
559 { "intr-queue-drops", CTLTYPE_INT }, \
560 { "stats", CTLTYPE_STRUCT }, \
561 { "accept_sourceroute", CTLTYPE_INT }, \
562 { "fastforwarding", CTLTYPE_INT }, \
563}
564
499#ifdef _KERNEL
500struct ifnet; struct mbuf; /* forward declarations for Standard C */
501#endif
565#endif /* __BSD_VISIBLE */
502
566
503/* INET6 stuff */
504#define __KAME_NETINET_IN_H_INCLUDED_
505#include <netinet6/in6.h>
506#undef __KAME_NETINET_IN_H_INCLUDED_
507
508#ifdef _KERNEL
509
567#ifdef _KERNEL
568
569struct ifnet; struct mbuf; /* forward declarations for Standard C */
570
510int in_broadcast(struct in_addr, struct ifnet *);
511int in_canforward(struct in_addr);
512int in_localaddr(struct in_addr);
513char *inet_ntoa(struct in_addr); /* in libkern */
514char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
515
516#define satosin(sa) ((struct sockaddr_in *)(sa))
517#define sintosa(sin) ((struct sockaddr *)(sin))
518#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
519
571int in_broadcast(struct in_addr, struct ifnet *);
572int in_canforward(struct in_addr);
573int in_localaddr(struct in_addr);
574char *inet_ntoa(struct in_addr); /* in libkern */
575char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
576
577#define satosin(sa) ((struct sockaddr_in *)(sa))
578#define sintosa(sin) ((struct sockaddr *)(sin))
579#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
580
520#else /* !_KERNEL */
521
522#ifndef _BYTEORDER_PROTOTYPED
523#define _BYTEORDER_PROTOTYPED
524__BEGIN_DECLS
525uint32_t htonl(uint32_t);
526uint16_t htons(uint16_t);
527uint32_t ntohl(uint32_t);
528uint16_t ntohs(uint16_t);
529__END_DECLS
530#endif
531
532#ifndef _BYTEORDER_FUNC_DEFINED
533#define _BYTEORDER_FUNC_DEFINED
534#define htonl(x) __htonl(x)
535#define htons(x) __htons(x)
536#define ntohl(x) __ntohl(x)
537#define ntohs(x) __ntohs(x)
538#endif
539
540#endif /* _KERNEL */
541
581#endif /* _KERNEL */
582
583/* INET6 stuff */
584#if __POSIX_VISIBLE >= 200112
585#define __KAME_NETINET_IN_H_INCLUDED_
586#include <netinet6/in6.h>
587#undef __KAME_NETINET_IN_H_INCLUDED_
542#endif
588#endif
589
590#endif /* !_NETINET_IN_H_*/