xref: /aosp_15_r20/external/wmediumd/wmediumd/api.h (revision 621120a22a0cd8ba80b131fe8bcb37c86ff453e3)
1 /*
2  * Copyright (C) 2020 Intel Corporation
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 #ifndef _WMEDIUMD_API_H
7 #define _WMEDIUMD_API_H
8 #include <stdint.h>
9 
10 #include "ieee80211.h"
11 
12 enum wmediumd_message {
13 	/* invalid message */
14 	WMEDIUMD_MSG_INVALID,
15 
16 	/* ACK, returned for each message for synchronisation */
17 	WMEDIUMD_MSG_ACK,
18 
19 	/*
20 	 * Register/unregister for frames, this may be a pure control
21 	 * socket which doesn't want to see frames.
22 	 */
23 	WMEDIUMD_MSG_REGISTER,
24 	WMEDIUMD_MSG_UNREGISTER,
25 
26 	/*
27 	 * netlink message, the data is the entire netlink message,
28 	 * this is used to communicate frame TX/RX in the familiar
29 	 * netlink format, to avoid having a special format
30 	 */
31 	WMEDIUMD_MSG_NETLINK,
32 
33 	/* control message, see struct wmediumd_message_control */
34 	WMEDIUMD_MSG_SET_CONTROL,
35 
36 	/*
37 	 * Indicates TX start if WMEDIUMD_RX_CTL_NOTIFY_TX_START is set,
38 	 * with struct wmediumd_tx_start as the payload.
39 	 */
40 	WMEDIUMD_MSG_TX_START,
41 
42 	WMEDIUMD_MSG_GET_STATIONS,
43 
44 	/*
45 	 * Set SNR between two nodes.
46 	 */
47 	WMEDIUMD_MSG_SET_SNR,
48 
49 	/*
50 	 * Clear and reload configuration at specified path
51 	 */
52 	WMEDIUMD_MSG_RELOAD_CONFIG,
53 
54 	/*
55 	 * Clear and reload configuration loaded before
56 	 */
57 	WMEDIUMD_MSG_RELOAD_CURRENT_CONFIG,
58 
59 	/*
60 	 * Start packet capture. If a previous capture exists, the capture will
61 	 * be closed and a new capture will be started. Captured packets are
62 	 * saved at the specified path of wmediumd_start_pcap. The saved file
63 	 * has pcap capture file format.
64 	 */
65 	WMEDIUMD_MSG_START_PCAP,
66 
67 	/*
68 	 * Stop packet capture
69 	 */
70 	WMEDIUMD_MSG_STOP_PCAP,
71 
72 	WMEDIUMD_MSG_STATIONS_LIST,
73 
74 	/*
75 	 * Set position of station.
76 	 */
77 	WMEDIUMD_MSG_SET_POSITION,
78 
79 	/*
80 	 * Set LCI of station
81 	 */
82 	WMEDIUMD_MSG_SET_LCI,
83 
84 	/*
85 	 * Set CIVIC loc of station
86 	 */
87 	WMEDIUMD_MSG_SET_CIVICLOC,
88 };
89 
90 struct wmediumd_message_header {
91 	/* type of message - see enum wmediumd_message */
92 	uint32_t type;
93 	/* data length */
94 	uint32_t data_len;
95 
96 	/* variable-length data according to the message type */
97 	uint8_t data[];
98 };
99 
100 enum wmediumd_control_flags {
101 	WMEDIUMD_CTL_NOTIFY_TX_START		= 1 << 0,
102 	WMEDIUMD_CTL_RX_ALL_FRAMES		= 1 << 1,
103 };
104 
105 struct wmediumd_message_control {
106 	uint32_t flags;
107 
108 	/*
109 	 * For compatibility, wmediumd is meant to understand shorter
110 	 * (and ignore unknown parts of longer) control messages than
111 	 * what's sent to it, so always take care to have defaults as
112 	 * zero since that's what it assumes.
113 	 */
114 };
115 
116 struct wmediumd_tx_start {
117 	/*
118 	 * The cookie is set only when telling the sender, otherwise
119 	 * it's set to 0.
120 	 */
121 	uint64_t cookie;
122 	uint32_t freq;
123 	uint32_t reserved[3];
124 };
125 
126 #pragma pack(push, 1)
127 struct wmediumd_set_snr {
128 	/* MAC address of node 1 */
129 	uint8_t node1_mac[6];
130 	/* MAC address of node 2 */
131 	uint8_t node2_mac[6];
132 	/* New SNR between two nodes */
133 	uint8_t snr;
134 };
135 #pragma pack(pop)
136 
137 struct wmediumd_load_config {
138 	/* path of wmediumd configuration file */
139 	char config_path[0];
140 };
141 
142 struct wmediumd_start_pcap {
143 	char pcap_path[0];
144 };
145 
146 #pragma pack(push, 1)
147 struct wmediumd_station_info {
148 	char addr[ETH_ALEN];
149 	char hwaddr[ETH_ALEN];
150 
151 	double x;
152 	double y;
153 
154 	/*
155 	 * Offsets to the null-terminating string data.
156 	 * They point outside of the struct wmediumd_station_info,
157 	 * and even struct wmediumd_station_infos for multiple stations.
158 	 */
159 	int lci_offset;
160 	int civicloc_offset;
161 
162 	int tx_power;
163 };
164 
165 struct wmediumd_station_infos {
166 	uint32_t count;
167 	struct wmediumd_station_info stations[0];
168 };
169 
170 struct wmediumd_set_position {
171 	/* MAC address */
172 	uint8_t mac[6];
173 	/* X position of station */
174 	double x;
175 	/* Y position of station */
176 	double y;
177 };
178 
179 struct wmediumd_set_tx_power {
180 	/* MAC address */
181 	uint8_t mac[6];
182 	/* TX power of station */
183 	int tx_power;
184 };
185 
186 struct wmediumd_set_lci {
187 	/* MAC address */
188 	uint8_t mac[6];
189 
190 	/* LCI */
191 	char lci[0];
192 };
193 
194 struct wmediumd_set_civicloc {
195 	/* MAC address */
196 	uint8_t mac[6];
197 
198 	/* CIVIC location */
199 	char civicloc[0];
200 };
201 
202 #pragma pack(pop)
203 
204 #endif /* _WMEDIUMD_API_H */
205