This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / include / net / sock.h
index e01e617..4cf8c90 100644 (file)
@@ -61,7 +61,7 @@
  */
 
 /* Define this to get the sk->sk_debug debugging facility. */
-#define SOCK_DEBUGGING
+//#define SOCK_DEBUGGING
 #ifdef SOCK_DEBUGGING
 #define SOCK_DEBUG(sk, msg...) do { if ((sk) && ((sk)->sk_debug)) \
                                        printk(KERN_DEBUG msg); } while (0)
@@ -109,6 +109,10 @@ struct sock_common {
        struct hlist_node       skc_node;
        struct hlist_node       skc_bind_node;
        atomic_t                skc_refcnt;
+       xid_t                   skc_xid;
+       struct vx_info          *skc_vx_info;
+       nid_t                   skc_nid;
+       struct nx_info          *skc_nx_info;
 };
 
 /**
@@ -164,12 +168,13 @@ struct sock_common {
   *    @sk_timer - sock cleanup timer
   *    @sk_stamp - time stamp of last packet received
   *    @sk_socket - Identd and reporting IO signals
-  *    @sk_user_data - RPC layer private data
+  *    @sk_user_data - RPC and Tux layer private data
   *    @sk_owner - module that owns this socket
   *    @sk_state_change - callback to indicate change in the state of the sock
   *    @sk_data_ready - callback to indicate there is data to be processed
   *    @sk_write_space - callback to indicate there is bf sending space available
   *    @sk_error_report - callback to indicate errors (e.g. %MSG_ERRQUEUE)
+  *    @sk_create_child - callback to get new socket events
   *    @sk_backlog_rcv - callback to process the backlog
   *    @sk_destruct - called at sock freeing time, i.e. when all refcnt == 0
  */
@@ -186,6 +191,10 @@ struct sock {
 #define sk_node                        __sk_common.skc_node
 #define sk_bind_node           __sk_common.skc_bind_node
 #define sk_refcnt              __sk_common.skc_refcnt
+#define sk_xid                 __sk_common.skc_xid
+#define sk_vx_info             __sk_common.skc_vx_info
+#define sk_nid                 __sk_common.skc_nid
+#define sk_nx_info             __sk_common.skc_nx_info
        volatile unsigned char  sk_zapped;
        unsigned char           sk_shutdown;
        unsigned char           sk_use_write_queue;
@@ -245,6 +254,7 @@ struct sock {
        struct timeval          sk_stamp;
        struct socket           *sk_socket;
        void                    *sk_user_data;
+       void                    *sk_ns;        // For use by CKRM
        struct module           *sk_owner;
        void                    *sk_security;
        void                    (*sk_state_change)(struct sock *sk);
@@ -253,6 +263,7 @@ struct sock {
        void                    (*sk_error_report)(struct sock *sk);
        int                     (*sk_backlog_rcv)(struct sock *sk,
                                                  struct sk_buff *skb);  
+       void                    (*sk_create_child)(struct sock *sk, struct sock *newsk);
        void                    (*sk_destruct)(struct sock *sk);
 };
 
@@ -398,6 +409,36 @@ static inline int sock_flag(struct sock *sk, enum sock_flags flag)
        return test_bit(flag, &sk->sk_flags);
 }
 
+static inline void sk_acceptq_removed(struct sock *sk)
+{
+       sk->sk_ack_backlog--;
+}
+
+static inline void sk_acceptq_added(struct sock *sk)
+{
+       sk->sk_ack_backlog++;
+}
+
+static inline int sk_acceptq_is_full(struct sock *sk)
+{
+       return sk->sk_ack_backlog > sk->sk_max_ack_backlog;
+}
+
+/*
+ * Compute minimal free write space needed to queue new packets.
+ */
+static inline int sk_stream_min_wspace(struct sock *sk)
+{
+       return sk->sk_wmem_queued / 2;
+}
+
+static inline int sk_stream_wspace(struct sock *sk)
+{
+       return sk->sk_sndbuf - sk->sk_wmem_queued;
+}
+
+extern void sk_stream_write_space(struct sock *sk);
+
 /* The per-socket spinlock must be held here. */
 #define sk_add_backlog(__sk, __skb)                            \
 do {   if (!(__sk)->sk_backlog.tail) {                         \
@@ -410,6 +451,20 @@ do {       if (!(__sk)->sk_backlog.tail) {                         \
        (__skb)->next = NULL;                                   \
 } while(0)
 
+#define sk_wait_event(__sk, __timeo, __condition)              \
+({     int rc;                                                 \
+       release_sock(__sk);                                     \
+       rc = __condition;                                       \
+       if (!rc) {                                              \
+               *(__timeo) = schedule_timeout(*(__timeo));      \
+               rc = __condition;                               \
+       }                                                       \
+       lock_sock(__sk);                                        \
+       rc;                                                     \
+})
+
+extern int sk_wait_data(struct sock *sk, long *timeo);
+
 /* IP protocol blocks we attach to sockets.
  * socket layer -> transport layer interface
  * transport -> network interface is defined by struct inet_proto
@@ -430,10 +485,11 @@ struct proto {
        int                     (*destroy)(struct sock *sk);
        void                    (*shutdown)(struct sock *sk, int how);
        int                     (*setsockopt)(struct sock *sk, int level, 
-                                       int optname, char *optval, int optlen);
+                                       int optname, char __user *optval,
+                                       int optlen);
        int                     (*getsockopt)(struct sock *sk, int level, 
-                                       int optname, char *optval, 
-                                       int *option);    
+                                       int optname, char __user *optval, 
+                                       int __user *option);     
        int                     (*sendmsg)(struct kiocb *iocb, struct sock *sk,
                                           struct msghdr *msg, size_t len);
        int                     (*recvmsg)(struct kiocb *iocb, struct sock *sk,
@@ -872,6 +928,11 @@ sk_dst_check(struct sock *sk, u32 cookie)
        return dst;
 }
 
+static inline void sk_charge_skb(struct sock *sk, struct sk_buff *skb)
+{
+       sk->sk_wmem_queued   += skb->truesize;
+       sk->sk_forward_alloc -= skb->truesize;
+}
 
 /*
  *     Queue a received datagram if it will fit. Stream and sequenced
@@ -897,6 +958,11 @@ static inline void skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
        atomic_add(skb->truesize, &sk->sk_rmem_alloc);
 }
 
+extern void sk_reset_timer(struct sock *sk, struct timer_list* timer,
+                          unsigned long expires);
+
+extern void sk_stop_timer(struct sock *sk, struct timer_list* timer);
+
 static inline int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 {
        int err = 0;
@@ -1034,6 +1100,20 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
                sk->sk_stamp = *stamp;
 }
 
+/**
+ * sk_eat_skb - Release a skb if it is no longer needed
+ * @sk - socket to eat this skb from
+ * @skb - socket buffer to eat
+ *
+ * This routine must be called with interrupts disabled or with the socket
+ * locked so that the sk_buff queue operation is ok.
+*/
+static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb)
+{
+       __skb_unlink(skb, &sk->sk_receive_queue);
+       __kfree_skb(skb);
+}
+
 extern atomic_t netstamp_needed;
 extern void sock_enable_timestamp(struct sock *sk);
 extern void sock_disable_timestamp(struct sock *sk);
@@ -1048,7 +1128,7 @@ static inline void net_timestamp(struct timeval *stamp)
        }               
 } 
 
-extern int sock_get_timestamp(struct sock *, struct timeval *);
+extern int sock_get_timestamp(struct sock *, struct timeval __user *);
 
 /* 
  *     Enable debug/info messages