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/ip.h>
24
25 #ifndef _SNMP_H
26 #include "snmp.h"
27 #endif
28
29 #include "sock.h" /* struct sock */
30
31 /* IP flags. */
32 #define IP_CE 0x8000 /* Flag: "Congestion" */
33 #define IP_DF 0x4000 /* Flag: "Don't Fragment" */
34 #define IP_MF 0x2000 /* Flag: "More Fragments" */
35 #define IP_OFFSET 0x1FFF /* "Fragment Offset" part */
36
37 #define IP_FRAG_TIME (30 * HZ) /* fragment lifetime */
38
39
40 /* Describe an IP fragment. */
41 struct ipfrag {
42 int offset; /* offset of fragment in IP datagram */
43 int end; /* last byte of data in datagram */
44 int len; /* length of this fragment */
45 struct sk_buff *skb; /* complete received fragment */
46 unsigned char *ptr; /* pointer into real fragment data */
47 struct ipfrag *next; /* linked list pointers */
48 struct ipfrag *prev;
49 };
50
51 /* Describe an entry in the "incomplete datagrams" queue. */
52 struct ipq {
53 unsigned char *mac; /* pointer to MAC header */
54 struct iphdr *iph; /* pointer to IP header */
55 int len; /* total length of original datagram */
56 short ihlen; /* length of the IP header */
57 short maclen; /* length of the MAC header */
58 struct timer_list timer; /* when will this queue expire? */
59 struct ipfrag *fragments; /* linked list of received fragments */
60 struct ipq *next; /* linked list pointers */
61 struct ipq *prev;
62 struct device *dev; /* Device - for icmp replies */
63 };
64
65
66 extern int backoff(int n);
67
68 extern void ip_print(const struct iphdr *ip);
69 extern int ip_ioctl(struct sock *sk, int cmd,
70 unsigned long arg);
71 extern void ip_route_check(unsigned long daddr);
72 extern int ip_build_header(struct sk_buff *skb,
73 unsigned long saddr,
74 unsigned long daddr,
75 struct device **dev, int type,
76 struct options *opt, int len,
77 int tos,int ttl);
78 extern unsigned short ip_compute_csum(unsigned char * buff, int len);
79 extern int ip_rcv(struct sk_buff *skb, struct device *dev,
80 struct packet_type *pt);
81 extern void ip_queue_xmit(struct sock *sk,
82 struct device *dev, struct sk_buff *skb,
83 int free);
84 extern void ip_retransmit(struct sock *sk, int all);
85 extern void ip_do_retransmit(struct sock *sk, int all);
86 extern int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen);
87 extern int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen);
88 extern void ip_init(void);
89
90 extern struct ip_mib ip_statistics;
91 #endif /* _IP_H */