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