sl@0: /* IN.H sl@0: * sl@0: * Portions Copyright (c) 1997-2006 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: */ sl@0: sl@0: /** @file sl@0: @PublishedAll sl@0: */ sl@0: sl@0: /* sl@0: * Copyright (c) 1982, 1986 Regents of the University of California. sl@0: * All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms are permitted sl@0: * provided that this notice is preserved and that due credit is given sl@0: * to the University of California at Berkeley. The name of the University sl@0: * may not be used to endorse or promote products derived from this sl@0: * software without specific prior written permission. This software sl@0: * is provided ``as is'' without express or implied warranty. sl@0: */ sl@0: sl@0: /* sl@0: * Constants and structures defined by the internet system, sl@0: * Per RFC 790, September 1981. sl@0: */ sl@0: sl@0: #ifndef _NETINET_IN_H sl@0: #define _NETINET_IN_H sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: #include <_ansi.h> sl@0: sl@0: /** sl@0: Protocols sl@0: */ sl@0: #define IPPROTO_IP 0x100 /* dummy for IP */ sl@0: #define IPPROTO_ICMP 1 /* control message protocol */ sl@0: #define IPPROTO_IGMP 2 /* group control protocol */ sl@0: #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ sl@0: #define IPPROTO_ENCAP 4 /* IP in IP encapsulation */ sl@0: #define IPPROTO_TCP 6 /* tcp */ sl@0: #define IPPROTO_EGP 8 /* exterior gateway protocol */ sl@0: #define IPPROTO_PUP 12 /* pup */ sl@0: #define IPPROTO_UDP 17 /* user datagram protocol */ sl@0: #define IPPROTO_IDP 22 /* xns idp */ sl@0: #define IPPROTO_HELLO 63 /* "hello" routing protocol */ sl@0: #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ sl@0: #define IPPROTO_EON 80 /* ISO clnp */ sl@0: #define IPPROTO_RAW 255 /* raw IP packet */ sl@0: #define IPPROTO_MAX 0x101 sl@0: sl@0: /** sl@0: Port/socket numbers: network standard functions sl@0: */ sl@0: #define IPPORT_ECHO 7 sl@0: #define IPPORT_DISCARD 9 sl@0: #define IPPORT_SYSTAT 11 sl@0: #define IPPORT_DAYTIME 13 sl@0: #define IPPORT_NETSTAT 15 sl@0: #define IPPORT_FTP 21 sl@0: #define IPPORT_TELNET 23 sl@0: #define IPPORT_SMTP 25 sl@0: #define IPPORT_TIMESERVER 37 sl@0: #define IPPORT_NAMESERVER 42 sl@0: #define IPPORT_WHOIS 43 sl@0: #define IPPORT_MTP 57 sl@0: sl@0: /** sl@0: Port/socket numbers: host specific functions sl@0: */ sl@0: #define IPPORT_TFTP 69 sl@0: #define IPPORT_RJE 77 sl@0: #define IPPORT_FINGER 79 sl@0: #define IPPORT_TTYLINK 87 sl@0: #define IPPORT_SUPDUP 95 sl@0: sl@0: /** sl@0: UNIX TCP sockets sl@0: */ sl@0: #define IPPORT_EXECSERVER 512 sl@0: #define IPPORT_LOGINSERVER 513 sl@0: #define IPPORT_CMDSERVER 514 sl@0: #define IPPORT_EFSSERVER 520 sl@0: sl@0: /** sl@0: UNIX UDP sockets sl@0: */ sl@0: #define IPPORT_BIFFUDP 512 sl@0: #define IPPORT_WHOSERVER 513 sl@0: #define IPPORT_ROUTESERVER 520 /* 520+1 also used */ sl@0: sl@0: /** sl@0: Ports < IPPORT_RESERVED are reserved for sl@0: privileged processes (e.g. root). sl@0: Ports > IPPORT_USERRESERVED are reserved sl@0: for servers, not necessarily privileged. sl@0: */ sl@0: #define IPPORT_RESERVED 1024 sl@0: #define IPPORT_USERRESERVED 5000 sl@0: sl@0: /** sl@0: Link numbers sl@0: */ sl@0: #define IMPLINK_IP 155 sl@0: #define IMPLINK_LOWEXPER 156 sl@0: #define IMPLINK_HIGHEXPER 158 sl@0: sl@0: /** sl@0: Internet address sl@0: This definition contains obsolete fields for compatibility sl@0: with SunOS 3.x and 4.2bsd. The presence of subnets renders sl@0: divisions into fixed fields misleading at best. New code sl@0: should use only the s_addr field. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: struct in_addr { sl@0: union { sl@0: struct { u_char s_b1, s_b2, s_b3, s_b4; } S_un_b; sl@0: struct { u_short s_w1, s_w2; } S_un_w; sl@0: u_long S_addr; sl@0: } S_un; sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define s_addr S_un.S_addr /* should be used for all code */ sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define s_host S_un.S_un_b.s_b2 /* OBSOLETE: host on imp */ sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define s_net S_un.S_un_b.s_b1 /* OBSOLETE: network */ sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define s_imp S_un.S_un_w.s_w2 /* OBSOLETE: imp */ sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define s_impno S_un.S_un_b.s_b4 /* OBSOLETE: imp # */ sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: #define s_lh S_un.S_un_b.s_b3 /* OBSOLETE: logical host */ sl@0: }; sl@0: sl@0: /** sl@0: Definitions of bits in internet address integers. sl@0: On subnets, the decomposition of addresses to host and net parts sl@0: is done according to subnet mask, not the masks here. sl@0: */ sl@0: #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) sl@0: #define IN_CLASSA_NET 0xff000000 sl@0: #define IN_CLASSA_NSHIFT 24 sl@0: #define IN_CLASSA_HOST 0x00ffffff sl@0: #define IN_CLASSA_MAX 128 sl@0: sl@0: #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) sl@0: #define IN_CLASSB_NET 0xffff0000 sl@0: #define IN_CLASSB_NSHIFT 16 sl@0: #define IN_CLASSB_HOST 0x0000ffff sl@0: #define IN_CLASSB_MAX 65536 sl@0: sl@0: #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) sl@0: #define IN_CLASSC_NET 0xffffff00 sl@0: #define IN_CLASSC_NSHIFT 8 sl@0: #define IN_CLASSC_HOST 0x000000ff sl@0: #define IN_CLASSC_MAX 16777216L sl@0: sl@0: #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) sl@0: #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ sl@0: #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ sl@0: #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ sl@0: #define IN_MULTICAST(i) IN_CLASSD(i) sl@0: sl@0: #define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000) sl@0: #define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000) sl@0: sl@0: #define INADDR_ANY (u_long)0x00000000 sl@0: #define INADDR_LOOPBACK (u_long)0x7F000001 sl@0: #define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ sl@0: sl@0: #define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */ sl@0: #define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */ sl@0: #define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */ sl@0: sl@0: #define INADDR_NONE INADDR_BROADCAST /* traditional, but misleading */ sl@0: sl@0: #define IN_LOOPBACKNET 127 /* official! */ sl@0: sl@0: /** sl@0: Define a macro to stuff the loopback address into an Internet address sl@0: 0x0100007F is htonl(INADDR_LOOPBACK) without the overhead of a function call. sl@0: */ sl@0: #define IN_SET_LOOPBACK_ADDR(a) \ sl@0: { (a)->sin_addr.s_addr = 0x0100007F; (a)->sin_family = AF_INET; } sl@0: sl@0: /** sl@0: Socket address, internet style. sl@0: */ sl@0: struct sockaddr_in { sl@0: u_short sin_family; sl@0: u_short sin_port; sl@0: struct in_addr sin_addr; sl@0: char sin_zero[20]; sl@0: }; sl@0: sl@0: /** sl@0: * Options for use with [gs]etsockopt at the IP level. sl@0: * NB. The negative option values below are not supported and must not sl@0: * be used in calls to the [gs]etsockopt() API as they will be ignored sl@0: * or cause an error. sl@0: */ sl@0: #define SOL_IP 0x100 /* options for IP level */ sl@0: sl@0: #define IP_OPTIONS 0x306 /* set/get IP per-packet options */ sl@0: #define IP_HDRINCL 0x308 /* int; header is included with data (raw) */ sl@0: #define IP_TOS 0x309 /* int; IP type of service and precedence */ sl@0: #define IP_TTL 0x310 /* int; IP time to live */ sl@0: #define IP_RECVOPTS -1 /* bool; receive all IP options w/datagram */ sl@0: #define IP_RECVRETOPTS -2 /* bool; receive IP options for response */ sl@0: #define IP_RECVDSTADDR -3 /* bool; receive IP dst addr w/datagram */ sl@0: #define IP_RETOPTS -4 /* ip_opts; set/get IP per-packet options */ sl@0: #define IP_MULTICAST_IF -5 /* set/get IP multicast interface */ sl@0: #define IP_MULTICAST_TTL -6 /* set/get IP multicast timetolive */ sl@0: #define IP_MULTICAST_LOOP -7 /* set/get IP multicast loopback */ sl@0: #define IP_ADD_MEMBERSHIP -8 /* add an IP group membership */ sl@0: #define IP_DROP_MEMBERSHIP -9 /* drop an IP group membership */ sl@0: sl@0: #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ sl@0: #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ sl@0: sl@0: /** sl@0: Options for use with [gs]etsockopt at the TCP level. sl@0: */ sl@0: #define SOL_TCP 0x106 /* options for TCP level */ sl@0: sl@0: #define TCP_SENDWINDOW 0x301 /* int: send window size in bytes */ sl@0: #define TCP_RECVWINDOW 0x302 /* int: recv window size in bytes */ sl@0: #define TCP_NODELAY 0x304 /* disable Nagle's algorithm */ sl@0: #define TCP_KEEPALIVE 0x305 /* keep connections alive */ sl@0: sl@0: /** sl@0: Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: struct ip_mreq { sl@0: struct in_addr imr_multiaddr; /* IP multicast address of group */ sl@0: struct in_addr imr_interface; /* local IP address of interface */ sl@0: }; sl@0: sl@0: /* sl@0: EPOC32 is little-endian sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: IMPORT_C unsigned short htons(unsigned short hs); sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: IMPORT_C unsigned long htonl(unsigned long hl); sl@0: sl@0: sl@0: #define ntohl htonl sl@0: #define ntohs htons sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: sl@0: #endif /* _NETINET_IN_H */