xref: /openbmc/linux/include/net/ip.h (revision 7eb95156)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * INET		An implementation of the TCP/IP protocol suite for the LINUX
31da177e4SLinus Torvalds  *		operating system.  INET is implemented using the  BSD Socket
41da177e4SLinus Torvalds  *		interface as the means of communication with the user level.
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  *		Definitions for the IP module.
71da177e4SLinus Torvalds  *
81da177e4SLinus Torvalds  * Version:	@(#)ip.h	1.0.2	05/07/93
91da177e4SLinus Torvalds  *
1002c30a84SJesper Juhl  * Authors:	Ross Biro
111da177e4SLinus Torvalds  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
121da177e4SLinus Torvalds  *		Alan Cox, <gw4pts@gw4pts.ampr.org>
131da177e4SLinus Torvalds  *
141da177e4SLinus Torvalds  * Changes:
151da177e4SLinus Torvalds  *		Mike McLagan    :       Routing by source
161da177e4SLinus Torvalds  *
171da177e4SLinus Torvalds  *		This program is free software; you can redistribute it and/or
181da177e4SLinus Torvalds  *		modify it under the terms of the GNU General Public License
191da177e4SLinus Torvalds  *		as published by the Free Software Foundation; either version
201da177e4SLinus Torvalds  *		2 of the License, or (at your option) any later version.
211da177e4SLinus Torvalds  */
221da177e4SLinus Torvalds #ifndef _IP_H
231da177e4SLinus Torvalds #define _IP_H
241da177e4SLinus Torvalds 
251da177e4SLinus Torvalds #include <linux/types.h>
261da177e4SLinus Torvalds #include <linux/ip.h>
271da177e4SLinus Torvalds #include <linux/in.h>
28c9bdd4b5SArnaldo Carvalho de Melo #include <linux/skbuff.h>
2914c85021SArnaldo Carvalho de Melo 
3014c85021SArnaldo Carvalho de Melo #include <net/inet_sock.h>
311da177e4SLinus Torvalds #include <net/snmp.h>
321da177e4SLinus Torvalds 
331da177e4SLinus Torvalds struct sock;
341da177e4SLinus Torvalds 
351da177e4SLinus Torvalds struct inet_skb_parm
361da177e4SLinus Torvalds {
371da177e4SLinus Torvalds 	struct ip_options	opt;		/* Compiled IP options		*/
381da177e4SLinus Torvalds 	unsigned char		flags;
391da177e4SLinus Torvalds 
408cdfab8aSPatrick McHardy #define IPSKB_FORWARDED		1
418cdfab8aSPatrick McHardy #define IPSKB_XFRM_TUNNEL_SIZE	2
423e3850e9SPatrick McHardy #define IPSKB_XFRM_TRANSFORMED	4
433e3850e9SPatrick McHardy #define IPSKB_FRAG_COMPLETE	8
4448d5cad8SPatrick McHardy #define IPSKB_REROUTED		16
451da177e4SLinus Torvalds };
461da177e4SLinus Torvalds 
47c9bdd4b5SArnaldo Carvalho de Melo static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
48c9bdd4b5SArnaldo Carvalho de Melo {
49eddc9ec5SArnaldo Carvalho de Melo 	return ip_hdr(skb)->ihl * 4;
50c9bdd4b5SArnaldo Carvalho de Melo }
51c9bdd4b5SArnaldo Carvalho de Melo 
521da177e4SLinus Torvalds struct ipcm_cookie
531da177e4SLinus Torvalds {
54c1d18f9fSAl Viro 	__be32			addr;
551da177e4SLinus Torvalds 	int			oif;
561da177e4SLinus Torvalds 	struct ip_options	*opt;
571da177e4SLinus Torvalds };
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds #define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb))
601da177e4SLinus Torvalds 
611da177e4SLinus Torvalds struct ip_ra_chain
621da177e4SLinus Torvalds {
631da177e4SLinus Torvalds 	struct ip_ra_chain	*next;
641da177e4SLinus Torvalds 	struct sock		*sk;
651da177e4SLinus Torvalds 	void			(*destructor)(struct sock *);
661da177e4SLinus Torvalds };
671da177e4SLinus Torvalds 
681da177e4SLinus Torvalds extern struct ip_ra_chain *ip_ra_chain;
691da177e4SLinus Torvalds extern rwlock_t ip_ra_lock;
701da177e4SLinus Torvalds 
711da177e4SLinus Torvalds /* IP flags. */
721da177e4SLinus Torvalds #define IP_CE		0x8000		/* Flag: "Congestion"		*/
731da177e4SLinus Torvalds #define IP_DF		0x4000		/* Flag: "Don't Fragment"	*/
741da177e4SLinus Torvalds #define IP_MF		0x2000		/* Flag: "More Fragments"	*/
751da177e4SLinus Torvalds #define IP_OFFSET	0x1FFF		/* "Fragment Offset" part	*/
761da177e4SLinus Torvalds 
771da177e4SLinus Torvalds #define IP_FRAG_TIME	(30 * HZ)		/* fragment lifetime	*/
781da177e4SLinus Torvalds 
7914c85021SArnaldo Carvalho de Melo struct msghdr;
8014c85021SArnaldo Carvalho de Melo struct net_device;
8114c85021SArnaldo Carvalho de Melo struct packet_type;
8214c85021SArnaldo Carvalho de Melo struct rtable;
8314c85021SArnaldo Carvalho de Melo struct sockaddr;
8414c85021SArnaldo Carvalho de Melo 
851da177e4SLinus Torvalds extern void		ip_mc_dropsocket(struct sock *);
861da177e4SLinus Torvalds extern void		ip_mc_dropdevice(struct net_device *dev);
871da177e4SLinus Torvalds extern int		igmp_mc_proc_init(void);
881da177e4SLinus Torvalds 
891da177e4SLinus Torvalds /*
901da177e4SLinus Torvalds  *	Functions provided by ip.c
911da177e4SLinus Torvalds  */
921da177e4SLinus Torvalds 
931da177e4SLinus Torvalds extern int		ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
9413d8eaa0SAl Viro 					      __be32 saddr, __be32 daddr,
951da177e4SLinus Torvalds 					      struct ip_options *opt);
961da177e4SLinus Torvalds extern int		ip_rcv(struct sk_buff *skb, struct net_device *dev,
97f2ccd8faSDavid S. Miller 			       struct packet_type *pt, struct net_device *orig_dev);
981da177e4SLinus Torvalds extern int		ip_local_deliver(struct sk_buff *skb);
991da177e4SLinus Torvalds extern int		ip_mr_input(struct sk_buff *skb);
1001da177e4SLinus Torvalds extern int		ip_output(struct sk_buff *skb);
1011da177e4SLinus Torvalds extern int		ip_mc_output(struct sk_buff *skb);
1022e2f7aefSPatrick McHardy extern int		ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
1031da177e4SLinus Torvalds extern int		ip_do_nat(struct sk_buff *skb);
1041da177e4SLinus Torvalds extern void		ip_send_check(struct iphdr *ip);
105e89862f4SDavid S. Miller extern int		ip_queue_xmit(struct sk_buff *skb, int ipfragok);
1061da177e4SLinus Torvalds extern void		ip_init(void);
1071da177e4SLinus Torvalds extern int		ip_append_data(struct sock *sk,
1081da177e4SLinus Torvalds 				       int getfrag(void *from, char *to, int offset, int len,
1091da177e4SLinus Torvalds 						   int odd, struct sk_buff *skb),
1101da177e4SLinus Torvalds 				void *from, int len, int protolen,
1111da177e4SLinus Torvalds 				struct ipcm_cookie *ipc,
1121da177e4SLinus Torvalds 				struct rtable *rt,
1131da177e4SLinus Torvalds 				unsigned int flags);
1141da177e4SLinus Torvalds extern int		ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb);
1151da177e4SLinus Torvalds extern ssize_t		ip_append_page(struct sock *sk, struct page *page,
1161da177e4SLinus Torvalds 				int offset, size_t size, int flags);
1171da177e4SLinus Torvalds extern int		ip_push_pending_frames(struct sock *sk);
1181da177e4SLinus Torvalds extern void		ip_flush_pending_frames(struct sock *sk);
1191da177e4SLinus Torvalds 
1201da177e4SLinus Torvalds /* datagram.c */
1211da177e4SLinus Torvalds extern int		ip4_datagram_connect(struct sock *sk,
1221da177e4SLinus Torvalds 					     struct sockaddr *uaddr, int addr_len);
1231da177e4SLinus Torvalds 
1241da177e4SLinus Torvalds /*
1251da177e4SLinus Torvalds  *	Map a multicast IP onto multicast MAC for type Token Ring.
1261da177e4SLinus Torvalds  *      This conforms to RFC1469 Option 2 Multicasting i.e.
1271da177e4SLinus Torvalds  *      using a functional address to transmit / receive
1281da177e4SLinus Torvalds  *      multicast packets.
1291da177e4SLinus Torvalds  */
1301da177e4SLinus Torvalds 
131714e85beSAl Viro static inline void ip_tr_mc_map(__be32 addr, char *buf)
1321da177e4SLinus Torvalds {
1331da177e4SLinus Torvalds 	buf[0]=0xC0;
1341da177e4SLinus Torvalds 	buf[1]=0x00;
1351da177e4SLinus Torvalds 	buf[2]=0x00;
1361da177e4SLinus Torvalds 	buf[3]=0x04;
1371da177e4SLinus Torvalds 	buf[4]=0x00;
1381da177e4SLinus Torvalds 	buf[5]=0x00;
1391da177e4SLinus Torvalds }
1401da177e4SLinus Torvalds 
1411da177e4SLinus Torvalds struct ip_reply_arg {
1421da177e4SLinus Torvalds 	struct kvec iov[1];
143d6f5493cSAl Viro 	__wsum 	    csum;
1441da177e4SLinus Torvalds 	int	    csumoffset; /* u16 offset of csum in iov[0].iov_base */
1451da177e4SLinus Torvalds 				/* -1 if not needed */
146f0e48dbfSPatrick McHardy 	int	    bound_dev_if;
1471da177e4SLinus Torvalds };
1481da177e4SLinus Torvalds 
1491da177e4SLinus Torvalds void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *arg,
1501da177e4SLinus Torvalds 		   unsigned int len);
1511da177e4SLinus Torvalds 
1521da177e4SLinus Torvalds struct ipv4_config
1531da177e4SLinus Torvalds {
1541da177e4SLinus Torvalds 	int	log_martians;
1551da177e4SLinus Torvalds 	int	no_pmtu_disc;
1561da177e4SLinus Torvalds };
1571da177e4SLinus Torvalds 
1581da177e4SLinus Torvalds extern struct ipv4_config ipv4_config;
1591da177e4SLinus Torvalds DECLARE_SNMP_STAT(struct ipstats_mib, ip_statistics);
1601da177e4SLinus Torvalds #define IP_INC_STATS(field)		SNMP_INC_STATS(ip_statistics, field)
1611da177e4SLinus Torvalds #define IP_INC_STATS_BH(field)		SNMP_INC_STATS_BH(ip_statistics, field)
1621da177e4SLinus Torvalds #define IP_INC_STATS_USER(field) 	SNMP_INC_STATS_USER(ip_statistics, field)
1631da177e4SLinus Torvalds DECLARE_SNMP_STAT(struct linux_mib, net_statistics);
1641da177e4SLinus Torvalds #define NET_INC_STATS(field)		SNMP_INC_STATS(net_statistics, field)
1651da177e4SLinus Torvalds #define NET_INC_STATS_BH(field)		SNMP_INC_STATS_BH(net_statistics, field)
1661da177e4SLinus Torvalds #define NET_INC_STATS_USER(field) 	SNMP_INC_STATS_USER(net_statistics, field)
1671da177e4SLinus Torvalds #define NET_ADD_STATS_BH(field, adnd)	SNMP_ADD_STATS_BH(net_statistics, field, adnd)
1681da177e4SLinus Torvalds #define NET_ADD_STATS_USER(field, adnd)	SNMP_ADD_STATS_USER(net_statistics, field, adnd)
1691da177e4SLinus Torvalds 
1705e0f0435SHerbert Xu extern unsigned long snmp_fold_field(void *mib[], int offt);
17133490170SYOSHIFUJI Hideaki extern int snmp_mib_init(void *ptr[2], size_t mibsize, size_t mibalign);
17233490170SYOSHIFUJI Hideaki extern void snmp_mib_free(void *ptr[2]);
17333490170SYOSHIFUJI Hideaki 
174227b60f5SStephen Hemminger extern void inet_get_local_port_range(int *low, int *high);
175227b60f5SStephen Hemminger 
1761da177e4SLinus Torvalds extern int sysctl_ip_default_ttl;
177cdac4e07SNeil Horman extern int sysctl_ip_nonlocal_bind;
1781da177e4SLinus Torvalds 
17920380731SArnaldo Carvalho de Melo /* From ip_fragment.c */
18020380731SArnaldo Carvalho de Melo extern int sysctl_ipfrag_high_thresh;
18120380731SArnaldo Carvalho de Melo extern int sysctl_ipfrag_low_thresh;
18220380731SArnaldo Carvalho de Melo extern int sysctl_ipfrag_time;
18320380731SArnaldo Carvalho de Melo extern int sysctl_ipfrag_secret_interval;
18489cee8b1SHerbert Xu extern int sysctl_ipfrag_max_dist;
18520380731SArnaldo Carvalho de Melo 
18620380731SArnaldo Carvalho de Melo /* From inetpeer.c */
18720380731SArnaldo Carvalho de Melo extern int inet_peer_threshold;
18820380731SArnaldo Carvalho de Melo extern int inet_peer_minttl;
18920380731SArnaldo Carvalho de Melo extern int inet_peer_maxttl;
19020380731SArnaldo Carvalho de Melo extern int inet_peer_gc_mintime;
19120380731SArnaldo Carvalho de Melo extern int inet_peer_gc_maxtime;
19220380731SArnaldo Carvalho de Melo 
19320380731SArnaldo Carvalho de Melo /* From ip_output.c */
19420380731SArnaldo Carvalho de Melo extern int sysctl_ip_dynaddr;
19520380731SArnaldo Carvalho de Melo 
19620380731SArnaldo Carvalho de Melo extern void ipfrag_init(void);
19720380731SArnaldo Carvalho de Melo 
1981da177e4SLinus Torvalds #ifdef CONFIG_INET
19914c85021SArnaldo Carvalho de Melo #include <net/dst.h>
20014c85021SArnaldo Carvalho de Melo 
2011da177e4SLinus Torvalds /* The function in 2.2 was invalid, producing wrong result for
2021da177e4SLinus Torvalds  * check=0xFEFF. It was noticed by Arthur Skawina _year_ ago. --ANK(000625) */
2031da177e4SLinus Torvalds static inline
2041da177e4SLinus Torvalds int ip_decrease_ttl(struct iphdr *iph)
2051da177e4SLinus Torvalds {
2065c78f275SAl Viro 	u32 check = (__force u32)iph->check;
2075c78f275SAl Viro 	check += (__force u32)htons(0x0100);
2085c78f275SAl Viro 	iph->check = (__force __sum16)(check + (check>=0xFFFF));
2091da177e4SLinus Torvalds 	return --iph->ttl;
2101da177e4SLinus Torvalds }
2111da177e4SLinus Torvalds 
2121da177e4SLinus Torvalds static inline
2131da177e4SLinus Torvalds int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
2141da177e4SLinus Torvalds {
2151da177e4SLinus Torvalds 	return (inet_sk(sk)->pmtudisc == IP_PMTUDISC_DO ||
2161da177e4SLinus Torvalds 		(inet_sk(sk)->pmtudisc == IP_PMTUDISC_WANT &&
2171da177e4SLinus Torvalds 		 !(dst_metric(dst, RTAX_LOCK)&(1<<RTAX_MTU))));
2181da177e4SLinus Torvalds }
2191da177e4SLinus Torvalds 
2201da177e4SLinus Torvalds extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
2211da177e4SLinus Torvalds 
2221da177e4SLinus Torvalds static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, struct sock *sk)
2231da177e4SLinus Torvalds {
2241da177e4SLinus Torvalds 	if (iph->frag_off & htons(IP_DF)) {
2251da177e4SLinus Torvalds 		/* This is only to work around buggy Windows95/2000
2261da177e4SLinus Torvalds 		 * VJ compression implementations.  If the ID field
2271da177e4SLinus Torvalds 		 * does not change, they drop every other packet in
2281da177e4SLinus Torvalds 		 * a TCP stream using header compression.
2291da177e4SLinus Torvalds 		 */
2301da177e4SLinus Torvalds 		iph->id = (sk && inet_sk(sk)->daddr) ?
2311da177e4SLinus Torvalds 					htons(inet_sk(sk)->id++) : 0;
2321da177e4SLinus Torvalds 	} else
2331da177e4SLinus Torvalds 		__ip_select_ident(iph, dst, 0);
2341da177e4SLinus Torvalds }
2351da177e4SLinus Torvalds 
2361da177e4SLinus Torvalds static inline void ip_select_ident_more(struct iphdr *iph, struct dst_entry *dst, struct sock *sk, int more)
2371da177e4SLinus Torvalds {
2381da177e4SLinus Torvalds 	if (iph->frag_off & htons(IP_DF)) {
2391da177e4SLinus Torvalds 		if (sk && inet_sk(sk)->daddr) {
2401da177e4SLinus Torvalds 			iph->id = htons(inet_sk(sk)->id);
2411da177e4SLinus Torvalds 			inet_sk(sk)->id += 1 + more;
2421da177e4SLinus Torvalds 		} else
2431da177e4SLinus Torvalds 			iph->id = 0;
2441da177e4SLinus Torvalds 	} else
2451da177e4SLinus Torvalds 		__ip_select_ident(iph, dst, more);
2461da177e4SLinus Torvalds }
2471da177e4SLinus Torvalds 
2481da177e4SLinus Torvalds /*
2491da177e4SLinus Torvalds  *	Map a multicast IP onto multicast MAC for type ethernet.
2501da177e4SLinus Torvalds  */
2511da177e4SLinus Torvalds 
252714e85beSAl Viro static inline void ip_eth_mc_map(__be32 naddr, char *buf)
2531da177e4SLinus Torvalds {
254714e85beSAl Viro 	__u32 addr=ntohl(naddr);
2551da177e4SLinus Torvalds 	buf[0]=0x01;
2561da177e4SLinus Torvalds 	buf[1]=0x00;
2571da177e4SLinus Torvalds 	buf[2]=0x5e;
2581da177e4SLinus Torvalds 	buf[5]=addr&0xFF;
2591da177e4SLinus Torvalds 	addr>>=8;
2601da177e4SLinus Torvalds 	buf[4]=addr&0xFF;
2611da177e4SLinus Torvalds 	addr>>=8;
2621da177e4SLinus Torvalds 	buf[3]=addr&0x7F;
2631da177e4SLinus Torvalds }
2641da177e4SLinus Torvalds 
2651da177e4SLinus Torvalds /*
2661da177e4SLinus Torvalds  *	Map a multicast IP onto multicast MAC for type IP-over-InfiniBand.
2671da177e4SLinus Torvalds  *	Leave P_Key as 0 to be filled in by driver.
2681da177e4SLinus Torvalds  */
2691da177e4SLinus Torvalds 
270714e85beSAl Viro static inline void ip_ib_mc_map(__be32 naddr, char *buf)
2711da177e4SLinus Torvalds {
272714e85beSAl Viro 	__u32 addr;
2731da177e4SLinus Torvalds 	buf[0]  = 0;		/* Reserved */
2741da177e4SLinus Torvalds 	buf[1]  = 0xff;		/* Multicast QPN */
2751da177e4SLinus Torvalds 	buf[2]  = 0xff;
2761da177e4SLinus Torvalds 	buf[3]  = 0xff;
277714e85beSAl Viro 	addr    = ntohl(naddr);
2781da177e4SLinus Torvalds 	buf[4]  = 0xff;
2791da177e4SLinus Torvalds 	buf[5]  = 0x12;		/* link local scope */
2801da177e4SLinus Torvalds 	buf[6]  = 0x40;		/* IPv4 signature */
2811da177e4SLinus Torvalds 	buf[7]  = 0x1b;
2821da177e4SLinus Torvalds 	buf[8]  = 0;		/* P_Key */
2831da177e4SLinus Torvalds 	buf[9]  = 0;
2841da177e4SLinus Torvalds 	buf[10] = 0;
2851da177e4SLinus Torvalds 	buf[11] = 0;
2861da177e4SLinus Torvalds 	buf[12] = 0;
2871da177e4SLinus Torvalds 	buf[13] = 0;
2881da177e4SLinus Torvalds 	buf[14] = 0;
2891da177e4SLinus Torvalds 	buf[15] = 0;
2901da177e4SLinus Torvalds 	buf[19] = addr & 0xff;
2911da177e4SLinus Torvalds 	addr  >>= 8;
2921da177e4SLinus Torvalds 	buf[18] = addr & 0xff;
2931da177e4SLinus Torvalds 	addr  >>= 8;
2941da177e4SLinus Torvalds 	buf[17] = addr & 0xff;
2951da177e4SLinus Torvalds 	addr  >>= 8;
2961da177e4SLinus Torvalds 	buf[16] = addr & 0x0f;
2971da177e4SLinus Torvalds }
2981da177e4SLinus Torvalds 
2991da177e4SLinus Torvalds #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
3001da177e4SLinus Torvalds #include <linux/ipv6.h>
3011da177e4SLinus Torvalds #endif
3021da177e4SLinus Torvalds 
3031da177e4SLinus Torvalds static __inline__ void inet_reset_saddr(struct sock *sk)
3041da177e4SLinus Torvalds {
3051da177e4SLinus Torvalds 	inet_sk(sk)->rcv_saddr = inet_sk(sk)->saddr = 0;
3061da177e4SLinus Torvalds #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
3071da177e4SLinus Torvalds 	if (sk->sk_family == PF_INET6) {
3081da177e4SLinus Torvalds 		struct ipv6_pinfo *np = inet6_sk(sk);
3091da177e4SLinus Torvalds 
3101da177e4SLinus Torvalds 		memset(&np->saddr, 0, sizeof(np->saddr));
3111da177e4SLinus Torvalds 		memset(&np->rcv_saddr, 0, sizeof(np->rcv_saddr));
3121da177e4SLinus Torvalds 	}
3131da177e4SLinus Torvalds #endif
3141da177e4SLinus Torvalds }
3151da177e4SLinus Torvalds 
3161da177e4SLinus Torvalds #endif
3171da177e4SLinus Torvalds 
3181da177e4SLinus Torvalds extern int	ip_call_ra_chain(struct sk_buff *skb);
3191da177e4SLinus Torvalds 
3201da177e4SLinus Torvalds /*
3211da177e4SLinus Torvalds  *	Functions provided by ip_fragment.o
3221da177e4SLinus Torvalds  */
3231da177e4SLinus Torvalds 
3241da177e4SLinus Torvalds enum ip_defrag_users
3251da177e4SLinus Torvalds {
3261da177e4SLinus Torvalds 	IP_DEFRAG_LOCAL_DELIVER,
3271da177e4SLinus Torvalds 	IP_DEFRAG_CALL_RA_CHAIN,
3281da177e4SLinus Torvalds 	IP_DEFRAG_CONNTRACK_IN,
3291da177e4SLinus Torvalds 	IP_DEFRAG_CONNTRACK_OUT,
3301da177e4SLinus Torvalds 	IP_DEFRAG_VS_IN,
3311da177e4SLinus Torvalds 	IP_DEFRAG_VS_OUT,
3321da177e4SLinus Torvalds 	IP_DEFRAG_VS_FWD
3331da177e4SLinus Torvalds };
3341da177e4SLinus Torvalds 
335776c729eSHerbert Xu int ip_defrag(struct sk_buff *skb, u32 user);
336*7eb95156SPavel Emelyanov int ip_frag_mem(void);
337*7eb95156SPavel Emelyanov int ip_frag_nqueues(void);
3381da177e4SLinus Torvalds 
3391da177e4SLinus Torvalds /*
3401da177e4SLinus Torvalds  *	Functions provided by ip_forward.c
3411da177e4SLinus Torvalds  */
3421da177e4SLinus Torvalds 
3431da177e4SLinus Torvalds extern int ip_forward(struct sk_buff *skb);
3441da177e4SLinus Torvalds extern int ip_net_unreachable(struct sk_buff *skb);
3451da177e4SLinus Torvalds 
3461da177e4SLinus Torvalds /*
3471da177e4SLinus Torvalds  *	Functions provided by ip_options.c
3481da177e4SLinus Torvalds  */
3491da177e4SLinus Torvalds 
3508712f774SAl Viro extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, __be32 daddr, struct rtable *rt, int is_frag);
3511da177e4SLinus Torvalds extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb);
3521da177e4SLinus Torvalds extern void ip_options_fragment(struct sk_buff *skb);
3531da177e4SLinus Torvalds extern int ip_options_compile(struct ip_options *opt, struct sk_buff *skb);
3544c6ea29dSArnaldo Carvalho de Melo extern int ip_options_get(struct ip_options **optp,
3554c6ea29dSArnaldo Carvalho de Melo 			  unsigned char *data, int optlen);
3564c6ea29dSArnaldo Carvalho de Melo extern int ip_options_get_from_user(struct ip_options **optp,
3574c6ea29dSArnaldo Carvalho de Melo 				    unsigned char __user *data, int optlen);
3581da177e4SLinus Torvalds extern void ip_options_undo(struct ip_options * opt);
3591da177e4SLinus Torvalds extern void ip_forward_options(struct sk_buff *skb);
3601da177e4SLinus Torvalds extern int ip_options_rcv_srr(struct sk_buff *skb);
3611da177e4SLinus Torvalds 
3621da177e4SLinus Torvalds /*
3631da177e4SLinus Torvalds  *	Functions provided by ip_sockglue.c
3641da177e4SLinus Torvalds  */
3651da177e4SLinus Torvalds 
3661da177e4SLinus Torvalds extern void	ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb);
3671da177e4SLinus Torvalds extern int	ip_cmsg_send(struct msghdr *msg, struct ipcm_cookie *ipc);
3681da177e4SLinus Torvalds extern int	ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, int optlen);
3691da177e4SLinus Torvalds extern int	ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen);
3703fdadf7dSDmitry Mishin extern int	compat_ip_setsockopt(struct sock *sk, int level,
3713fdadf7dSDmitry Mishin 			int optname, char __user *optval, int optlen);
3723fdadf7dSDmitry Mishin extern int	compat_ip_getsockopt(struct sock *sk, int level,
3733fdadf7dSDmitry Mishin 			int optname, char __user *optval, int __user *optlen);
3741da177e4SLinus Torvalds extern int	ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct sock *));
3751da177e4SLinus Torvalds 
3761da177e4SLinus Torvalds extern int 	ip_recv_error(struct sock *sk, struct msghdr *msg, int len);
3771da177e4SLinus Torvalds extern void	ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
37835986b32SAl Viro 			      __be16 port, u32 info, u8 *payload);
3790579016eSAl Viro extern void	ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,
3801da177e4SLinus Torvalds 			       u32 info);
3811da177e4SLinus Torvalds 
3821da177e4SLinus Torvalds /* sysctl helpers - any sysctl which holds a value that ends up being
3831da177e4SLinus Torvalds  * fed into the routing cache should use these handlers.
3841da177e4SLinus Torvalds  */
3851da177e4SLinus Torvalds int ipv4_doint_and_flush(ctl_table *ctl, int write,
3861da177e4SLinus Torvalds 			 struct file* filp, void __user *buffer,
3871da177e4SLinus Torvalds 			 size_t *lenp, loff_t *ppos);
3881da177e4SLinus Torvalds int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen,
3891da177e4SLinus Torvalds 				  void __user *oldval, size_t __user *oldlenp,
3901f29bcd7SAlexey Dobriyan 				  void __user *newval, size_t newlen);
39120380731SArnaldo Carvalho de Melo #ifdef CONFIG_PROC_FS
39220380731SArnaldo Carvalho de Melo extern int ip_misc_proc_init(void);
39320380731SArnaldo Carvalho de Melo #endif
39420380731SArnaldo Carvalho de Melo 
39520380731SArnaldo Carvalho de Melo extern struct ctl_table ipv4_table[];
3961da177e4SLinus Torvalds 
3971da177e4SLinus Torvalds #endif	/* _IP_H */
398