xref: /linux/include/linux/net.h (revision 8d8ad9d7c4bfe79bc91b7fc419ecfb9dcdfe6a51)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * NET		An implementation of the SOCKET network access protocol.
31da177e4SLinus Torvalds  *		This is the master header file for the Linux NET layer,
41da177e4SLinus Torvalds  *		or, in plain English: the networking handling part of the
51da177e4SLinus Torvalds  *		kernel.
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  * Version:	@(#)net.h	1.0.3	05/25/93
81da177e4SLinus Torvalds  *
91da177e4SLinus Torvalds  * Authors:	Orest Zborowski, <obz@Kodak.COM>
1002c30a84SJesper Juhl  *		Ross Biro
111da177e4SLinus Torvalds  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
121da177e4SLinus Torvalds  *
131da177e4SLinus Torvalds  *		This program is free software; you can redistribute it and/or
141da177e4SLinus Torvalds  *		modify it under the terms of the GNU General Public License
151da177e4SLinus Torvalds  *		as published by the Free Software Foundation; either version
161da177e4SLinus Torvalds  *		2 of the License, or (at your option) any later version.
171da177e4SLinus Torvalds  */
181da177e4SLinus Torvalds #ifndef _LINUX_NET_H
191da177e4SLinus Torvalds #define _LINUX_NET_H
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #include <linux/wait.h>
221da177e4SLinus Torvalds #include <asm/socket.h>
231da177e4SLinus Torvalds 
241da177e4SLinus Torvalds struct poll_table_struct;
259c55e01cSJens Axboe struct pipe_inode_info;
261da177e4SLinus Torvalds struct inode;
271b8d7ae4SEric W. Biederman struct net;
281da177e4SLinus Torvalds 
2917926a79SDavid Howells #define NPROTO		34		/* should be enough for now..	*/
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds #define SYS_SOCKET	1		/* sys_socket(2)		*/
321da177e4SLinus Torvalds #define SYS_BIND	2		/* sys_bind(2)			*/
331da177e4SLinus Torvalds #define SYS_CONNECT	3		/* sys_connect(2)		*/
341da177e4SLinus Torvalds #define SYS_LISTEN	4		/* sys_listen(2)		*/
351da177e4SLinus Torvalds #define SYS_ACCEPT	5		/* sys_accept(2)		*/
361da177e4SLinus Torvalds #define SYS_GETSOCKNAME	6		/* sys_getsockname(2)		*/
371da177e4SLinus Torvalds #define SYS_GETPEERNAME	7		/* sys_getpeername(2)		*/
381da177e4SLinus Torvalds #define SYS_SOCKETPAIR	8		/* sys_socketpair(2)		*/
391da177e4SLinus Torvalds #define SYS_SEND	9		/* sys_send(2)			*/
401da177e4SLinus Torvalds #define SYS_RECV	10		/* sys_recv(2)			*/
411da177e4SLinus Torvalds #define SYS_SENDTO	11		/* sys_sendto(2)		*/
421da177e4SLinus Torvalds #define SYS_RECVFROM	12		/* sys_recvfrom(2)		*/
431da177e4SLinus Torvalds #define SYS_SHUTDOWN	13		/* sys_shutdown(2)		*/
441da177e4SLinus Torvalds #define SYS_SETSOCKOPT	14		/* sys_setsockopt(2)		*/
451da177e4SLinus Torvalds #define SYS_GETSOCKOPT	15		/* sys_getsockopt(2)		*/
461da177e4SLinus Torvalds #define SYS_SENDMSG	16		/* sys_sendmsg(2)		*/
471da177e4SLinus Torvalds #define SYS_RECVMSG	17		/* sys_recvmsg(2)		*/
481da177e4SLinus Torvalds 
491da177e4SLinus Torvalds typedef enum {
501da177e4SLinus Torvalds 	SS_FREE = 0,			/* not allocated		*/
511da177e4SLinus Torvalds 	SS_UNCONNECTED,			/* unconnected to any socket	*/
521da177e4SLinus Torvalds 	SS_CONNECTING,			/* in process of connecting	*/
531da177e4SLinus Torvalds 	SS_CONNECTED,			/* connected to socket		*/
541da177e4SLinus Torvalds 	SS_DISCONNECTING		/* in process of disconnecting	*/
551da177e4SLinus Torvalds } socket_state;
561da177e4SLinus Torvalds 
571da177e4SLinus Torvalds #define __SO_ACCEPTCON	(1 << 16)	/* performed a listen		*/
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds #ifdef __KERNEL__
60eacf17bdSDavid Woodhouse #include <linux/stringify.h>
61cb4db4c2SDavid Woodhouse #include <linux/random.h>
621da177e4SLinus Torvalds 
631da177e4SLinus Torvalds #define SOCK_ASYNC_NOSPACE	0
641da177e4SLinus Torvalds #define SOCK_ASYNC_WAITDATA	1
651da177e4SLinus Torvalds #define SOCK_NOSPACE		2
661da177e4SLinus Torvalds #define SOCK_PASSCRED		3
67877ce7c1SCatherine Zhang #define SOCK_PASSSEC		4
681da177e4SLinus Torvalds 
691da177e4SLinus Torvalds #ifndef ARCH_HAS_SOCKET_TYPES
704dc3b16bSPavel Pisa /**
714dc3b16bSPavel Pisa  * enum sock_type - Socket types
724dc3b16bSPavel Pisa  * @SOCK_STREAM: stream (connection) socket
734dc3b16bSPavel Pisa  * @SOCK_DGRAM: datagram (conn.less) socket
744dc3b16bSPavel Pisa  * @SOCK_RAW: raw socket
754dc3b16bSPavel Pisa  * @SOCK_RDM: reliably-delivered message
764dc3b16bSPavel Pisa  * @SOCK_SEQPACKET: sequential packet socket
778f2709b5SRandy Dunlap  * @SOCK_DCCP: Datagram Congestion Control Protocol socket
784dc3b16bSPavel Pisa  * @SOCK_PACKET: linux specific way of getting packets at the dev level.
794dc3b16bSPavel Pisa  *		  For writing rarp and other similar things on the user level.
801da177e4SLinus Torvalds  *
811da177e4SLinus Torvalds  * When adding some new socket type please
821da177e4SLinus Torvalds  * grep ARCH_HAS_SOCKET_TYPE include/asm-* /socket.h, at least MIPS
831da177e4SLinus Torvalds  * overrides this enum for binary compat reasons.
841da177e4SLinus Torvalds  */
851da177e4SLinus Torvalds enum sock_type {
861da177e4SLinus Torvalds 	SOCK_STREAM	= 1,
871da177e4SLinus Torvalds 	SOCK_DGRAM	= 2,
881da177e4SLinus Torvalds 	SOCK_RAW	= 3,
891da177e4SLinus Torvalds 	SOCK_RDM	= 4,
901da177e4SLinus Torvalds 	SOCK_SEQPACKET	= 5,
917c657876SArnaldo Carvalho de Melo 	SOCK_DCCP	= 6,
921da177e4SLinus Torvalds 	SOCK_PACKET	= 10,
931da177e4SLinus Torvalds };
941da177e4SLinus Torvalds 
951da177e4SLinus Torvalds #define SOCK_MAX (SOCK_PACKET + 1)
961da177e4SLinus Torvalds 
971da177e4SLinus Torvalds #endif /* ARCH_HAS_SOCKET_TYPES */
981da177e4SLinus Torvalds 
9991cf45f0STrond Myklebust enum sock_shutdown_cmd {
10091cf45f0STrond Myklebust 	SHUT_RD		= 0,
10191cf45f0STrond Myklebust 	SHUT_WR		= 1,
10291cf45f0STrond Myklebust 	SHUT_RDWR	= 2,
10391cf45f0STrond Myklebust };
10491cf45f0STrond Myklebust 
1051da177e4SLinus Torvalds /**
1061da177e4SLinus Torvalds  *  struct socket - general BSD socket
1074dc3b16bSPavel Pisa  *  @state: socket state (%SS_CONNECTED, etc)
1084dc3b16bSPavel Pisa  *  @flags: socket flags (%SOCK_ASYNC_NOSPACE, etc)
1094dc3b16bSPavel Pisa  *  @ops: protocol specific socket operations
1104dc3b16bSPavel Pisa  *  @fasync_list: Asynchronous wake up list
1114dc3b16bSPavel Pisa  *  @file: File back pointer for gc
1124dc3b16bSPavel Pisa  *  @sk: internal networking protocol agnostic socket representation
1134dc3b16bSPavel Pisa  *  @wait: wait queue for several uses
1144dc3b16bSPavel Pisa  *  @type: socket type (%SOCK_STREAM, etc)
1151da177e4SLinus Torvalds  */
1161da177e4SLinus Torvalds struct socket {
1171da177e4SLinus Torvalds 	socket_state		state;
1181da177e4SLinus Torvalds 	unsigned long		flags;
11990ddc4f0SEric Dumazet 	const struct proto_ops	*ops;
1201da177e4SLinus Torvalds 	struct fasync_struct	*fasync_list;
1211da177e4SLinus Torvalds 	struct file		*file;
1221da177e4SLinus Torvalds 	struct sock		*sk;
1231da177e4SLinus Torvalds 	wait_queue_head_t	wait;
1241da177e4SLinus Torvalds 	short			type;
1251da177e4SLinus Torvalds };
1261da177e4SLinus Torvalds 
1271da177e4SLinus Torvalds struct vm_area_struct;
1281da177e4SLinus Torvalds struct page;
1291da177e4SLinus Torvalds struct kiocb;
1301da177e4SLinus Torvalds struct sockaddr;
1311da177e4SLinus Torvalds struct msghdr;
1321da177e4SLinus Torvalds struct module;
1331da177e4SLinus Torvalds 
1341da177e4SLinus Torvalds struct proto_ops {
1351da177e4SLinus Torvalds 	int		family;
1361da177e4SLinus Torvalds 	struct module	*owner;
1371da177e4SLinus Torvalds 	int		(*release)   (struct socket *sock);
1381da177e4SLinus Torvalds 	int		(*bind)	     (struct socket *sock,
1391da177e4SLinus Torvalds 				      struct sockaddr *myaddr,
1401da177e4SLinus Torvalds 				      int sockaddr_len);
1411da177e4SLinus Torvalds 	int		(*connect)   (struct socket *sock,
1421da177e4SLinus Torvalds 				      struct sockaddr *vaddr,
1431da177e4SLinus Torvalds 				      int sockaddr_len, int flags);
1441da177e4SLinus Torvalds 	int		(*socketpair)(struct socket *sock1,
1451da177e4SLinus Torvalds 				      struct socket *sock2);
1461da177e4SLinus Torvalds 	int		(*accept)    (struct socket *sock,
1471da177e4SLinus Torvalds 				      struct socket *newsock, int flags);
1481da177e4SLinus Torvalds 	int		(*getname)   (struct socket *sock,
1491da177e4SLinus Torvalds 				      struct sockaddr *addr,
1501da177e4SLinus Torvalds 				      int *sockaddr_len, int peer);
1511da177e4SLinus Torvalds 	unsigned int	(*poll)	     (struct file *file, struct socket *sock,
1521da177e4SLinus Torvalds 				      struct poll_table_struct *wait);
1531da177e4SLinus Torvalds 	int		(*ioctl)     (struct socket *sock, unsigned int cmd,
1541da177e4SLinus Torvalds 				      unsigned long arg);
15589bbfc95SShaun Pereira 	int	 	(*compat_ioctl) (struct socket *sock, unsigned int cmd,
15689bbfc95SShaun Pereira 				      unsigned long arg);
1571da177e4SLinus Torvalds 	int		(*listen)    (struct socket *sock, int len);
1581da177e4SLinus Torvalds 	int		(*shutdown)  (struct socket *sock, int flags);
1591da177e4SLinus Torvalds 	int		(*setsockopt)(struct socket *sock, int level,
1601da177e4SLinus Torvalds 				      int optname, char __user *optval, int optlen);
1611da177e4SLinus Torvalds 	int		(*getsockopt)(struct socket *sock, int level,
1621da177e4SLinus Torvalds 				      int optname, char __user *optval, int __user *optlen);
1633fdadf7dSDmitry Mishin 	int		(*compat_setsockopt)(struct socket *sock, int level,
1643fdadf7dSDmitry Mishin 				      int optname, char __user *optval, int optlen);
1653fdadf7dSDmitry Mishin 	int		(*compat_getsockopt)(struct socket *sock, int level,
1663fdadf7dSDmitry Mishin 				      int optname, char __user *optval, int __user *optlen);
1671da177e4SLinus Torvalds 	int		(*sendmsg)   (struct kiocb *iocb, struct socket *sock,
1681da177e4SLinus Torvalds 				      struct msghdr *m, size_t total_len);
1691da177e4SLinus Torvalds 	int		(*recvmsg)   (struct kiocb *iocb, struct socket *sock,
1701da177e4SLinus Torvalds 				      struct msghdr *m, size_t total_len,
1711da177e4SLinus Torvalds 				      int flags);
1721da177e4SLinus Torvalds 	int		(*mmap)	     (struct file *file, struct socket *sock,
1731da177e4SLinus Torvalds 				      struct vm_area_struct * vma);
1741da177e4SLinus Torvalds 	ssize_t		(*sendpage)  (struct socket *sock, struct page *page,
1751da177e4SLinus Torvalds 				      int offset, size_t size, int flags);
1769c55e01cSJens Axboe 	ssize_t 	(*splice_read)(struct socket *sock,  loff_t *ppos,
1779c55e01cSJens Axboe 				       struct pipe_inode_info *pipe, size_t len, unsigned int flags);
1781da177e4SLinus Torvalds };
1791da177e4SLinus Torvalds 
1801da177e4SLinus Torvalds struct net_proto_family {
1811da177e4SLinus Torvalds 	int		family;
1821b8d7ae4SEric W. Biederman 	int		(*create)(struct net *net, struct socket *sock, int protocol);
1831da177e4SLinus Torvalds 	struct module	*owner;
1841da177e4SLinus Torvalds };
1851da177e4SLinus Torvalds 
1861da177e4SLinus Torvalds struct iovec;
1871da177e4SLinus Torvalds struct kvec;
1881da177e4SLinus Torvalds 
189*8d8ad9d7SPavel Emelyanov enum {
190*8d8ad9d7SPavel Emelyanov 	SOCK_WAKE_IO,
191*8d8ad9d7SPavel Emelyanov 	SOCK_WAKE_WAITD,
192*8d8ad9d7SPavel Emelyanov 	SOCK_WAKE_SPACE,
193*8d8ad9d7SPavel Emelyanov 	SOCK_WAKE_URG,
194*8d8ad9d7SPavel Emelyanov };
195*8d8ad9d7SPavel Emelyanov 
1961da177e4SLinus Torvalds extern int	     sock_wake_async(struct socket *sk, int how, int band);
197f0fd27d4SStephen Hemminger extern int	     sock_register(const struct net_proto_family *fam);
198f0fd27d4SStephen Hemminger extern void	     sock_unregister(int family);
1991da177e4SLinus Torvalds extern int	     sock_create(int family, int type, int proto,
2001da177e4SLinus Torvalds 				 struct socket **res);
2011da177e4SLinus Torvalds extern int	     sock_create_kern(int family, int type, int proto,
2021da177e4SLinus Torvalds 				      struct socket **res);
2031da177e4SLinus Torvalds extern int	     sock_create_lite(int family, int type, int proto,
2041da177e4SLinus Torvalds 				      struct socket **res);
2051da177e4SLinus Torvalds extern void	     sock_release(struct socket *sock);
2061da177e4SLinus Torvalds extern int   	     sock_sendmsg(struct socket *sock, struct msghdr *msg,
2071da177e4SLinus Torvalds 				  size_t len);
2081da177e4SLinus Torvalds extern int	     sock_recvmsg(struct socket *sock, struct msghdr *msg,
2091da177e4SLinus Torvalds 				  size_t size, int flags);
2101da177e4SLinus Torvalds extern int 	     sock_map_fd(struct socket *sock);
2111da177e4SLinus Torvalds extern struct socket *sockfd_lookup(int fd, int *err);
2121da177e4SLinus Torvalds #define		     sockfd_put(sock) fput(sock->file)
2131da177e4SLinus Torvalds extern int	     net_ratelimit(void);
214aaa248f6SStephen Hemminger 
215aaa248f6SStephen Hemminger #define net_random()		random32()
216a64b78a0SAl Viro #define net_srandom(seed)	srandom32((__force u32)seed)
2171da177e4SLinus Torvalds 
2181da177e4SLinus Torvalds extern int   	     kernel_sendmsg(struct socket *sock, struct msghdr *msg,
2191da177e4SLinus Torvalds 				    struct kvec *vec, size_t num, size_t len);
2201da177e4SLinus Torvalds extern int   	     kernel_recvmsg(struct socket *sock, struct msghdr *msg,
2211da177e4SLinus Torvalds 				    struct kvec *vec, size_t num,
2221da177e4SLinus Torvalds 				    size_t len, int flags);
2231da177e4SLinus Torvalds 
224ac5a488eSSridhar Samudrala extern int kernel_bind(struct socket *sock, struct sockaddr *addr,
225ac5a488eSSridhar Samudrala 		       int addrlen);
226ac5a488eSSridhar Samudrala extern int kernel_listen(struct socket *sock, int backlog);
227ac5a488eSSridhar Samudrala extern int kernel_accept(struct socket *sock, struct socket **newsock,
228ac5a488eSSridhar Samudrala 			 int flags);
229ac5a488eSSridhar Samudrala extern int kernel_connect(struct socket *sock, struct sockaddr *addr,
230ac5a488eSSridhar Samudrala 			  int addrlen, int flags);
231ac5a488eSSridhar Samudrala extern int kernel_getsockname(struct socket *sock, struct sockaddr *addr,
232ac5a488eSSridhar Samudrala 			      int *addrlen);
233ac5a488eSSridhar Samudrala extern int kernel_getpeername(struct socket *sock, struct sockaddr *addr,
234ac5a488eSSridhar Samudrala 			      int *addrlen);
235ac5a488eSSridhar Samudrala extern int kernel_getsockopt(struct socket *sock, int level, int optname,
236ac5a488eSSridhar Samudrala 			     char *optval, int *optlen);
237ac5a488eSSridhar Samudrala extern int kernel_setsockopt(struct socket *sock, int level, int optname,
238ac5a488eSSridhar Samudrala 			     char *optval, int optlen);
239ac5a488eSSridhar Samudrala extern int kernel_sendpage(struct socket *sock, struct page *page, int offset,
240ac5a488eSSridhar Samudrala 			   size_t size, int flags);
241ac5a488eSSridhar Samudrala extern int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg);
24291cf45f0STrond Myklebust extern int kernel_sock_shutdown(struct socket *sock,
24391cf45f0STrond Myklebust 				enum sock_shutdown_cmd how);
244ac5a488eSSridhar Samudrala 
2451da177e4SLinus Torvalds #ifndef CONFIG_SMP
2461da177e4SLinus Torvalds #define SOCKOPS_WRAPPED(name) name
2471da177e4SLinus Torvalds #define SOCKOPS_WRAP(name, fam)
2481da177e4SLinus Torvalds #else
2491da177e4SLinus Torvalds 
2501da177e4SLinus Torvalds #define SOCKOPS_WRAPPED(name) __unlocked_##name
2511da177e4SLinus Torvalds 
2521da177e4SLinus Torvalds #define SOCKCALL_WRAP(name, call, parms, args)		\
2531da177e4SLinus Torvalds static int __lock_##name##_##call  parms		\
2541da177e4SLinus Torvalds {							\
2551da177e4SLinus Torvalds 	int ret;					\
2561da177e4SLinus Torvalds 	lock_kernel();					\
2571da177e4SLinus Torvalds 	ret = __unlocked_##name##_ops.call  args ;\
2581da177e4SLinus Torvalds 	unlock_kernel();				\
2591da177e4SLinus Torvalds 	return ret;					\
2601da177e4SLinus Torvalds }
2611da177e4SLinus Torvalds 
2621da177e4SLinus Torvalds #define SOCKCALL_UWRAP(name, call, parms, args)		\
2631da177e4SLinus Torvalds static unsigned int __lock_##name##_##call  parms	\
2641da177e4SLinus Torvalds {							\
2651da177e4SLinus Torvalds 	int ret;					\
2661da177e4SLinus Torvalds 	lock_kernel();					\
2671da177e4SLinus Torvalds 	ret = __unlocked_##name##_ops.call  args ;\
2681da177e4SLinus Torvalds 	unlock_kernel();				\
2691da177e4SLinus Torvalds 	return ret;					\
2701da177e4SLinus Torvalds }
2711da177e4SLinus Torvalds 
2721da177e4SLinus Torvalds 
2731da177e4SLinus Torvalds #define SOCKOPS_WRAP(name, fam)					\
2741da177e4SLinus Torvalds SOCKCALL_WRAP(name, release, (struct socket *sock), (sock))	\
2751da177e4SLinus Torvalds SOCKCALL_WRAP(name, bind, (struct socket *sock, struct sockaddr *uaddr, int addr_len), \
2761da177e4SLinus Torvalds 	      (sock, uaddr, addr_len))				\
2771da177e4SLinus Torvalds SOCKCALL_WRAP(name, connect, (struct socket *sock, struct sockaddr * uaddr, \
2781da177e4SLinus Torvalds 			      int addr_len, int flags), 	\
2791da177e4SLinus Torvalds 	      (sock, uaddr, addr_len, flags))			\
2801da177e4SLinus Torvalds SOCKCALL_WRAP(name, socketpair, (struct socket *sock1, struct socket *sock2), \
2811da177e4SLinus Torvalds 	      (sock1, sock2))					\
2821da177e4SLinus Torvalds SOCKCALL_WRAP(name, accept, (struct socket *sock, struct socket *newsock, \
2831da177e4SLinus Torvalds 			 int flags), (sock, newsock, flags)) \
2841da177e4SLinus Torvalds SOCKCALL_WRAP(name, getname, (struct socket *sock, struct sockaddr *uaddr, \
2851da177e4SLinus Torvalds 			 int *addr_len, int peer), (sock, uaddr, addr_len, peer)) \
2861da177e4SLinus Torvalds SOCKCALL_UWRAP(name, poll, (struct file *file, struct socket *sock, struct poll_table_struct *wait), \
2871da177e4SLinus Torvalds 	      (file, sock, wait)) \
2881da177e4SLinus Torvalds SOCKCALL_WRAP(name, ioctl, (struct socket *sock, unsigned int cmd, \
2891da177e4SLinus Torvalds 			 unsigned long arg), (sock, cmd, arg)) \
29089bbfc95SShaun Pereira SOCKCALL_WRAP(name, compat_ioctl, (struct socket *sock, unsigned int cmd, \
29189bbfc95SShaun Pereira 			 unsigned long arg), (sock, cmd, arg)) \
2921da177e4SLinus Torvalds SOCKCALL_WRAP(name, listen, (struct socket *sock, int len), (sock, len)) \
2931da177e4SLinus Torvalds SOCKCALL_WRAP(name, shutdown, (struct socket *sock, int flags), (sock, flags)) \
2941da177e4SLinus Torvalds SOCKCALL_WRAP(name, setsockopt, (struct socket *sock, int level, int optname, \
2951da177e4SLinus Torvalds 			 char __user *optval, int optlen), (sock, level, optname, optval, optlen)) \
2961da177e4SLinus Torvalds SOCKCALL_WRAP(name, getsockopt, (struct socket *sock, int level, int optname, \
2971da177e4SLinus Torvalds 			 char __user *optval, int __user *optlen), (sock, level, optname, optval, optlen)) \
2981da177e4SLinus Torvalds SOCKCALL_WRAP(name, sendmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, size_t len), \
2991da177e4SLinus Torvalds 	      (iocb, sock, m, len)) \
3001da177e4SLinus Torvalds SOCKCALL_WRAP(name, recvmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, size_t len, int flags), \
3011da177e4SLinus Torvalds 	      (iocb, sock, m, len, flags)) \
3021da177e4SLinus Torvalds SOCKCALL_WRAP(name, mmap, (struct file *file, struct socket *sock, struct vm_area_struct *vma), \
3031da177e4SLinus Torvalds 	      (file, sock, vma)) \
3041da177e4SLinus Torvalds 	      \
30590ddc4f0SEric Dumazet static const struct proto_ops name##_ops = {			\
3061da177e4SLinus Torvalds 	.family		= fam,				\
3071da177e4SLinus Torvalds 	.owner		= THIS_MODULE,			\
3081da177e4SLinus Torvalds 	.release	= __lock_##name##_release,	\
3091da177e4SLinus Torvalds 	.bind		= __lock_##name##_bind,		\
3101da177e4SLinus Torvalds 	.connect	= __lock_##name##_connect,	\
3111da177e4SLinus Torvalds 	.socketpair	= __lock_##name##_socketpair,	\
3121da177e4SLinus Torvalds 	.accept		= __lock_##name##_accept,	\
3131da177e4SLinus Torvalds 	.getname	= __lock_##name##_getname,	\
3141da177e4SLinus Torvalds 	.poll		= __lock_##name##_poll,		\
3151da177e4SLinus Torvalds 	.ioctl		= __lock_##name##_ioctl,	\
31689bbfc95SShaun Pereira 	.compat_ioctl	= __lock_##name##_compat_ioctl,	\
3171da177e4SLinus Torvalds 	.listen		= __lock_##name##_listen,	\
3181da177e4SLinus Torvalds 	.shutdown	= __lock_##name##_shutdown,	\
3191da177e4SLinus Torvalds 	.setsockopt	= __lock_##name##_setsockopt,	\
3201da177e4SLinus Torvalds 	.getsockopt	= __lock_##name##_getsockopt,	\
3211da177e4SLinus Torvalds 	.sendmsg	= __lock_##name##_sendmsg,	\
3221da177e4SLinus Torvalds 	.recvmsg	= __lock_##name##_recvmsg,	\
3231da177e4SLinus Torvalds 	.mmap		= __lock_##name##_mmap,		\
3241da177e4SLinus Torvalds };
32589bbfc95SShaun Pereira 
3261da177e4SLinus Torvalds #endif
3271da177e4SLinus Torvalds 
3281da177e4SLinus Torvalds #define MODULE_ALIAS_NETPROTO(proto) \
3291da177e4SLinus Torvalds 	MODULE_ALIAS("net-pf-" __stringify(proto))
3301da177e4SLinus Torvalds 
3314fdb3bb7SHarald Welte #define MODULE_ALIAS_NET_PF_PROTO(pf, proto) \
3324fdb3bb7SHarald Welte 	MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto))
3334fdb3bb7SHarald Welte 
334305e1e96SJean Delvare #define MODULE_ALIAS_NET_PF_PROTO_TYPE(pf, proto, type) \
335305e1e96SJean Delvare 	MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
336305e1e96SJean Delvare 		     "-type-" __stringify(type))
337305e1e96SJean Delvare 
33820380731SArnaldo Carvalho de Melo #ifdef CONFIG_SYSCTL
33920380731SArnaldo Carvalho de Melo #include <linux/sysctl.h>
34020380731SArnaldo Carvalho de Melo extern ctl_table net_table[];
34120380731SArnaldo Carvalho de Melo extern int net_msg_cost;
34220380731SArnaldo Carvalho de Melo extern int net_msg_burst;
34320380731SArnaldo Carvalho de Melo #endif
34420380731SArnaldo Carvalho de Melo 
3451da177e4SLinus Torvalds #endif /* __KERNEL__ */
3461da177e4SLinus Torvalds #endif	/* _LINUX_NET_H */
347