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