genericopenlibs/cstdlib/LINCINET/IN.H
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /* IN.H
       
     2  * 
       
     3  * Portions Copyright (c) 1997-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     4  * All rights reserved.
       
     5  */
       
     6 
       
     7 /** @file
       
     8 @PublishedAll
       
     9 */
       
    10 
       
    11 /*
       
    12  * Copyright (c) 1982, 1986 Regents of the University of California.
       
    13  * All rights reserved.
       
    14  *
       
    15  * Redistribution and use in source and binary forms are permitted
       
    16  * provided that this notice is preserved and that due credit is given
       
    17  * to the University of California at Berkeley. The name of the University
       
    18  * may not be used to endorse or promote products derived from this
       
    19  * software without specific prior written permission. This software
       
    20  * is provided ``as is'' without express or implied warranty.
       
    21  */
       
    22 
       
    23 /*
       
    24  * Constants and structures defined by the internet system,
       
    25  * Per RFC 790, September 1981.
       
    26  */
       
    27 
       
    28 #ifndef _NETINET_IN_H
       
    29 #define	_NETINET_IN_H
       
    30 
       
    31 #ifdef	__cplusplus
       
    32 extern "C" {
       
    33 #endif
       
    34 #include <_ansi.h>
       
    35 
       
    36 /**
       
    37 Protocols
       
    38 */
       
    39 #define	IPPROTO_IP		0x100		/* dummy for IP */
       
    40 #define	IPPROTO_ICMP		1		/* control message protocol */
       
    41 #define	IPPROTO_IGMP		2		/* group control protocol */
       
    42 #define	IPPROTO_GGP		3		/* gateway^2 (deprecated) */
       
    43 #define	IPPROTO_ENCAP		4		/* IP in IP encapsulation */
       
    44 #define	IPPROTO_TCP		6		/* tcp */
       
    45 #define	IPPROTO_EGP		8		/* exterior gateway protocol */
       
    46 #define	IPPROTO_PUP		12		/* pup */
       
    47 #define	IPPROTO_UDP		17		/* user datagram protocol */
       
    48 #define	IPPROTO_IDP		22		/* xns idp */
       
    49 #define	IPPROTO_HELLO		63		/* "hello" routing protocol */
       
    50 #define	IPPROTO_ND		77		/* UNOFFICIAL net disk proto */
       
    51 #define	IPPROTO_EON		80		/* ISO clnp */
       
    52 #define	IPPROTO_RAW		255		/* raw IP packet */
       
    53 #define	IPPROTO_MAX		0x101
       
    54 
       
    55 /**
       
    56 Port/socket numbers: network standard functions
       
    57 */
       
    58 #define	IPPORT_ECHO		7
       
    59 #define	IPPORT_DISCARD		9
       
    60 #define	IPPORT_SYSTAT		11
       
    61 #define	IPPORT_DAYTIME		13
       
    62 #define	IPPORT_NETSTAT		15
       
    63 #define	IPPORT_FTP		21
       
    64 #define	IPPORT_TELNET		23
       
    65 #define	IPPORT_SMTP		25
       
    66 #define	IPPORT_TIMESERVER	37
       
    67 #define	IPPORT_NAMESERVER	42
       
    68 #define	IPPORT_WHOIS		43
       
    69 #define	IPPORT_MTP		57
       
    70 
       
    71 /**
       
    72 Port/socket numbers: host specific functions
       
    73 */
       
    74 #define	IPPORT_TFTP		69
       
    75 #define	IPPORT_RJE		77
       
    76 #define	IPPORT_FINGER		79
       
    77 #define	IPPORT_TTYLINK		87
       
    78 #define	IPPORT_SUPDUP		95
       
    79 
       
    80 /**
       
    81 UNIX TCP sockets
       
    82 */
       
    83 #define	IPPORT_EXECSERVER	512
       
    84 #define	IPPORT_LOGINSERVER	513
       
    85 #define	IPPORT_CMDSERVER	514
       
    86 #define	IPPORT_EFSSERVER	520
       
    87 
       
    88 /**
       
    89 UNIX UDP sockets
       
    90 */
       
    91 #define	IPPORT_BIFFUDP		512
       
    92 #define	IPPORT_WHOSERVER	513
       
    93 #define	IPPORT_ROUTESERVER	520	/* 520+1 also used */
       
    94 
       
    95 /**
       
    96 Ports < IPPORT_RESERVED are reserved for
       
    97 privileged processes (e.g. root).
       
    98 Ports > IPPORT_USERRESERVED are reserved
       
    99 for servers, not necessarily privileged.
       
   100 */
       
   101 #define	IPPORT_RESERVED		1024
       
   102 #define	IPPORT_USERRESERVED	5000
       
   103 
       
   104 /**
       
   105 Link numbers
       
   106 */
       
   107 #define	IMPLINK_IP		155
       
   108 #define	IMPLINK_LOWEXPER	156
       
   109 #define	IMPLINK_HIGHEXPER	158
       
   110 
       
   111 /**
       
   112 Internet address
       
   113 This definition contains obsolete fields for compatibility
       
   114 with SunOS 3.x and 4.2bsd.  The presence of subnets renders
       
   115 divisions into fixed fields misleading at best.	 New code
       
   116 should use only the s_addr field.
       
   117 @publishedAll
       
   118 @released
       
   119  */
       
   120 struct in_addr {
       
   121 	union {
       
   122 		struct { u_char s_b1, s_b2, s_b3, s_b4; } S_un_b;
       
   123 		struct { u_short s_w1, s_w2; } S_un_w;
       
   124 		u_long S_addr;
       
   125 	} S_un;
       
   126 /**
       
   127 @publishedAll
       
   128 @released
       
   129 */
       
   130 #define	s_addr	S_un.S_addr		/* should be used for all code */
       
   131 /**
       
   132 @publishedAll
       
   133 @released
       
   134 */
       
   135 #define	s_host	S_un.S_un_b.s_b2	/* OBSOLETE: host on imp */
       
   136 /**
       
   137 @publishedAll
       
   138 @released
       
   139 */
       
   140 #define	s_net	S_un.S_un_b.s_b1	/* OBSOLETE: network */
       
   141 /**
       
   142 @publishedAll
       
   143 @released
       
   144 */
       
   145 #define	s_imp	S_un.S_un_w.s_w2	/* OBSOLETE: imp */
       
   146 /**
       
   147 @publishedAll
       
   148 @released
       
   149 */
       
   150 #define	s_impno	S_un.S_un_b.s_b4	/* OBSOLETE: imp # */
       
   151 /**
       
   152 @publishedAll
       
   153 @released
       
   154 */
       
   155 #define	s_lh	S_un.S_un_b.s_b3	/* OBSOLETE: logical host */
       
   156 };
       
   157 
       
   158 /**
       
   159 Definitions of bits in internet address integers.
       
   160 On subnets, the decomposition of addresses to host and net parts
       
   161 is done according to subnet mask, not the masks here.
       
   162 */
       
   163 #define	IN_CLASSA(i)		(((long)(i) & 0x80000000) == 0)
       
   164 #define	IN_CLASSA_NET		0xff000000
       
   165 #define	IN_CLASSA_NSHIFT	24
       
   166 #define	IN_CLASSA_HOST		0x00ffffff
       
   167 #define	IN_CLASSA_MAX		128
       
   168 
       
   169 #define	IN_CLASSB(i)		(((long)(i) & 0xc0000000) == 0x80000000)
       
   170 #define	IN_CLASSB_NET		0xffff0000
       
   171 #define	IN_CLASSB_NSHIFT	16
       
   172 #define	IN_CLASSB_HOST		0x0000ffff
       
   173 #define	IN_CLASSB_MAX		65536
       
   174 
       
   175 #define	IN_CLASSC(i)		(((long)(i) & 0xe0000000) == 0xc0000000)
       
   176 #define	IN_CLASSC_NET		0xffffff00
       
   177 #define	IN_CLASSC_NSHIFT	8
       
   178 #define	IN_CLASSC_HOST		0x000000ff
       
   179 #define	IN_CLASSC_MAX		16777216L
       
   180 
       
   181 #define	IN_CLASSD(i)		(((long)(i) & 0xf0000000) == 0xe0000000)
       
   182 #define	IN_CLASSD_NET		0xf0000000	/* These ones aren't really */
       
   183 #define	IN_CLASSD_NSHIFT	28		/* net and host fields, but */
       
   184 #define	IN_CLASSD_HOST		0x0fffffff	/* routing needn't know.    */
       
   185 #define	IN_MULTICAST(i)		IN_CLASSD(i)
       
   186 
       
   187 #define	IN_EXPERIMENTAL(i)	(((long)(i) & 0xe0000000) == 0xe0000000)
       
   188 #define	IN_BADCLASS(i)		(((long)(i) & 0xf0000000) == 0xf0000000)
       
   189 
       
   190 #define	INADDR_ANY			(u_long)0x00000000
       
   191 #define	INADDR_LOOPBACK		(u_long)0x7F000001
       
   192 #define	INADDR_BROADCAST	(u_long)0xffffffff	/* must be masked */
       
   193 
       
   194 #define	INADDR_UNSPEC_GROUP		(u_long)0xe0000000	/* 224.0.0.0   */
       
   195 #define	INADDR_ALLHOSTS_GROUP	(u_long)0xe0000001	/* 224.0.0.1   */
       
   196 #define	INADDR_MAX_LOCAL_GROUP	(u_long)0xe00000ff	/* 224.0.0.255 */
       
   197 
       
   198 #define INADDR_NONE			INADDR_BROADCAST	/* traditional, but misleading */
       
   199 
       
   200 #define	IN_LOOPBACKNET		127			/* official! */
       
   201 
       
   202 /**
       
   203 Define a macro to stuff the loopback address into an Internet address
       
   204 0x0100007F is htonl(INADDR_LOOPBACK) without the overhead of a function call.
       
   205 */
       
   206 #define	IN_SET_LOOPBACK_ADDR(a) \
       
   207 	{ (a)->sin_addr.s_addr  = 0x0100007F; (a)->sin_family = AF_INET; }
       
   208 
       
   209 /**
       
   210 Socket address, internet style.
       
   211 */
       
   212 struct sockaddr_in {
       
   213 	u_short	sin_family;
       
   214 	u_short	sin_port;
       
   215 	struct	in_addr sin_addr;
       
   216 	char	sin_zero[20];
       
   217 };
       
   218 
       
   219 /**
       
   220 * Options for use with [gs]etsockopt at the IP level.
       
   221 * NB. The negative option values below are not supported and must not
       
   222 * be used in calls to the [gs]etsockopt() API as they will be ignored
       
   223 * or cause an error.
       
   224 */
       
   225 #define SOL_IP		0x100	/* options for IP level */
       
   226 
       
   227 #define	IP_OPTIONS	0x306	/* set/get IP per-packet options   */
       
   228 #define	IP_HDRINCL	0x308	/* int; header is included with data (raw) */
       
   229 #define	IP_TOS		0x309	/* int; IP type of service and precedence */
       
   230 #define	IP_TTL		0x310	/* int; IP time to live */
       
   231 #define	IP_RECVOPTS	-1	/* bool; receive all IP options w/datagram */
       
   232 #define	IP_RECVRETOPTS	-2	/* bool; receive IP options for response */
       
   233 #define	IP_RECVDSTADDR	-3	/* bool; receive IP dst addr w/datagram */
       
   234 #define	IP_RETOPTS	-4	/* ip_opts; set/get IP per-packet options */
       
   235 #define	IP_MULTICAST_IF		-5	/* set/get IP multicast interface  */
       
   236 #define	IP_MULTICAST_TTL	-6	/* set/get IP multicast timetolive */
       
   237 #define	IP_MULTICAST_LOOP	-7	/* set/get IP multicast loopback   */
       
   238 #define	IP_ADD_MEMBERSHIP	-8	/* add	an IP group membership	   */
       
   239 #define	IP_DROP_MEMBERSHIP	-9	/* drop an IP group membership	   */
       
   240 
       
   241 #define	IP_DEFAULT_MULTICAST_TTL  1	/* normally limit m'casts to 1 hop */
       
   242 #define	IP_DEFAULT_MULTICAST_LOOP 1	/* normally hear sends if a member */
       
   243 
       
   244 /**
       
   245 Options for use with [gs]etsockopt at the TCP level.
       
   246 */
       
   247 #define SOL_TCP		0x106		/* options for TCP level */
       
   248 
       
   249 #define	TCP_SENDWINDOW	0x301		/* int: send window size in bytes */
       
   250 #define	TCP_RECVWINDOW	0x302		/* int: recv window size in bytes */
       
   251 #define	TCP_NODELAY	0x304		/* disable Nagle's algorithm */
       
   252 #define	TCP_KEEPALIVE	0x305		/* keep connections alive */
       
   253 
       
   254 /**
       
   255 Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
       
   256 @publishedAll
       
   257 @released
       
   258 */
       
   259 struct ip_mreq {
       
   260 	struct in_addr	imr_multiaddr;	/* IP multicast address of group */
       
   261 	struct in_addr	imr_interface;	/* local IP address of interface */
       
   262 };
       
   263 
       
   264 /* 
       
   265 EPOC32 is little-endian
       
   266 @publishedAll
       
   267 @released
       
   268 */
       
   269 IMPORT_C unsigned short htons(unsigned short hs);
       
   270 /**
       
   271 @publishedAll
       
   272 @released
       
   273 */
       
   274 IMPORT_C unsigned long  htonl(unsigned long hl);
       
   275 
       
   276 
       
   277 #define ntohl	htonl
       
   278 #define ntohs	htons
       
   279 
       
   280 #ifdef	__cplusplus
       
   281 }
       
   282 #endif
       
   283 
       
   284 #endif	/* _NETINET_IN_H */