File: vis.h

package info (click to toggle)
alfred 2025.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 448 kB
  • sloc: ansic: 5,948; makefile: 271
file content (94 lines) | stat: -rw-r--r-- 1,825 bytes parent folder | download
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
85
86
87
88
89
90
91
92
93
94
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) B.A.T.M.A.N. contributors:
 *
 * Simon Wunderlich
 *
 * License-Filename: LICENSES/preferred/GPL-2.0
 */

#include <sys/socket.h>
#include <linux/if_ether.h>
#include <stdint.h>
#include "../list.h"
#include "../packet.h"


#ifndef SOURCE_VERSION
#define SOURCE_VERSION				"2025.5"
#endif

#define ALFRED_SOCK_PATH_DEFAULT		"/var/run/alfred.sock"
#define PATH_BUFF_LEN				200
#define VIS_PACKETTYPE				1
#define	VIS_PACKETVERSION			1
#define UPDATE_INTERVAL				10


enum opmode {
	OPMODE_SERVER,
	OPMODE_CLIENT
};

enum vis_format {
	FORMAT_DOT,
	FORMAT_JSON,
	FORMAT_JSONDOC,
};

struct vis_iface {
	uint8_t mac[ETH_ALEN];
};

struct vis_entry {
	uint8_t mac[ETH_ALEN];
	uint8_t ifindex; 	/* 255 = TT */
	uint8_t qual;		/* zero for TT (maybe flags in the future?)
				 * TQ for batman-adv */
}__packed;

struct vis_v1 {
	uint8_t mac[ETH_ALEN];
	uint8_t iface_n;
	uint8_t entries_n;
	__extension__ struct vis_iface ifaces[0]; /* #iface_n of this */
	/* following:
	 * #vis_entries of vis_entry structs
	 */
}__packed;

struct iface_list_entry {
	char name[256];
	uint8_t mac[ETH_ALEN];
	int devindex;
	struct list_head list;
};

struct vis_list_entry {
	struct vis_entry v;
	struct list_head list;
};

#define VIS_DATA_SIZE(vis_data)	\
	(sizeof(*vis_data) + (vis_data)->iface_n * sizeof(struct vis_iface) + \
	 (vis_data)->entries_n * sizeof(struct vis_entry))

struct globals {
	const char *interface;
	enum opmode opmode;
	enum vis_format vis_format;
	uint8_t buf[65536];

	/* internal pointers into buf */
	struct alfred_request_v0 *request;
	struct alfred_push_data_v0 *push;
	struct vis_v1 *vis_data;

	/* lists for parsed information used in server only */
	struct list_head iface_list;
	struct list_head entry_list;

	int unix_sock;
	const char *unix_path;
};