af_unix.h 1.8 KB
Newer Older
L
Linus Torvalds 已提交
1 2
#ifndef __LINUX_NET_AFUNIX_H
#define __LINUX_NET_AFUNIX_H
3 4 5

#include <linux/socket.h>
#include <linux/un.h>
I
Ingo Molnar 已提交
6
#include <linux/mutex.h>
7 8
#include <net/sock.h>

L
Linus Torvalds 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
extern void unix_inflight(struct file *fp);
extern void unix_notinflight(struct file *fp);
extern void unix_gc(void);

#define UNIX_HASH_SIZE	256

extern atomic_t unix_tot_inflight;

struct unix_address {
	atomic_t	refcnt;
	int		len;
	unsigned	hash;
	struct sockaddr_un name[0];
};

struct unix_skb_parms {
	struct ucred		creds;		/* Skb credentials	*/
	struct scm_fp_list	*fp;		/* Passed files		*/
C
Catherine Zhang 已提交
27
#ifdef CONFIG_SECURITY_NETWORK
28
	u32			secid;		/* Security ID		*/
C
Catherine Zhang 已提交
29
#endif
L
Linus Torvalds 已提交
30 31 32 33
};

#define UNIXCB(skb) 	(*(struct unix_skb_parms*)&((skb)->cb))
#define UNIXCREDS(skb)	(&UNIXCB((skb)).creds)
34
#define UNIXSID(skb)	(&UNIXCB((skb)).secid)
L
Linus Torvalds 已提交
35

36 37 38
#define unix_state_lock(s)	spin_lock(&unix_sk(s)->lock)
#define unix_state_unlock(s)	spin_unlock(&unix_sk(s)->lock)
#define unix_state_lock_nested(s) \
39 40
				spin_lock_nested(&unix_sk(s)->lock, \
				SINGLE_DEPTH_NESTING)
L
Linus Torvalds 已提交
41 42 43 44 45 46 47 48 49

#ifdef __KERNEL__
/* The AF_UNIX socket */
struct unix_sock {
	/* WARNING: sk has to be the first member */
	struct sock		sk;
        struct unix_address     *addr;
        struct dentry		*dentry;
        struct vfsmount		*mnt;
I
Ingo Molnar 已提交
50
	struct mutex		readlock;
L
Linus Torvalds 已提交
51 52
        struct sock		*peer;
        struct sock		*other;
53
	struct list_head	link;
L
Linus Torvalds 已提交
54
        atomic_t                inflight;
55
        spinlock_t		lock;
56
	unsigned int		gc_candidate : 1;
L
Linus Torvalds 已提交
57 58 59
        wait_queue_head_t       peer_wait;
};
#define unix_sk(__sk) ((struct unix_sock *)__sk)
60 61 62 63 64 65 66 67 68

#ifdef CONFIG_SYSCTL
extern int sysctl_unix_max_dgram_qlen;
extern void unix_sysctl_register(void);
extern void unix_sysctl_unregister(void);
#else
static inline void unix_sysctl_register(void) {}
static inline void unix_sysctl_unregister(void) {}
#endif
L
Linus Torvalds 已提交
69 70
#endif
#endif