af_unix.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. extern struct sock *unix_get_socket(struct file *filp);
  12. #define UNIX_HASH_SIZE 256
  13. extern unsigned int unix_tot_inflight;
  14. struct unix_address {
  15. atomic_t refcnt;
  16. int len;
  17. unsigned hash;
  18. struct sockaddr_un name[0];
  19. };
  20. struct unix_skb_parms {
  21. struct pid *pid; /* Skb credentials */
  22. const struct cred *cred;
  23. struct scm_fp_list *fp; /* Passed files */
  24. #ifdef CONFIG_SECURITY_NETWORK
  25. u32 secid; /* Security ID */
  26. #endif
  27. };
  28. #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
  29. #define UNIXSID(skb) (&UNIXCB((skb)).secid)
  30. #define unix_state_lock(s) spin_lock(&unix_sk(s)->lock)
  31. #define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock)
  32. #define unix_state_lock_nested(s) \
  33. spin_lock_nested(&unix_sk(s)->lock, \
  34. SINGLE_DEPTH_NESTING)
  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. unsigned char recursion_level;
  51. struct socket_wq peer_wq;
  52. };
  53. #define unix_sk(__sk) ((struct unix_sock *)__sk)
  54. #define peer_wait peer_wq.wait
  55. #ifdef CONFIG_SYSCTL
  56. extern int unix_sysctl_register(struct net *net);
  57. extern void unix_sysctl_unregister(struct net *net);
  58. #else
  59. static inline int unix_sysctl_register(struct net *net) { return 0; }
  60. static inline void unix_sysctl_unregister(struct net *net) {}
  61. #endif
  62. #endif