Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __LINUX_NET_AFUNIX_H |
| 2 | #define __LINUX_NET_AFUNIX_H |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 3 | |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 4 | #include <linux/socket.h> |
| 5 | #include <linux/un.h> |
Ingo Molnar | 57b47a5 | 2006-03-20 22:35:41 -0800 | [diff] [blame] | 6 | #include <linux/mutex.h> |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 7 | #include <net/sock.h> |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | extern void unix_inflight(struct file *fp); |
| 10 | extern void unix_notinflight(struct file *fp); |
| 11 | extern void unix_gc(void); |
| 12 | |
| 13 | #define UNIX_HASH_SIZE 256 |
| 14 | |
Pavel Emelyanov | 9305cfa | 2007-11-10 22:06:01 -0800 | [diff] [blame] | 15 | extern unsigned int unix_tot_inflight; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | struct unix_address { |
| 18 | atomic_t refcnt; |
| 19 | int len; |
| 20 | unsigned hash; |
| 21 | struct sockaddr_un name[0]; |
| 22 | }; |
| 23 | |
| 24 | struct unix_skb_parms { |
| 25 | struct ucred creds; /* Skb credentials */ |
| 26 | struct scm_fp_list *fp; /* Passed files */ |
Catherine Zhang | 877ce7c | 2006-06-29 12:27:47 -0700 | [diff] [blame] | 27 | #ifdef CONFIG_SECURITY_NETWORK |
Catherine Zhang | dc49c1f | 2006-08-02 14:12:06 -0700 | [diff] [blame] | 28 | u32 secid; /* Security ID */ |
Catherine Zhang | 877ce7c | 2006-06-29 12:27:47 -0700 | [diff] [blame] | 29 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | #define UNIXCB(skb) (*(struct unix_skb_parms*)&((skb)->cb)) |
| 33 | #define UNIXCREDS(skb) (&UNIXCB((skb)).creds) |
Catherine Zhang | dc49c1f | 2006-08-02 14:12:06 -0700 | [diff] [blame] | 34 | #define UNIXSID(skb) (&UNIXCB((skb)).secid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
David S. Miller | 1c92b4e | 2007-05-31 13:24:26 -0700 | [diff] [blame] | 36 | #define unix_state_lock(s) spin_lock(&unix_sk(s)->lock) |
| 37 | #define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock) |
| 38 | #define unix_state_lock_nested(s) \ |
Ingo Molnar | a09785a | 2006-07-03 00:25:12 -0700 | [diff] [blame] | 39 | spin_lock_nested(&unix_sk(s)->lock, \ |
| 40 | SINGLE_DEPTH_NESTING) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | #ifdef __KERNEL__ |
| 43 | /* The AF_UNIX socket */ |
| 44 | struct unix_sock { |
| 45 | /* WARNING: sk has to be the first member */ |
| 46 | struct sock sk; |
| 47 | struct unix_address *addr; |
| 48 | struct dentry *dentry; |
| 49 | struct vfsmount *mnt; |
Ingo Molnar | 57b47a5 | 2006-03-20 22:35:41 -0800 | [diff] [blame] | 50 | struct mutex readlock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | struct sock *peer; |
| 52 | struct sock *other; |
Miklos Szeredi | 1fd05ba | 2007-07-11 14:22:39 -0700 | [diff] [blame] | 53 | struct list_head link; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | atomic_t inflight; |
Benjamin LaHaise | fd19f32 | 2006-01-03 14:10:46 -0800 | [diff] [blame] | 55 | spinlock_t lock; |
Miklos Szeredi | 1fd05ba | 2007-07-11 14:22:39 -0700 | [diff] [blame] | 56 | unsigned int gc_candidate : 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | wait_queue_head_t peer_wait; |
| 58 | }; |
| 59 | #define unix_sk(__sk) ((struct unix_sock *)__sk) |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 60 | |
| 61 | #ifdef CONFIG_SYSCTL |
Pavel Emelyanov | 97577e3 | 2007-12-01 23:40:40 +1100 | [diff] [blame] | 62 | extern int unix_sysctl_register(struct net *net); |
| 63 | extern void unix_sysctl_unregister(struct net *net); |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 64 | #else |
Pavel Emelyanov | 97577e3 | 2007-12-01 23:40:40 +1100 | [diff] [blame] | 65 | static inline int unix_sysctl_register(struct net *net) { return 0; } |
| 66 | static inline void unix_sysctl_unregister(struct net *net) {} |
Arnaldo Carvalho de Melo | 2038073 | 2005-08-16 02:18:02 -0300 | [diff] [blame] | 67 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #endif |
| 69 | #endif |