File: functions.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 (84 lines) | stat: -rw-r--r-- 2,442 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
73
74
75
76
77
78
79
80
81
82
83
84
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) B.A.T.M.A.N. contributors:
 *
 * Andreas Langer <an.langer@gmx.de>, Marek Lindner <marek.lindner@mailbox.org>
 *
 * License-Filename: LICENSES/preferred/GPL-2.0
 */

#ifndef _BATCTL_FUNCTIONS_H
#define _BATCTL_FUNCTIONS_H

#include <net/ethernet.h>
#include <netlink/netlink.h>
#include <netlink/handlers.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include "main.h"

/**
 * enum batadv_bandwidth_units - bandwidth unit types
 */
enum batadv_bandwidth_units {
	/** @BATADV_BW_UNIT_KBIT: unit type kbit */
	BATADV_BW_UNIT_KBIT,

	/** @BATADV_BW_UNIT_MBIT: unit type mbit */
	BATADV_BW_UNIT_MBIT,
};

#define ETH_STR_LEN 17
#define BATMAN_ADV_TAG "batman-adv:"

#define PATH_BUFF_LEN 400

struct state;

/* return time delta from start to end in milliseconds */
void start_timer(void);
double end_timer(void);
char *ether_ntoa_long(const struct ether_addr *addr);
char *get_name_by_macaddr(struct ether_addr *mac_addr, int read_opt);
char *get_name_by_macstr(char *mac_str, int read_opt);
int file_exists(const char *fpath);
int read_file(const char *full_path, int read_opt);
struct ether_addr *translate_mac(struct state *state,
				 const struct ether_addr *mac);
struct ether_addr *resolve_mac(const char *asc);
int query_rtnl_link(int ifindex, nl_recvmsg_msg_cb_t func, void *arg);
int netlink_simple_request(struct nl_msg *msg);
int translate_mesh_iface_vlan(struct state *state, const char *vlandev);
int translate_vlan_iface(struct state *state, const char *vlandev);
int translate_vid(struct state *state, const char *vidstr);
int translate_hard_iface(struct state *state, const char *hardif);
int guess_netdev_type(const char *netdev, enum selector_prefix *type);
int get_algoname(struct state *state, unsigned int mesh_ifindex,
		 char *algoname, size_t algoname_len);
int check_mesh_iface(struct state *state);
int check_mesh_iface_ownership(struct state *state, char *hard_iface);

void get_random_bytes(void *buf, size_t buflen);

int parse_bool(const char *val, bool *res);
bool parse_throughput(char *buff, const char *description,
		      uint32_t *throughput);

extern char *line_ptr;

enum {
	NO_FLAGS = 0x00,
	CONT_READ = 0x01,
	CLR_CONT_READ = 0x02,
	USE_BAT_HOSTS = 0x04,
	USE_READ_BUFF = 0x10,
	SILENCE_ERRORS = 0x20,
	NO_OLD_ORIGS = 0x40,
	COMPAT_FILTER = 0x80,
	SKIP_HEADER = 0x100,
	UNICAST_ONLY = 0x200,
	MULTICAST_ONLY = 0x400,
};

#endif