more debug output
[linux-2.4.git] / include / net / af_unix.h
1 #ifndef __LINUX_NET_AFUNIX_H
2 #define __LINUX_NET_AFUNIX_H
3 extern void unix_proto_init(struct net_proto *pro);
4 extern void unix_inflight(struct file *fp);
5 extern void unix_notinflight(struct file *fp);
6 typedef struct sock unix_socket;
7 extern void unix_gc(void);
8
9 #define UNIX_HASH_SIZE  256
10
11 extern unix_socket *unix_socket_table[UNIX_HASH_SIZE+1];
12 extern rwlock_t unix_table_lock;
13
14 extern atomic_t unix_tot_inflight;
15
16 static inline unix_socket *first_unix_socket(int *i)
17 {
18         for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
19                 if (unix_socket_table[*i])
20                         return unix_socket_table[*i];
21         }
22         return NULL;
23 }
24
25 static inline unix_socket *next_unix_socket(int *i, unix_socket *s)
26 {
27         /* More in this chain? */
28         if (s->next)
29                 return s->next;
30         /* Look for next non-empty chain. */
31         for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
32                 if (unix_socket_table[*i])
33                         return unix_socket_table[*i];
34         }
35         return NULL;
36 }
37
38 #define forall_unix_sockets(i, s) \
39         for (s = first_unix_socket(&(i)); s; s = next_unix_socket(&(i),(s)))
40
41 struct unix_address
42 {
43         atomic_t        refcnt;
44         int             len;
45         unsigned        hash;
46         struct sockaddr_un name[0];
47 };
48
49 struct unix_skb_parms
50 {
51         struct ucred            creds;          /* Skb credentials      */
52         struct scm_fp_list      *fp;            /* Passed files         */
53 };
54
55 #define UNIXCB(skb)     (*(struct unix_skb_parms*)&((skb)->cb))
56 #define UNIXCREDS(skb)  (&UNIXCB((skb)).creds)
57
58 #define unix_state_rlock(s)     read_lock(&(s)->protinfo.af_unix.lock)
59 #define unix_state_runlock(s)   read_unlock(&(s)->protinfo.af_unix.lock)
60 #define unix_state_wlock(s)     write_lock(&(s)->protinfo.af_unix.lock)
61 #define unix_state_wunlock(s)   write_unlock(&(s)->protinfo.af_unix.lock)
62
63 #endif