1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LINCINET/IN.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,284 @@
1.4 +/* IN.H
1.5 + *
1.6 + * Portions Copyright (c) 1997-2006 Nokia Corporation and/or its subsidiary(-ies).
1.7 + * All rights reserved.
1.8 + */
1.9 +
1.10 +/** @file
1.11 +@PublishedAll
1.12 +*/
1.13 +
1.14 +/*
1.15 + * Copyright (c) 1982, 1986 Regents of the University of California.
1.16 + * All rights reserved.
1.17 + *
1.18 + * Redistribution and use in source and binary forms are permitted
1.19 + * provided that this notice is preserved and that due credit is given
1.20 + * to the University of California at Berkeley. The name of the University
1.21 + * may not be used to endorse or promote products derived from this
1.22 + * software without specific prior written permission. This software
1.23 + * is provided ``as is'' without express or implied warranty.
1.24 + */
1.25 +
1.26 +/*
1.27 + * Constants and structures defined by the internet system,
1.28 + * Per RFC 790, September 1981.
1.29 + */
1.30 +
1.31 +#ifndef _NETINET_IN_H
1.32 +#define _NETINET_IN_H
1.33 +
1.34 +#ifdef __cplusplus
1.35 +extern "C" {
1.36 +#endif
1.37 +#include <_ansi.h>
1.38 +
1.39 +/**
1.40 +Protocols
1.41 +*/
1.42 +#define IPPROTO_IP 0x100 /* dummy for IP */
1.43 +#define IPPROTO_ICMP 1 /* control message protocol */
1.44 +#define IPPROTO_IGMP 2 /* group control protocol */
1.45 +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
1.46 +#define IPPROTO_ENCAP 4 /* IP in IP encapsulation */
1.47 +#define IPPROTO_TCP 6 /* tcp */
1.48 +#define IPPROTO_EGP 8 /* exterior gateway protocol */
1.49 +#define IPPROTO_PUP 12 /* pup */
1.50 +#define IPPROTO_UDP 17 /* user datagram protocol */
1.51 +#define IPPROTO_IDP 22 /* xns idp */
1.52 +#define IPPROTO_HELLO 63 /* "hello" routing protocol */
1.53 +#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
1.54 +#define IPPROTO_EON 80 /* ISO clnp */
1.55 +#define IPPROTO_RAW 255 /* raw IP packet */
1.56 +#define IPPROTO_MAX 0x101
1.57 +
1.58 +/**
1.59 +Port/socket numbers: network standard functions
1.60 +*/
1.61 +#define IPPORT_ECHO 7
1.62 +#define IPPORT_DISCARD 9
1.63 +#define IPPORT_SYSTAT 11
1.64 +#define IPPORT_DAYTIME 13
1.65 +#define IPPORT_NETSTAT 15
1.66 +#define IPPORT_FTP 21
1.67 +#define IPPORT_TELNET 23
1.68 +#define IPPORT_SMTP 25
1.69 +#define IPPORT_TIMESERVER 37
1.70 +#define IPPORT_NAMESERVER 42
1.71 +#define IPPORT_WHOIS 43
1.72 +#define IPPORT_MTP 57
1.73 +
1.74 +/**
1.75 +Port/socket numbers: host specific functions
1.76 +*/
1.77 +#define IPPORT_TFTP 69
1.78 +#define IPPORT_RJE 77
1.79 +#define IPPORT_FINGER 79
1.80 +#define IPPORT_TTYLINK 87
1.81 +#define IPPORT_SUPDUP 95
1.82 +
1.83 +/**
1.84 +UNIX TCP sockets
1.85 +*/
1.86 +#define IPPORT_EXECSERVER 512
1.87 +#define IPPORT_LOGINSERVER 513
1.88 +#define IPPORT_CMDSERVER 514
1.89 +#define IPPORT_EFSSERVER 520
1.90 +
1.91 +/**
1.92 +UNIX UDP sockets
1.93 +*/
1.94 +#define IPPORT_BIFFUDP 512
1.95 +#define IPPORT_WHOSERVER 513
1.96 +#define IPPORT_ROUTESERVER 520 /* 520+1 also used */
1.97 +
1.98 +/**
1.99 +Ports < IPPORT_RESERVED are reserved for
1.100 +privileged processes (e.g. root).
1.101 +Ports > IPPORT_USERRESERVED are reserved
1.102 +for servers, not necessarily privileged.
1.103 +*/
1.104 +#define IPPORT_RESERVED 1024
1.105 +#define IPPORT_USERRESERVED 5000
1.106 +
1.107 +/**
1.108 +Link numbers
1.109 +*/
1.110 +#define IMPLINK_IP 155
1.111 +#define IMPLINK_LOWEXPER 156
1.112 +#define IMPLINK_HIGHEXPER 158
1.113 +
1.114 +/**
1.115 +Internet address
1.116 +This definition contains obsolete fields for compatibility
1.117 +with SunOS 3.x and 4.2bsd. The presence of subnets renders
1.118 +divisions into fixed fields misleading at best. New code
1.119 +should use only the s_addr field.
1.120 +@publishedAll
1.121 +@released
1.122 + */
1.123 +struct in_addr {
1.124 + union {
1.125 + struct { u_char s_b1, s_b2, s_b3, s_b4; } S_un_b;
1.126 + struct { u_short s_w1, s_w2; } S_un_w;
1.127 + u_long S_addr;
1.128 + } S_un;
1.129 +/**
1.130 +@publishedAll
1.131 +@released
1.132 +*/
1.133 +#define s_addr S_un.S_addr /* should be used for all code */
1.134 +/**
1.135 +@publishedAll
1.136 +@released
1.137 +*/
1.138 +#define s_host S_un.S_un_b.s_b2 /* OBSOLETE: host on imp */
1.139 +/**
1.140 +@publishedAll
1.141 +@released
1.142 +*/
1.143 +#define s_net S_un.S_un_b.s_b1 /* OBSOLETE: network */
1.144 +/**
1.145 +@publishedAll
1.146 +@released
1.147 +*/
1.148 +#define s_imp S_un.S_un_w.s_w2 /* OBSOLETE: imp */
1.149 +/**
1.150 +@publishedAll
1.151 +@released
1.152 +*/
1.153 +#define s_impno S_un.S_un_b.s_b4 /* OBSOLETE: imp # */
1.154 +/**
1.155 +@publishedAll
1.156 +@released
1.157 +*/
1.158 +#define s_lh S_un.S_un_b.s_b3 /* OBSOLETE: logical host */
1.159 +};
1.160 +
1.161 +/**
1.162 +Definitions of bits in internet address integers.
1.163 +On subnets, the decomposition of addresses to host and net parts
1.164 +is done according to subnet mask, not the masks here.
1.165 +*/
1.166 +#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
1.167 +#define IN_CLASSA_NET 0xff000000
1.168 +#define IN_CLASSA_NSHIFT 24
1.169 +#define IN_CLASSA_HOST 0x00ffffff
1.170 +#define IN_CLASSA_MAX 128
1.171 +
1.172 +#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
1.173 +#define IN_CLASSB_NET 0xffff0000
1.174 +#define IN_CLASSB_NSHIFT 16
1.175 +#define IN_CLASSB_HOST 0x0000ffff
1.176 +#define IN_CLASSB_MAX 65536
1.177 +
1.178 +#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
1.179 +#define IN_CLASSC_NET 0xffffff00
1.180 +#define IN_CLASSC_NSHIFT 8
1.181 +#define IN_CLASSC_HOST 0x000000ff
1.182 +#define IN_CLASSC_MAX 16777216L
1.183 +
1.184 +#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
1.185 +#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
1.186 +#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
1.187 +#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
1.188 +#define IN_MULTICAST(i) IN_CLASSD(i)
1.189 +
1.190 +#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
1.191 +#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
1.192 +
1.193 +#define INADDR_ANY (u_long)0x00000000
1.194 +#define INADDR_LOOPBACK (u_long)0x7F000001
1.195 +#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
1.196 +
1.197 +#define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */
1.198 +#define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */
1.199 +#define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */
1.200 +
1.201 +#define INADDR_NONE INADDR_BROADCAST /* traditional, but misleading */
1.202 +
1.203 +#define IN_LOOPBACKNET 127 /* official! */
1.204 +
1.205 +/**
1.206 +Define a macro to stuff the loopback address into an Internet address
1.207 +0x0100007F is htonl(INADDR_LOOPBACK) without the overhead of a function call.
1.208 +*/
1.209 +#define IN_SET_LOOPBACK_ADDR(a) \
1.210 + { (a)->sin_addr.s_addr = 0x0100007F; (a)->sin_family = AF_INET; }
1.211 +
1.212 +/**
1.213 +Socket address, internet style.
1.214 +*/
1.215 +struct sockaddr_in {
1.216 + u_short sin_family;
1.217 + u_short sin_port;
1.218 + struct in_addr sin_addr;
1.219 + char sin_zero[20];
1.220 +};
1.221 +
1.222 +/**
1.223 +* Options for use with [gs]etsockopt at the IP level.
1.224 +* NB. The negative option values below are not supported and must not
1.225 +* be used in calls to the [gs]etsockopt() API as they will be ignored
1.226 +* or cause an error.
1.227 +*/
1.228 +#define SOL_IP 0x100 /* options for IP level */
1.229 +
1.230 +#define IP_OPTIONS 0x306 /* set/get IP per-packet options */
1.231 +#define IP_HDRINCL 0x308 /* int; header is included with data (raw) */
1.232 +#define IP_TOS 0x309 /* int; IP type of service and precedence */
1.233 +#define IP_TTL 0x310 /* int; IP time to live */
1.234 +#define IP_RECVOPTS -1 /* bool; receive all IP options w/datagram */
1.235 +#define IP_RECVRETOPTS -2 /* bool; receive IP options for response */
1.236 +#define IP_RECVDSTADDR -3 /* bool; receive IP dst addr w/datagram */
1.237 +#define IP_RETOPTS -4 /* ip_opts; set/get IP per-packet options */
1.238 +#define IP_MULTICAST_IF -5 /* set/get IP multicast interface */
1.239 +#define IP_MULTICAST_TTL -6 /* set/get IP multicast timetolive */
1.240 +#define IP_MULTICAST_LOOP -7 /* set/get IP multicast loopback */
1.241 +#define IP_ADD_MEMBERSHIP -8 /* add an IP group membership */
1.242 +#define IP_DROP_MEMBERSHIP -9 /* drop an IP group membership */
1.243 +
1.244 +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
1.245 +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
1.246 +
1.247 +/**
1.248 +Options for use with [gs]etsockopt at the TCP level.
1.249 +*/
1.250 +#define SOL_TCP 0x106 /* options for TCP level */
1.251 +
1.252 +#define TCP_SENDWINDOW 0x301 /* int: send window size in bytes */
1.253 +#define TCP_RECVWINDOW 0x302 /* int: recv window size in bytes */
1.254 +#define TCP_NODELAY 0x304 /* disable Nagle's algorithm */
1.255 +#define TCP_KEEPALIVE 0x305 /* keep connections alive */
1.256 +
1.257 +/**
1.258 +Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
1.259 +@publishedAll
1.260 +@released
1.261 +*/
1.262 +struct ip_mreq {
1.263 + struct in_addr imr_multiaddr; /* IP multicast address of group */
1.264 + struct in_addr imr_interface; /* local IP address of interface */
1.265 +};
1.266 +
1.267 +/*
1.268 +EPOC32 is little-endian
1.269 +@publishedAll
1.270 +@released
1.271 +*/
1.272 +IMPORT_C unsigned short htons(unsigned short hs);
1.273 +/**
1.274 +@publishedAll
1.275 +@released
1.276 +*/
1.277 +IMPORT_C unsigned long htonl(unsigned long hl);
1.278 +
1.279 +
1.280 +#define ntohl htonl
1.281 +#define ntohs htons
1.282 +
1.283 +#ifdef __cplusplus
1.284 +}
1.285 +#endif
1.286 +
1.287 +#endif /* _NETINET_IN_H */