nfsd41: define NFSD_DRC_SIZE_SHIFT in set_max_drc
[safe/jmp/linux-2.6] / include / linux / net.h
index b20c53c..4515efa 100644 (file)
 #ifndef _LINUX_NET_H
 #define _LINUX_NET_H
 
-#include <linux/wait.h>
+#include <linux/socket.h>
 #include <asm/socket.h>
 
-struct poll_table_struct;
-struct inode;
-
-#define NPROTO         32              /* should be enough for now..   */
+#define NPROTO         AF_MAX
 
 #define SYS_SOCKET     1               /* sys_socket(2)                */
 #define SYS_BIND       2               /* sys_bind(2)                  */
@@ -43,6 +40,7 @@ struct inode;
 #define SYS_GETSOCKOPT 15              /* sys_getsockopt(2)            */
 #define SYS_SENDMSG    16              /* sys_sendmsg(2)               */
 #define SYS_RECVMSG    17              /* sys_recvmsg(2)               */
+#define SYS_ACCEPT4    18              /* sys_accept4(2)               */
 
 typedef enum {
        SS_FREE = 0,                    /* not allocated                */
@@ -56,6 +54,14 @@ typedef enum {
 
 #ifdef __KERNEL__
 #include <linux/stringify.h>
+#include <linux/random.h>
+#include <linux/wait.h>
+#include <linux/fcntl.h>       /* For O_CLOEXEC and O_NONBLOCK */
+
+struct poll_table_struct;
+struct pipe_inode_info;
+struct inode;
+struct net;
 
 #define SOCK_ASYNC_NOSPACE     0
 #define SOCK_ASYNC_WAITDATA    1
@@ -90,29 +96,44 @@ enum sock_type {
 };
 
 #define SOCK_MAX (SOCK_PACKET + 1)
+/* Mask which covers at least up to SOCK_MASK-1.  The
+ * remaining bits are used as flags. */
+#define SOCK_TYPE_MASK 0xf
+
+/* Flags for socket, socketpair, accept4 */
+#define SOCK_CLOEXEC   O_CLOEXEC
+#ifndef SOCK_NONBLOCK
+#define SOCK_NONBLOCK  O_NONBLOCK
+#endif
 
 #endif /* ARCH_HAS_SOCKET_TYPES */
 
+enum sock_shutdown_cmd {
+       SHUT_RD         = 0,
+       SHUT_WR         = 1,
+       SHUT_RDWR       = 2,
+};
+
 /**
  *  struct socket - general BSD socket
  *  @state: socket state (%SS_CONNECTED, etc)
+ *  @type: socket type (%SOCK_STREAM, etc)
  *  @flags: socket flags (%SOCK_ASYNC_NOSPACE, etc)
  *  @ops: protocol specific socket operations
  *  @fasync_list: Asynchronous wake up list
  *  @file: File back pointer for gc
  *  @sk: internal networking protocol agnostic socket representation
  *  @wait: wait queue for several uses
- *  @type: socket type (%SOCK_STREAM, etc)
  */
 struct socket {
        socket_state            state;
+       short                   type;
        unsigned long           flags;
        const struct proto_ops  *ops;
        struct fasync_struct    *fasync_list;
        struct file             *file;
        struct sock             *sk;
        wait_queue_head_t       wait;
-       short                   type;
 };
 
 struct vm_area_struct;
@@ -164,25 +185,29 @@ struct proto_ops {
                                      struct vm_area_struct * vma);
        ssize_t         (*sendpage)  (struct socket *sock, struct page *page,
                                      int offset, size_t size, int flags);
+       ssize_t         (*splice_read)(struct socket *sock,  loff_t *ppos,
+                                      struct pipe_inode_info *pipe, size_t len, unsigned int flags);
 };
 
 struct net_proto_family {
        int             family;
-       int             (*create)(struct socket *sock, int protocol);
-       /* These are counters for the number of different methods of
-          each we support */
-       short           authentication;
-       short           encryption;
-       short           encrypt_net;
+       int             (*create)(struct net *net, struct socket *sock, int protocol);
        struct module   *owner;
 };
 
 struct iovec;
 struct kvec;
 
+enum {
+       SOCK_WAKE_IO,
+       SOCK_WAKE_WAITD,
+       SOCK_WAKE_SPACE,
+       SOCK_WAKE_URG,
+};
+
 extern int          sock_wake_async(struct socket *sk, int how, int band);
-extern int          sock_register(struct net_proto_family *fam);
-extern int          sock_unregister(int family);
+extern int          sock_register(const struct net_proto_family *fam);
+extern void         sock_unregister(int family);
 extern int          sock_create(int family, int type, int proto,
                                 struct socket **res);
 extern int          sock_create_kern(int family, int type, int proto,
@@ -194,13 +219,13 @@ extern int             sock_sendmsg(struct socket *sock, struct msghdr *msg,
                                  size_t len);
 extern int          sock_recvmsg(struct socket *sock, struct msghdr *msg,
                                  size_t size, int flags);
-extern int          sock_map_fd(struct socket *sock);
+extern int          sock_map_fd(struct socket *sock, int flags);
 extern struct socket *sockfd_lookup(int fd, int *err);
 #define                     sockfd_put(sock) fput(sock->file)
 extern int          net_ratelimit(void);
-extern unsigned long net_random(void);
-extern void         net_srandom(unsigned long);
-extern void         net_random_init(void);
+
+#define net_random()           random32()
+#define net_srandom(seed)      srandom32((__force u32)seed)
 
 extern int          kernel_sendmsg(struct socket *sock, struct msghdr *msg,
                                    struct kvec *vec, size_t num, size_t len);
@@ -208,6 +233,27 @@ extern int              kernel_recvmsg(struct socket *sock, struct msghdr *msg,
                                    struct kvec *vec, size_t num,
                                    size_t len, int flags);
 
+extern int kernel_bind(struct socket *sock, struct sockaddr *addr,
+                      int addrlen);
+extern int kernel_listen(struct socket *sock, int backlog);
+extern int kernel_accept(struct socket *sock, struct socket **newsock,
+                        int flags);
+extern int kernel_connect(struct socket *sock, struct sockaddr *addr,
+                         int addrlen, int flags);
+extern int kernel_getsockname(struct socket *sock, struct sockaddr *addr,
+                             int *addrlen);
+extern int kernel_getpeername(struct socket *sock, struct sockaddr *addr,
+                             int *addrlen);
+extern int kernel_getsockopt(struct socket *sock, int level, int optname,
+                            char *optval, int *optlen);
+extern int kernel_setsockopt(struct socket *sock, int level, int optname,
+                            char *optval, int optlen);
+extern int kernel_sendpage(struct socket *sock, struct page *page, int offset,
+                          size_t size, int flags);
+extern int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg);
+extern int kernel_sock_shutdown(struct socket *sock,
+                               enum sock_shutdown_cmd how);
+
 #ifndef CONFIG_SMP
 #define SOCKOPS_WRAPPED(name) name
 #define SOCKOPS_WRAP(name, fam)
@@ -297,11 +343,13 @@ static const struct proto_ops name##_ops = {                      \
 #define MODULE_ALIAS_NET_PF_PROTO(pf, proto) \
        MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto))
 
+#define MODULE_ALIAS_NET_PF_PROTO_TYPE(pf, proto, type) \
+       MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
+                    "-type-" __stringify(type))
+
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
-extern ctl_table net_table[];
-extern int net_msg_cost;
-extern int net_msg_burst;
+extern struct ratelimit_state net_ratelimit_state;
 #endif
 
 #endif /* __KERNEL__ */