xref: /csrg-svn/sys/netinet/in.h (revision 8970)
1*8970Sroot /*	in.h	4.17	82/10/31	*/
24793Swnj 
34793Swnj /*
44793Swnj  * Constants and structures defined by the internet system,
54793Swnj  * Per RFC 790, September 1981.
64793Swnj  */
74793Swnj 
84793Swnj /*
94793Swnj  * Protocols
104793Swnj  */
114793Swnj #define	IPPROTO_ICMP		1		/* control message protocol */
125994Swnj #define	IPPROTO_GGP		2		/* gateway^2 (deprecated) */
134793Swnj #define	IPPROTO_TCP		6		/* tcp */
144793Swnj #define	IPPROTO_PUP		12		/* pup */
154793Swnj #define	IPPROTO_UDP		17		/* user datagram protocol */
164793Swnj 
175611Swnj #define	IPPROTO_RAW		255		/* raw IP packet */
184897Swnj #define	IPPROTO_MAX		256
194897Swnj 
204793Swnj /*
214793Swnj  * Port/socket numbers: network standard functions
224793Swnj  */
234793Swnj #define	IPPORT_ECHO		7
244793Swnj #define	IPPORT_DISCARD		9
254793Swnj #define	IPPORT_SYSTAT		11
264793Swnj #define	IPPORT_DAYTIME		13
274793Swnj #define	IPPORT_NETSTAT		15
284793Swnj #define	IPPORT_FTP		21
294793Swnj #define	IPPORT_TELNET		23
304793Swnj #define	IPPORT_SMTP		25
314793Swnj #define	IPPORT_TIMESERVER	37
324793Swnj #define	IPPORT_NAMESERVER	42
334793Swnj #define	IPPORT_WHOIS		43
344793Swnj #define	IPPORT_MTP		57
354793Swnj 
364793Swnj /*
374793Swnj  * Port/socket numbers: host specific functions
384793Swnj  */
394793Swnj #define	IPPORT_TFTP		69
404793Swnj #define	IPPORT_RJE		77
414793Swnj #define	IPPORT_FINGER		79
424793Swnj #define	IPPORT_TTYLINK		87
434793Swnj #define	IPPORT_SUPDUP		95
444793Swnj 
456229Sroot /*
466229Sroot  * UNIX TCP sockets
476229Sroot  */
486229Sroot #define	IPPORT_EXECSERVER	512
496229Sroot #define	IPPORT_LOGINSERVER	513
506229Sroot #define	IPPORT_CMDSERVER	514
517337Swnj #define	IPPORT_EFSSERVER	520
526229Sroot 
536229Sroot /*
546229Sroot  * UNIX UDP sockets
556229Sroot  */
566229Sroot #define	IPPORT_BIFFUDP		512
576229Sroot #define	IPPORT_WHOSERVER	513
587337Swnj #define	IPPORT_ROUTESERVER	520	/* 520+1 also used */
596229Sroot 
606229Sroot /*
616229Sroot  * Ports < IPPORT_RESERVED are reserved for
626229Sroot  * privileged processes (e.g. root).
636229Sroot  */
645994Swnj #define	IPPORT_RESERVED		1024
655994Swnj 
664793Swnj /*
674793Swnj  * Link numbers
684793Swnj  */
694793Swnj #define	IMPLINK_IP		155
704793Swnj #define	IMPLINK_LOWEXPER	156
714793Swnj #define	IMPLINK_HIGHEXPER	158
724793Swnj 
734793Swnj /*
744793Swnj  * Internet address (old style... should be updated)
754793Swnj  */
764922Swnj struct in_addr {
774793Swnj 	union {
784793Swnj 		struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
794793Swnj 		struct { u_short s_w1,s_w2; } S_un_w;
805683Ssam 		u_long S_addr;
814793Swnj 	} S_un;
825683Ssam #define	s_addr	S_un.S_addr	/* can be used for most tcp & ip code */
835683Ssam #ifdef vax
844793Swnj #define	s_host	S_un.S_un_b.s_b2	/* host on imp */
854793Swnj #define	s_net	S_un.S_un_b.s_b1	/* network */
864793Swnj #define	s_imp	S_un.S_un_w.s_w2	/* imp */
876045Swnj #define	s_impno	S_un.S_un_b.s_b4	/* imp # */
886045Swnj #define	s_lh	S_un.S_un_b.s_b3	/* logical host */
895683Ssam #endif
904793Swnj };
914922Swnj 
927034Swnj /*
938595Sroot  * Definitions of bits in internet address integers.
947034Swnj  */
958694Sroot #define	IN_CLASSA(i)		((((long)(i))&0x80000000)==0)
968595Sroot #define	IN_CLASSA_NET		0xff000000
978595Sroot #define	IN_CLASSA_NSHIFT	24
988595Sroot #define	IN_CLASSA_HOST		0x00ffffff
998595Sroot 
1008694Sroot #define	IN_CLASSB(i)		((((long)(i))&0xc0000000)==0x80000000)
1018595Sroot #define	IN_CLASSB_NET		0xffff0000
1028595Sroot #define	IN_CLASSB_NSHIFT	16
1038595Sroot #define	IN_CLASSB_HOST		0x0000ffff
1048595Sroot 
1058694Sroot #define	IN_CLASSC(i)		((((long)(i))&0xc0000000)==0xc0000000)
1068595Sroot #define	IN_CLASSC_NET		0xffffff00
1078595Sroot #define	IN_CLASSC_NSHIFT	8
1088595Sroot #define	IN_CLASSC_HOST		0x000000ff
1097034Swnj 
1105994Swnj #define	INADDR_ANY	0x00000000
1115994Swnj 
1124922Swnj /*
1134922Swnj  * Socket address, internet style.
1144922Swnj  */
1154922Swnj struct sockaddr_in {
1164922Swnj 	short	sin_family;
1174922Swnj 	u_short	sin_port;
1184922Swnj 	struct	in_addr sin_addr;
1194922Swnj 	char	sin_zero[8];
1204922Swnj };
121*8970Sroot 
122*8970Sroot #if !defined(vax)
123*8970Sroot /*
124*8970Sroot  * Macros for number representation conversion.
125*8970Sroot  */
126*8970Sroot #define	ntohl(x)	(x)
127*8970Sroot #define	ntohs(x)	(x)
128*8970Sroot #define	htonl(x)	(x)
129*8970Sroot #define	htons(x)	(x)
130*8970Sroot #endif
131