File: netlink.h

package info (click to toggle)
batctl 2025.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 840 kB
  • sloc: ansic: 12,083; makefile: 155; sh: 21
file content (72 lines) | stat: -rw-r--r-- 2,155 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) B.A.T.M.A.N. contributors:
 *
 * Marek Lindner <marek.lindner@mailbox.org>, Andrew Lunn <andrew@lunn.ch>
 *
 * License-Filename: LICENSES/preferred/GPL-2.0
 */

#ifndef _BATCTL_NETLINK_H
#define _BATCTL_NETLINK_H

#include <netlink/genl/genl.h>
#include <netlink/genl/ctrl.h>
#include <stdint.h>

struct state;

struct print_opts {
	int read_opt;
	float orig_timeout;
	float watch_interval;
	nl_recvmsg_msg_cb_t callback;
	char *remaining_header;
	const char *static_header;
	uint8_t nl_cmd;
};

struct nlquery_opts {
	int err;
};

struct ether_addr;

int netlink_create(struct state *state);
void netlink_destroy(struct state *state);

char *netlink_get_info(struct state *state, uint8_t nl_cmd, const char *header);
int translate_mac_netlink(struct state *state, const struct ether_addr *mac,
			  struct ether_addr *mac_out);
int get_nexthop_netlink(struct state *state, const struct ether_addr *mac,
			uint8_t *nexthop, char *ifname);
int get_primarymac_netlink(struct state *state, uint8_t *primarymac);
int get_algoname_netlink(struct state *state, unsigned int mesh_ifindex,
			 char *algoname, size_t algoname_len);

extern struct nla_policy batadv_netlink_policy[];

int missing_mandatory_attrs(struct nlattr *attrs[], const int mandatory[],
			    int num);
int netlink_print_common(struct state *state, char *orig_iface, int read_opt,
			 float orig_timeout, float watch_interval,
			 const char *header, uint8_t nl_cmd,
			 nl_recvmsg_msg_cb_t callback);

int netlink_print_common_cb(struct nl_msg *msg, void *arg);
int netlink_stop_callback(struct nl_msg *msg, void *arg);
int netlink_print_error(struct sockaddr_nl *nla, struct nlmsgerr *nlerr,
			void *arg);
void netlink_print_remaining_header(struct print_opts *opts);

int netlink_query_common(struct state *state,
			 unsigned int mesh_ifindex, uint8_t nl_cmd,
			 nl_recvmsg_msg_cb_t callback,
			 nl_recvmsg_msg_cb_t attribute_cb,
			 int flags, struct nlquery_opts *query_opts);

extern char algo_name_buf[256];
extern int last_err;
extern int64_t mcast_flags;
extern int64_t mcast_flags_priv;

#endif /* _BATCTL_NETLINK_H */