xref: /openbmc/linux/include/net/protocol.h (revision 951dbc8a)
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 protocol dispatcher.
71da177e4SLinus Torvalds  *
81da177e4SLinus Torvalds  * Version:	@(#)protocol.h	1.0.2	05/07/93
91da177e4SLinus Torvalds  *
101da177e4SLinus Torvalds  * Author:	Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
111da177e4SLinus Torvalds  *
121da177e4SLinus Torvalds  *		This program is free software; you can redistribute it and/or
131da177e4SLinus Torvalds  *		modify it under the terms of the GNU General Public License
141da177e4SLinus Torvalds  *		as published by the Free Software Foundation; either version
151da177e4SLinus Torvalds  *		2 of the License, or (at your option) any later version.
161da177e4SLinus Torvalds  *
171da177e4SLinus Torvalds  *	Changes:
181da177e4SLinus Torvalds  *		Alan Cox	:	Added a name field and a frag handler
191da177e4SLinus Torvalds  *					field for later.
201da177e4SLinus Torvalds  *		Alan Cox	:	Cleaned up, and sorted types.
211da177e4SLinus Torvalds  *		Pedro Roque	:	inet6 protocols
221da177e4SLinus Torvalds  */
231da177e4SLinus Torvalds 
241da177e4SLinus Torvalds #ifndef _PROTOCOL_H
251da177e4SLinus Torvalds #define _PROTOCOL_H
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds #include <linux/config.h>
281da177e4SLinus Torvalds #include <linux/in6.h>
291da177e4SLinus Torvalds #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
301da177e4SLinus Torvalds #include <linux/ipv6.h>
311da177e4SLinus Torvalds #endif
321da177e4SLinus Torvalds 
331da177e4SLinus Torvalds #define MAX_INET_PROTOS	256		/* Must be a power of 2		*/
341da177e4SLinus Torvalds 
351da177e4SLinus Torvalds 
361da177e4SLinus Torvalds /* This is used to register protocols. */
371da177e4SLinus Torvalds struct net_protocol {
381da177e4SLinus Torvalds 	int			(*handler)(struct sk_buff *skb);
391da177e4SLinus Torvalds 	void			(*err_handler)(struct sk_buff *skb, u32 info);
401da177e4SLinus Torvalds 	int			no_policy;
411da177e4SLinus Torvalds };
421da177e4SLinus Torvalds 
431da177e4SLinus Torvalds #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
441da177e4SLinus Torvalds struct inet6_protocol
451da177e4SLinus Torvalds {
46951dbc8aSPatrick McHardy 	int	(*handler)(struct sk_buff **skb);
471da177e4SLinus Torvalds 
481da177e4SLinus Torvalds 	void	(*err_handler)(struct sk_buff *skb,
491da177e4SLinus Torvalds 			       struct inet6_skb_parm *opt,
501da177e4SLinus Torvalds 			       int type, int code, int offset,
511da177e4SLinus Torvalds 			       __u32 info);
521da177e4SLinus Torvalds 	unsigned int	flags;	/* INET6_PROTO_xxx */
531da177e4SLinus Torvalds };
541da177e4SLinus Torvalds 
551da177e4SLinus Torvalds #define INET6_PROTO_NOPOLICY	0x1
561da177e4SLinus Torvalds #define INET6_PROTO_FINAL	0x2
571da177e4SLinus Torvalds #endif
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds /* This is used to register socket interfaces for IP protocols.  */
601da177e4SLinus Torvalds struct inet_protosw {
611da177e4SLinus Torvalds 	struct list_head list;
621da177e4SLinus Torvalds 
631da177e4SLinus Torvalds         /* These two fields form the lookup key.  */
641da177e4SLinus Torvalds 	unsigned short	 type;	   /* This is the 2nd argument to socket(2). */
651da177e4SLinus Torvalds 	int		 protocol; /* This is the L4 protocol number.  */
661da177e4SLinus Torvalds 
671da177e4SLinus Torvalds 	struct proto	 *prot;
6890ddc4f0SEric Dumazet 	const struct proto_ops *ops;
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds 	int              capability; /* Which (if any) capability do
711da177e4SLinus Torvalds 				      * we need to use this socket
721da177e4SLinus Torvalds 				      * interface?
731da177e4SLinus Torvalds                                       */
741da177e4SLinus Torvalds 	char             no_check;   /* checksum on rcv/xmit/none? */
751da177e4SLinus Torvalds 	unsigned char	 flags;      /* See INET_PROTOSW_* below.  */
761da177e4SLinus Torvalds };
771da177e4SLinus Torvalds #define INET_PROTOSW_REUSE 0x01	     /* Are ports automatically reusable? */
781da177e4SLinus Torvalds #define INET_PROTOSW_PERMANENT 0x02  /* Permanent protocols are unremovable. */
79d83d8461SArnaldo Carvalho de Melo #define INET_PROTOSW_ICSK      0x04  /* Is this an inet_connection_sock? */
801da177e4SLinus Torvalds 
811da177e4SLinus Torvalds extern struct net_protocol *inet_protocol_base;
821da177e4SLinus Torvalds extern struct net_protocol *inet_protos[MAX_INET_PROTOS];
831da177e4SLinus Torvalds 
841da177e4SLinus Torvalds #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
851da177e4SLinus Torvalds extern struct inet6_protocol *inet6_protos[MAX_INET_PROTOS];
861da177e4SLinus Torvalds #endif
871da177e4SLinus Torvalds 
881da177e4SLinus Torvalds extern int	inet_add_protocol(struct net_protocol *prot, unsigned char num);
891da177e4SLinus Torvalds extern int	inet_del_protocol(struct net_protocol *prot, unsigned char num);
901da177e4SLinus Torvalds extern void	inet_register_protosw(struct inet_protosw *p);
911da177e4SLinus Torvalds extern void	inet_unregister_protosw(struct inet_protosw *p);
921da177e4SLinus Torvalds 
931da177e4SLinus Torvalds #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
941da177e4SLinus Torvalds extern int	inet6_add_protocol(struct inet6_protocol *prot, unsigned char num);
951da177e4SLinus Torvalds extern int	inet6_del_protocol(struct inet6_protocol *prot, unsigned char num);
961da177e4SLinus Torvalds extern void	inet6_register_protosw(struct inet_protosw *p);
971da177e4SLinus Torvalds extern void	inet6_unregister_protosw(struct inet_protosw *p);
981da177e4SLinus Torvalds #endif
991da177e4SLinus Torvalds 
1001da177e4SLinus Torvalds #endif	/* _PROTOCOL_H */
101