1 /*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the IP module.
7 *
8 * Version: @(#)ip.h 1.0.2 05/07/93
9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu>
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Alan Cox, <gw4pts@gw4pts.ampr.org>
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19 #ifndef _IP_H
20 #define _IP_H
21
22
23 #include <linux/config.h>
24 #include <linux/types.h>
25 #include <linux/socket.h>
26 #include <linux/ip.h>
27 #include <linux/netdevice.h>
28
29 #ifndef _SNMP_H
30 #include <net/snmp.h>
31 #endif
32
33 #include <net/sock.h> /* struct sock */
34
35 /* IP flags. */
36 #define IP_CE 0x8000 /* Flag: "Congestion" */
37 #define IP_DF 0x4000 /* Flag: "Don't Fragment" */
38 #define IP_MF 0x2000 /* Flag: "More Fragments" */
39 #define IP_OFFSET 0x1FFF /* "Fragment Offset" part */
40
41 #define IP_FRAG_TIME (30 * HZ) /* fragment lifetime */
42
43 #ifdef CONFIG_IP_MULTICAST
44 extern void ip_mc_dropsocket(struct sock *);
45 extern void ip_mc_dropdevice(struct device *dev);
46 extern int ip_mc_procinfo(char *, char **, off_t, int, int);
47 #endif
48
49
50 /* Describe an IP fragment. */
51 struct ipfrag
52 {
53 int offset; /* offset of fragment in IP datagram */
54 int end; /* last byte of data in datagram */
55 int len; /* length of this fragment */
56 struct sk_buff *skb; /* complete received fragment */
57 unsigned char *ptr; /* pointer into real fragment data */
58 struct ipfrag *next; /* linked list pointers */
59 struct ipfrag *prev;
60 };
61
62 /*
63 * Describe an entry in the "incomplete datagrams" queue.
64 */
65
66 struct ipq
67 {
68 unsigned char *mac; /* pointer to MAC header */
69 struct iphdr *iph; /* pointer to IP header */
70 int len; /* total length of original datagram */
71 short ihlen; /* length of the IP header */
72 short maclen; /* length of the MAC header */
73 struct timer_list timer; /* when will this queue expire? */
74 struct ipfrag *fragments; /* linked list of received fragments */
75 struct ipq *next; /* linked list pointers */
76 struct ipq *prev;
77 struct device *dev; /* Device - for icmp replies */
78 };
79
80 /*
81 * Functions provided by ip.c
82 */
83
84 extern void ip_print(const struct iphdr *ip);
85 extern int ip_ioctl(struct sock *sk, int cmd, unsigned long arg);
86 extern void ip_route_check(__u32 daddr);
87 extern int ip_send(struct sk_buff *skb, __u32 daddr, int len, struct device *dev, __u32 saddr);
88 extern int ip_build_header(struct sk_buff *skb,
89 __u32 saddr,
90 __u32 daddr,
91 struct device **dev, int type,
92 struct options *opt, int len,
93 int tos,int ttl);
94 extern int ip_rcv(struct sk_buff *skb, struct device *dev,
95 struct packet_type *pt);
96 extern int ip_options_echo(struct options * dopt, struct options * sopt,
97 __u32 daddr, __u32 saddr,
98 struct sk_buff * skb);
99 extern int ip_options_compile(struct options * opt, struct sk_buff * skb);
100 extern void ip_send_check(struct iphdr *ip);
101 extern int ip_id_count;
102 extern void ip_queue_xmit(struct sock *sk,
103 struct device *dev, struct sk_buff *skb,
104 int free);
105 extern void ip_init(void);
106 extern int ip_build_xmit(struct sock *sk,
107 void getfrag (const void *,
108 __u32,
109 char *,
110 unsigned int,
111 unsigned int),
112 const void *frag,
113 unsigned short int length,
114 __u32 daddr,
115 __u32 saddr,
116 struct options * opt,
117 int flags,
118 int type,
119 int noblock);
120
121 extern struct ip_mib ip_statistics;
122
123 /*
124 * Functions provided by ip_fragment.o
125 */
126
127 struct sk_buff *ip_defrag(struct iphdr *iph, struct sk_buff *skb, struct device *dev);
128 void ip_fragment(struct sock *sk, struct sk_buff *skb, struct device *dev, int is_frag);
129
130 /*
131 * Functions provided by ip_forward.c
132 */
133
134 extern int ip_forward(struct sk_buff *skb, struct device *dev, int is_frag, __u32 target_addr);
135
136 /*
137 * Functions provided by ip_options.c
138 */
139
140 extern void ip_options_build(struct sk_buff *skb, struct options *opt, __u32 daddr, __u32 saddr, int is_frag);
141 extern int ip_options_echo(struct options *dopt, struct options *sopt, __u32 daddr, __u32 saddr, struct sk_buff *skb);
142 extern void ip_options_fragment(struct sk_buff *skb);
143 extern int ip_options_compile(struct options *opt, struct sk_buff *skb);
144
145 /*
146 * Functions provided by ip_sockglue.c
147 */
148
149 extern int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen);
150 extern int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen);
151
152 #endif /* _IP_H */