af_unix.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifdef __KERNEL__
  36. /* The AF_UNIX socket */
  37. struct unix_sock {
  38. /* WARNING: sk has to be the first member */
  39. struct sock sk;
  40. struct unix_address *addr;
  41. struct dentry *dentry;
  42. struct vfsmount *mnt;
  43. struct mutex readlock;
  44. struct sock *peer;
  45. struct sock *other;
  46. struct list_head link;
  47. atomic_long_t inflight;
  48. spinlock_t lock;
  49. unsigned int gc_candidate : 1;
  50. unsigned int gc_maybe_cycle : 1;
  51. unsigned char recursion_level;
  52. struct socket_wq peer_wq;
  53. };
  54. #define unix_sk(__sk) ((struct unix_sock *)__sk)
  55. #define peer_wait peer_wq.wait
  56. #ifdef CONFIG_SYSCTL
  57. extern int unix_sysctl_register(struct net *net);
  58. extern void unix_sysctl_unregister(struct net *net);
  59. #else
  60. static inline int unix_sysctl_register(struct net *net) { return 0; }
  61. static inline void unix_sysctl_unregister(struct net *net) {}
  62. #endif
  63. #endif
  64. #endif