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