libnl: /data/src/libnl3/lib/nl-core.h Source File

libnl 3.10.0

nl-core.h
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2014 Thomas Graf <tgraf@suug.ch>
4 */
5
6#ifndef __LIB_NL_CORE_H__
7#define __LIB_NL_CORE_H__
8
9 struct nl_cb
10{
11 nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1];
12 void * cb_args[NL_CB_TYPE_MAX+1];
13
14 nl_recvmsg_err_cb_t cb_err;
15 void * cb_err_arg;
16
17 /** May be used to replace nl_recvmsgs with your own implementation
18 * in all internal calls to nl_recvmsgs. */
19 int (*cb_recvmsgs_ow)(struct nl_sock *,
20 struct nl_cb *);
21
22 /** Overwrite internal calls to nl_recv, must return the number of
23 * octets read and allocate a buffer for the received data. */
24 int (*cb_recv_ow)(struct nl_sock *,
25 struct sockaddr_nl *,
26 unsigned char **,
27 struct ucred **);
28
29 /** Overwrites internal calls to nl_send, must send the netlink
30 * message. */
31 int (*cb_send_ow)(struct nl_sock *,
32 struct nl_msg *);
33
34 int cb_refcnt;
35 /** indicates the callback that is currently active */
36 enum nl_cb_type cb_active;
37};
38
39static inline int nl_cb_call(struct nl_cb *cb, enum nl_cb_type type, struct nl_msg *msg)
40{
41 int ret;
42
43 cb->cb_active = type;
44 ret = cb->cb_set[type](msg, cb->cb_args[type]);
45 cb->cb_active = __NL_CB_TYPE_MAX;
46 return ret;
47}
48
49int _nl_socket_is_local_port_unspecified (struct nl_sock *sk);
50uint32_t _nl_socket_set_local_port_no_release(struct nl_sock *sk, int generate_other);
51
52void _nl_socket_used_ports_release_all(const uint32_t *used_ports);
53void _nl_socket_used_ports_set(uint32_t *used_ports, uint32_t port);
54
55extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *,
56 struct nlmsghdr *, struct nl_parser_param *);
57
58extern void dump_from_ops(struct nl_object *, struct nl_dump_params *);
59
60#endif /* __LIB_NL_CORE_H__ */
nl_recvmsg_err_cb_t
int(* nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla, struct nlmsgerr *nlerr, void *arg)
nl_recvmsgs() callback for error message processing customization
Definition handlers.h:47
nl_cb_type
nl_cb_type
Callback types.
Definition handlers.h:87
nl_recvmsg_msg_cb_t
int(* nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg)
nl_recvmsgs() callback for message processing customization
Definition handlers.h:38
nl_cb
Definition nl-core.h:10
nl_cb::cb_recvmsgs_ow
int(* cb_recvmsgs_ow)(struct nl_sock *, struct nl_cb *)
May be used to replace nl_recvmsgs with your own implementation in all internal calls to nl_recvmsgs.
Definition nl-core.h:19
nl_cb::cb_active
enum nl_cb_type cb_active
indicates the callback that is currently active
Definition nl-core.h:36
nl_cb::cb_recv_ow
int(* cb_recv_ow)(struct nl_sock *, struct sockaddr_nl *, unsigned char **, struct ucred **)
Overwrite internal calls to nl_recv, must return the number of octets read and allocate a buffer for ...
Definition nl-core.h:24
nl_cb::cb_send_ow
int(* cb_send_ow)(struct nl_sock *, struct nl_msg *)
Overwrites internal calls to nl_send, must send the netlink message.
Definition nl-core.h:31
nl_dump_params
Dumping parameters.
Definition types.h:32