1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __AF_UNIX_H
3#define __AF_UNIX_H
4
5#include <linux/uidgid.h>
6
7#define UNIX_HASH_MOD (256 - 1)
8#define UNIX_HASH_SIZE (256 * 2)
9#define UNIX_HASH_BITS 8
10
11struct sock *unix_peer_get(struct sock *sk);
12
13struct unix_skb_parms {
14 struct pid *pid; /* skb credentials */
15 kuid_t uid;
16 kgid_t gid;
17 struct scm_fp_list *fp; /* Passed files */
18#ifdef CONFIG_SECURITY_NETWORK
19 u32 secid; /* Security ID */
20#endif
21 u32 consumed;
22} __randomize_layout;
23
24#define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
25
26/* GC for SCM_RIGHTS */
27void unix_add_edges(struct scm_fp_list *fpl, struct unix_sock *receiver);
28void unix_del_edges(struct scm_fp_list *fpl);
29void unix_update_edges(struct unix_sock *receiver);
30int unix_prepare_fpl(struct scm_fp_list *fpl);
31void unix_destroy_fpl(struct scm_fp_list *fpl);
32void unix_schedule_gc(struct user_struct *user);
33
34/* SOCK_DIAG */
35long unix_inq_len(struct sock *sk);
36long unix_outq_len(struct sock *sk);
37
38/* sysctl */
39#ifdef CONFIG_SYSCTL
40int unix_sysctl_register(struct net *net);
41void unix_sysctl_unregister(struct net *net);
42#else
43static inline int unix_sysctl_register(struct net *net)
44{
45 return 0;
46}
47
48static inline void unix_sysctl_unregister(struct net *net)
49{
50}
51#endif
52
53/* BPF SOCKMAP */
54int __unix_dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags);
55int __unix_stream_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags);
56
57#ifdef CONFIG_BPF_SYSCALL
58extern struct proto unix_dgram_proto;
59extern struct proto unix_stream_proto;
60
61int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore);
62int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore);
63void __init unix_bpf_build_proto(void);
64#else
65static inline void __init unix_bpf_build_proto(void)
66{
67}
68#endif
69
70#endif
71

source code of linux/net/unix/af_unix.h