9 * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
10 * All rights reserved.
12 * Redistribution is only permitted until one year after the first shipment
13 * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and
14 * binary forms are permitted provided that: (1) source distributions retain
15 * this entire copyright notice and comment, and (2) distributions including
16 * binaries display the following acknowledgement: This product includes
17 * software developed by the University of California, Berkeley and its
18 * contributors'' in the documentation or other materials provided with the
19 * distribution and in all advertising materials mentioning features or use
20 * of this software. Neither the name of the University nor the names of
21 * its contributors may be used to endorse or promote products derived from
22 * this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 * @(#)in.h 7.10 (Berkeley) 6/28/90 plus MULTICAST 1.1
31 * Constants and structures defined by the internet system,
32 * Per RFC 790, September 1981.
38 #define IPPROTO_IP 0 /* dummy for IP */
39 #define IPPROTO_ICMP 1 /* control message protocol */
40 #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
41 #define IPPROTO_TCP 6 /* tcp */
42 #define IPPROTO_EGP 8 /* exterior gateway protocol */
43 #define IPPROTO_PUP 12 /* pup */
44 #define IPPROTO_UDP 17 /* user datagram protocol */
45 #define IPPROTO_IDP 22 /* xns idp */
46 #define IPPROTO_TP 29 /* tp-4 w/ class negotiation */
47 #define IPPROTO_EON 80 /* ISO cnlp */
49 #define IPPROTO_RAW 255 /* raw IP packet */
50 #define IPPROTO_MAX 256
54 * Local port number conventions:
55 * Ports < IPPORT_RESERVED are reserved for
56 * privileged processes (e.g. root).
57 * Ports > IPPORT_USERRESERVED are reserved
58 * for servers, not necessarily privileged.
60 #define IPPORT_RESERVED 1024
61 #define IPPORT_USERRESERVED 5000
64 * Internet address (a structure for historical reasons)
71 * Definitions of bits in internet address integers.
72 * On subnets, the decomposition of addresses to host and net parts
73 * is done according to subnet mask, not the masks here.
75 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
76 #define IN_CLASSA_NET 0xff000000
77 #define IN_CLASSA_NSHIFT 24
78 #define IN_CLASSA_HOST 0x00ffffff
79 #define IN_CLASSA_MAX 128
81 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
82 #define IN_CLASSB_NET 0xffff0000
83 #define IN_CLASSB_NSHIFT 16
84 #define IN_CLASSB_HOST 0x0000ffff
85 #define IN_CLASSB_MAX 65536
87 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
88 #define IN_CLASSC_NET 0xffffff00
89 #define IN_CLASSC_NSHIFT 8
90 #define IN_CLASSC_HOST 0x000000ff
92 #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
93 #define IN_MULTICAST(i) IN_CLASSD(i)
95 #define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
96 #define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
98 #define INADDR_ANY (unsigned long)0x00000000
99 #define INADDR_BROADCAST (unsigned long)0xffffffff /* must be masked */
100 #define INADDR_NONE (unsigned long)0xffffffff /* -1 return */
102 #define IN_LOOPBACKNET 127 /* official! */
105 * Socket address, internet style.
109 unsigned short sin_port;
110 struct in_addr sin_addr;
115 * Structure used to describe IP options.
116 * Used to store options internally, to pass them to a process,
117 * or to restore options retrieved earlier.
118 * The ip_dst is used for the first-hop gateway when using a source route
119 * (this gets put into the header proper).
122 struct in_addr ip_dst; /* first hop, 0 w/o src rt */
123 char ip_opts[40]; /* actually variable in size */
127 * Options for use with [gs]etsockopt at the IP level.
128 * First word of comment is data type; bool is stored in int.
130 #define IP_OPTIONS 1 /* buf/ip_opts; set/get IP per-packet options */
131 #define IP_HDRINCL 7 /* int; header is included with data (raw) */
132 #define IP_TOS 8 /* int; IP type of service and precedence */
133 #define IP_TTL 9 /* int; IP time to live */
135 extern unsigned long ntohl(unsigned long x);
136 extern unsigned short ntohs(unsigned short x);
137 extern unsigned long htonl(unsigned long x);
138 extern unsigned short htons(unsigned short x);
139 extern unsigned long inet_addr(char*);
140 extern char* inet_ntoa(struct in_addr);
141 extern unsigned long nptohl(void*);
147 #endif /* __netinet_in__ */