af_unix.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef __LINUX_NET_AFUNIX_H
  2. #define __LINUX_NET_AFUNIX_H
  3. #include <linux/socket.h>
  4. #include <linux/un.h>
  5. #include <linux/mutex.h>
  6. #include <net/sock.h>
  7. extern void unix_inflight(struct file *fp);
  8. extern void unix_notinflight(struct file *fp);
  9. extern void unix_gc(void);
  10. #define UNIX_HASH_SIZE 256
  11. extern atomic_t unix_tot_inflight;
  12. struct unix_address {
  13. atomic_t refcnt;
  14. int len;
  15. unsigned hash;
  16. struct sockaddr_un name[0];
  17. };
  18. struct unix_skb_parms {
  19. struct ucred creds; /* Skb credentials */
  20. struct scm_fp_list *fp; /* Passed files */
  21. #ifdef CONFIG_SECURITY_NETWORK
  22. u32 secid; /* Security ID */
  23. #endif
  24. };
  25. #define UNIXCB(skb) (*(struct unix_skb_parms*)&((skb)->cb))
  26. #define UNIXCREDS(skb) (&UNIXCB((skb)).creds)
  27. #define UNIXSID(skb) (&UNIXCB((skb)).secid)
  28. #define unix_state_lock(s) spin_lock(&unix_sk(s)->lock)
  29. #define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock)
  30. #define unix_state_lock_nested(s) \
  31. spin_lock_nested(&unix_sk(s)->lock, \
  32. SINGLE_DEPTH_NESTING)
  33. #ifdef __KERNEL__
  34. /* The AF_UNIX socket */
  35. struct unix_sock {
  36. /* WARNING: sk has to be the first member */
  37. struct sock sk;
  38. struct unix_address *addr;
  39. struct dentry *dentry;
  40. struct vfsmount *mnt;
  41. struct mutex readlock;
  42. struct sock *peer;
  43. struct sock *other;
  44. struct list_head link;
  45. atomic_t inflight;
  46. spinlock_t lock;
  47. unsigned int gc_candidate : 1;
  48. wait_queue_head_t peer_wait;
  49. };
  50. #define unix_sk(__sk) ((struct unix_sock *)__sk)
  51. #ifdef CONFIG_SYSCTL
  52. extern int sysctl_unix_max_dgram_qlen;
  53. extern void unix_sysctl_register(void);
  54. extern void unix_sysctl_unregister(void);
  55. #else
  56. static inline void unix_sysctl_register(void) {}
  57. static inline void unix_sysctl_unregister(void) {}
  58. #endif
  59. #endif
  60. #endif