xref: /original-bsd/sys/netinet/ip_var.h (revision 860e07fc)
1 /*
2  * Copyright (c) 1982, 1986 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)ip_var.h	7.8 (Berkeley) 07/06/92
8  */
9 
10 /*
11  * Overlay for ip header used by other protocols (tcp, udp).
12  */
13 struct ipovly {
14 	caddr_t	ih_next, ih_prev;	/* for protocol sequence q's */
15 	u_char	ih_x1;			/* (unused) */
16 	u_char	ih_pr;			/* protocol */
17 	short	ih_len;			/* protocol length */
18 	struct	in_addr ih_src;		/* source internet address */
19 	struct	in_addr ih_dst;		/* destination internet address */
20 };
21 
22 /*
23  * Ip reassembly queue structure.  Each fragment
24  * being reassembled is attached to one of these structures.
25  * They are timed out after ipq_ttl drops to 0, and may also
26  * be reclaimed if memory becomes tight.
27  */
28 struct ipq {
29 	struct	ipq *next,*prev;	/* to other reass headers */
30 	u_char	ipq_ttl;		/* time for reass q to live */
31 	u_char	ipq_p;			/* protocol of this fragment */
32 	u_short	ipq_id;			/* sequence id for reassembly */
33 	struct	ipasfrag *ipq_next,*ipq_prev;
34 					/* to ip headers of fragments */
35 	struct	in_addr ipq_src,ipq_dst;
36 };
37 
38 /*
39  * Ip header, when holding a fragment.
40  *
41  * Note: ipf_next must be at same offset as ipq_next above
42  */
43 struct	ipasfrag {
44 #if BYTE_ORDER == LITTLE_ENDIAN
45 	u_char	ip_hl:4,
46 		ip_v:4;
47 #endif
48 #if BYTE_ORDER == BIG_ENDIAN
49 	u_char	ip_v:4,
50 		ip_hl:4;
51 #endif
52 	u_char	ipf_mff;		/* copied from (ip_off&IP_MF) */
53 	short	ip_len;
54 	u_short	ip_id;
55 	short	ip_off;
56 	u_char	ip_ttl;
57 	u_char	ip_p;
58 	u_short	ip_sum;
59 	struct	ipasfrag *ipf_next;	/* next fragment */
60 	struct	ipasfrag *ipf_prev;	/* previous fragment */
61 };
62 
63 /*
64  * Structure stored in mbuf in inpcb.ip_options
65  * and passed to ip_output when ip options are in use.
66  * The actual length of the options (including ipopt_dst)
67  * is in m_len.
68  */
69 #define MAX_IPOPTLEN	40
70 
71 struct ipoption {
72 	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
73 	char	ipopt_list[MAX_IPOPTLEN];	/* options proper */
74 };
75 
76 /*
77  * Structure attached to inpcb.ip_moptions and
78  * passed to ip_output when IP multicast options are in use.
79  */
80 struct ip_moptions {
81 	struct	ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
82 	u_char	imo_multicast_ttl;	/* TTL for outgoing multicasts */
83 	u_char	imo_multicast_loop;	/* 1 => hear sends if a member */
84 	u_short	imo_num_memberships;	/* no. memberships this socket */
85 	struct	in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
86 };
87 
88 struct	ipstat {
89 	long	ips_total;		/* total packets received */
90 	long	ips_badsum;		/* checksum bad */
91 	long	ips_tooshort;		/* packet too short */
92 	long	ips_toosmall;		/* not enough data */
93 	long	ips_badhlen;		/* ip header length < data size */
94 	long	ips_badlen;		/* ip length < ip header length */
95 	long	ips_fragments;		/* fragments received */
96 	long	ips_fragdropped;	/* frags dropped (dups, out of space) */
97 	long	ips_fragtimeout;	/* fragments timed out */
98 	long	ips_forward;		/* packets forwarded */
99 	long	ips_cantforward;	/* packets rcvd for unreachable dest */
100 	long	ips_redirectsent;	/* packets forwarded on same net */
101 	long	ips_noproto;		/* unknown or unsupported protocol */
102 	long	ips_delivered;		/* packets consumed here */
103 	long	ips_localout;		/* total ip packets generated here */
104 	long	ips_odropped;		/* lost packets due to nobufs, etc. */
105 	long	ips_reassembled;	/* total packets reassembled ok */
106 	long	ips_fragmented;		/* output packets fragmented ok */
107 	long	ips_ofragments;		/* output fragments created */
108 	long	ips_cantfrag;		/* don't fragment flag was set, etc. */
109 };
110 
111 #ifdef KERNEL
112 /* flags passed to ip_output as last parameter */
113 #define	IP_FORWARDING		0x1		/* most of ip header exists */
114 #define	IP_ROUTETOIF		SO_DONTROUTE	/* bypass routing tables */
115 #define	IP_ALLOWBROADCAST	SO_BROADCAST	/* can send broadcast packets */
116 
117 struct	ipstat	ipstat;
118 struct	ipq	ipq;			/* ip reass. queue */
119 u_short	ip_id;				/* ip packet ctr, for ids */
120 
121 struct	mbuf *ip_srcroute();
122 #endif
123