xref: /aosp_15_r20/external/libnl/include/nl-priv-dynamic-core/nl-core.h (revision 4dc78e53d49367fa8e61b07018507c90983a077d)
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright (c) 2003-2013 Thomas Graf <[email protected]>
4  */
5 
6 #ifndef __NL_SHARED_CORE_NL_CORE_H__
7 #define __NL_SHARED_CORE_NL_CORE_H__
8 
9 #define NL_SOCK_PASSCRED (1 << 1)
10 #define NL_OWN_PORT (1 << 2)
11 #define NL_MSG_PEEK (1 << 3)
12 #define NL_MSG_PEEK_EXPLICIT (1 << 4)
13 #define NL_NO_AUTO_ACK (1 << 5)
14 
15 struct nl_sock {
16 	struct sockaddr_nl s_local;
17 	struct sockaddr_nl s_peer;
18 	int s_fd;
19 	int s_proto;
20 	unsigned int s_seq_next;
21 	unsigned int s_seq_expect;
22 	int s_flags;
23 	struct nl_cb *s_cb;
24 	size_t s_bufsize;
25 };
26 
wait_for_ack(struct nl_sock * sk)27 static inline int wait_for_ack(struct nl_sock *sk)
28 {
29 	if (sk->s_flags & NL_NO_AUTO_ACK)
30 		return 0;
31 	else
32 		return nl_wait_for_ack(sk);
33 }
34 
35 #define LOOSE_COMPARISON 1
36 #define ID_COMPARISON 2
37 
38 #define NL_OBJ_MARK 1
39 
40 struct nl_data {
41 	size_t d_size;
42 	void *d_data;
43 };
44 
45 struct nl_addr {
46 	int a_family;
47 	unsigned int a_maxsize;
48 	unsigned int a_len;
49 	int a_prefixlen;
50 	int a_refcnt;
51 	char a_addr[0];
52 };
53 
54 #define NL_MSG_CRED_PRESENT 1
55 
56 struct nl_msg {
57 	int nm_protocol;
58 	int nm_flags;
59 	struct sockaddr_nl nm_src;
60 	struct sockaddr_nl nm_dst;
61 	struct ucred nm_creds;
62 	struct nlmsghdr *nm_nlh;
63 	size_t nm_size;
64 	int nm_refcnt;
65 };
66 
67 /*****************************************************************************/
68 
69 int nl_getprotobyname(const char *name);
70 
71 bool nl_getprotobynumber(int proto, char *out_name, size_t name_len);
72 
73 extern const char *nl_strerror_l(int err);
74 
75 extern int __nl_read_num_str_file(const char *path,
76 				  int (*cb)(long, const char *));
77 
78 extern int __trans_list_add(int, const char *, struct nl_list_head *);
79 extern void __trans_list_clear(struct nl_list_head *);
80 
81 extern char *__type2str(int, char *, size_t, const struct trans_tbl *, size_t);
82 extern int __str2type(const char *, const struct trans_tbl *, size_t);
83 
84 extern char *__list_type2str(int, char *, size_t, struct nl_list_head *);
85 extern int __list_str2type(const char *, struct nl_list_head *);
86 
87 extern char *__flags2str(int, char *, size_t, const struct trans_tbl *, size_t);
88 extern int __str2flags(const char *, const struct trans_tbl *, size_t);
89 
90 #endif /* __NL_SHARED_CORE_NL_CORE_H__ */
91