ioctl cmd arg is u_long
[unix-history] / usr / src / sys / netinet / ip_var.h
CommitLineData
8ae0e4b4 1/*
e7a3707f
KB
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
8ae0e4b4 4 *
dbf0c423 5 * %sccs.include.redist.c%
2b6b6284 6 *
b47fe08a 7 * @(#)ip_var.h 8.2 (Berkeley) %G%
8ae0e4b4 8 */
77e50f35
BJ
9
10/*
11 * Overlay for ip header used by other protocols (tcp, udp).
12 */
13struct ipovly {
eb44bfb2
BJ
14 caddr_t ih_next, ih_prev; /* for protocol sequence q's */
15 u_char ih_x1; /* (unused) */
16 u_char ih_pr; /* protocol */
2b4b57cd
BJ
17 short ih_len; /* protocol length */
18 struct in_addr ih_src; /* source internet address */
19 struct in_addr ih_dst; /* destination internet address */
77e50f35
BJ
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 */
28struct 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 */
2b4b57cd 35 struct in_addr ipq_src,ipq_dst;
77e50f35
BJ
36};
37
38/*
39 * Ip header, when holding a fragment.
af8f6a21
SL
40 *
41 * Note: ipf_next must be at same offset as ipq_next above
77e50f35
BJ
42 */
43struct ipasfrag {
f8b9a4f5 44#if BYTE_ORDER == LITTLE_ENDIAN
77e50f35
BJ
45 u_char ip_hl:4,
46 ip_v:4;
f112c673 47#endif
f8b9a4f5 48#if BYTE_ORDER == BIG_ENDIAN
f112c673
MK
49 u_char ip_v:4,
50 ip_hl:4;
498aff44 51#endif
44d05a3b
AC
52 u_char ipf_mff; /* XXX overlays ip_tos: use low bit
53 * to avoid destroying tos;
54 * copied from (ip_off&IP_MF) */
77e50f35
BJ
55 short ip_len;
56 u_short ip_id;
57 short ip_off;
58 u_char ip_ttl;
59 u_char ip_p;
60 u_short ip_sum;
eb44bfb2
BJ
61 struct ipasfrag *ipf_next; /* next fragment */
62 struct ipasfrag *ipf_prev; /* previous fragment */
77e50f35
BJ
63};
64
8b2d0afb
MK
65/*
66 * Structure stored in mbuf in inpcb.ip_options
67 * and passed to ip_output when ip options are in use.
68 * The actual length of the options (including ipopt_dst)
69 * is in m_len.
70 */
71#define MAX_IPOPTLEN 40
72
73struct ipoption {
74 struct in_addr ipopt_dst; /* first-hop dst if source routed */
75 char ipopt_list[MAX_IPOPTLEN]; /* options proper */
76};
77
d6fa15c2
KS
78/*
79 * Structure attached to inpcb.ip_moptions and
80 * passed to ip_output when IP multicast options are in use.
81 */
82struct ip_moptions {
83 struct ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
84 u_char imo_multicast_ttl; /* TTL for outgoing multicasts */
85 u_char imo_multicast_loop; /* 1 => hear sends if a member */
86 u_short imo_num_memberships; /* no. memberships this socket */
87 struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
88};
89
2b4b57cd 90struct ipstat {
69d96ae2
AC
91 u_long ips_total; /* total packets received */
92 u_long ips_badsum; /* checksum bad */
93 u_long ips_tooshort; /* packet too short */
94 u_long ips_toosmall; /* not enough data */
95 u_long ips_badhlen; /* ip header length < data size */
96 u_long ips_badlen; /* ip length < ip header length */
97 u_long ips_fragments; /* fragments received */
98 u_long ips_fragdropped; /* frags dropped (dups, out of space) */
99 u_long ips_fragtimeout; /* fragments timed out */
100 u_long ips_forward; /* packets forwarded */
101 u_long ips_cantforward; /* packets rcvd for unreachable dest */
102 u_long ips_redirectsent; /* packets forwarded on same net */
103 u_long ips_noproto; /* unknown or unsupported protocol */
104 u_long ips_delivered; /* datagrams delivered to upper level*/
105 u_long ips_localout; /* total ip packets generated here */
106 u_long ips_odropped; /* lost packets due to nobufs, etc. */
107 u_long ips_reassembled; /* total packets reassembled ok */
108 u_long ips_fragmented; /* datagrams sucessfully fragmented */
109 u_long ips_ofragments; /* output fragments created */
110 u_long ips_cantfrag; /* don't fragment flag was set, etc. */
111 u_long ips_badoptions; /* error in option processing */
44d05a3b
AC
112 u_long ips_noroute; /* packets discarded due to no route */
113 u_long ips_badvers; /* ip version != 4 */
114 u_long ips_rawout; /* total raw ip packets generated */
2b4b57cd
BJ
115};
116
77e50f35 117#ifdef KERNEL
0e3f761f 118/* flags passed to ip_output as last parameter */
8f45cd54 119#define IP_FORWARDING 0x1 /* most of ip header exists */
44d05a3b 120#define IP_RAWOUTPUT 0x2 /* raw ip header exists */
8f45cd54
MK
121#define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */
122#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
0e3f761f 123
2b4b57cd 124struct ipstat ipstat;
77e50f35 125struct ipq ipq; /* ip reass. queue */
77e50f35 126u_short ip_id; /* ip packet ctr, for ids */
7b6b1eb1 127int ip_defttl; /* default IP ttl */
8b2d0afb 128
b47fe08a 129int in_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
c46785cb
KB
130int ip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
131void ip_deq __P((struct ipasfrag *));
132int ip_dooptions __P((struct mbuf *));
133void ip_drain __P((void));
134void ip_enq __P((struct ipasfrag *, struct ipasfrag *));
135void ip_forward __P((struct mbuf *, int));
136void ip_freef __P((struct ipq *));
137void ip_freemoptions __P((struct ip_moptions *));
138int ip_getmoptions __P((int, struct ip_moptions *, struct mbuf **));
139void ip_init __P((void));
140int ip_mforward __P((struct mbuf *, struct ifnet *));
141int ip_optcopy __P((struct ip *, struct ip *));
142int ip_output __P((struct mbuf *,
143 struct mbuf *, struct route *, int, struct ip_moptions *));
144int ip_pcbopts __P((struct mbuf **, struct mbuf *));
145struct ip *
146 ip_reass __P((struct ipasfrag *, struct ipq *));
147struct in_ifaddr *
148 ip_rtaddr __P((struct in_addr));
149int ip_setmoptions __P((int, struct ip_moptions **, struct mbuf *));
150void ip_slowtimo __P((void));
151struct mbuf *
152 ip_srcroute __P((void));
153void ip_stripoptions __P((struct mbuf *, struct mbuf *));
154int ip_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
155void ipintr __P((void));
156int rip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
157void rip_init __P((void));
158void rip_input __P((struct mbuf *));
159int rip_output __P((struct mbuf *, struct socket *, u_long));
160int rip_usrreq __P((struct socket *,
161 int, struct mbuf *, struct mbuf *, struct mbuf *));
77e50f35 162#endif