af_unix.h 1.8 KB

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