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 int offset; /* offset of fragment in IP datagram */
53 int end; /* last byte of data in datagram */
54 int len; /* length of this fragment */
55 struct sk_buff *skb; /* complete received fragment */
56 unsigned char *ptr; /* pointer into real fragment data */
57 struct ipfrag *next; /* linked list pointers */
58 struct ipfrag *prev;
59 };
60
61 /* Describe an entry in the "incomplete datagrams" queue. */
62 struct ipq {
63 unsigned char *mac; /* pointer to MAC header */
64 struct iphdr *iph; /* pointer to IP header */
65 int len; /* total length of original datagram */
66 short ihlen; /* length of the IP header */
67 short maclen; /* length of the MAC header */
68 struct timer_list timer; /* when will this queue expire? */
69 struct ipfrag *fragments; /* linked list of received fragments */
70 struct ipq *next; /* linked list pointers */
71 struct ipq *prev;
72 struct device *dev; /* Device - for icmp replies */
73 };
74
75
76 extern void ip_print(const struct iphdr *ip);
77 extern int ip_ioctl(struct sock *sk, int cmd,
78 unsigned long arg);
79 extern void ip_route_check(__u32 daddr);
80 extern int ip_build_header(struct sk_buff *skb,
81 __u32 saddr,
82 __u32 daddr,
83 struct device **dev, int type,
84 struct options *opt, int len,
85 int tos,int ttl);
86 /*extern unsigned short ip_compute_csum(unsigned char * buff, int len);*/
87 extern int ip_rcv(struct sk_buff *skb, struct device *dev,
88 struct packet_type *pt);
89 extern int ip_forward(struct sk_buff *skb, struct device *dev, int is_frag, unsigned long target_addr, int target_strict);
90 extern void ip_send_check(struct iphdr *ip);
91 extern int ip_id_count;
92 extern void ip_queue_xmit(struct sock *sk,
93 struct device *dev, struct sk_buff *skb,
94 int free);
95 extern int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen);
96 extern int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen);
97 extern void ip_init(void);
98 extern int ip_build_xmit(struct sock *sk,
99 void getfrag (const void *,
100 __u32,
101 char *,
102 unsigned int,
103 unsigned int),
104 const void *frag,
105 unsigned short int length,
106 __u32 daddr,
107 int flags,
108 int type);
109
110 extern struct ip_mib ip_statistics;
111
112 #endif /* _IP_H */