• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 struct wmediumd_message_header {
76 	/* type of message - see enum wmediumd_message */
77 	uint32_t type;
78 	/* data length */
79 	uint32_t data_len;
80 
81 	/* variable-length data according to the message type */
82 	uint8_t data[];
83 };
84 
85 enum wmediumd_control_flags {
86 	WMEDIUMD_CTL_NOTIFY_TX_START		= 1 << 0,
87 	WMEDIUMD_CTL_RX_ALL_FRAMES		= 1 << 1,
88 };
89 
90 struct wmediumd_message_control {
91 	uint32_t flags;
92 
93 	/*
94 	 * For compatibility, wmediumd is meant to understand shorter
95 	 * (and ignore unknown parts of longer) control messages than
96 	 * what's sent to it, so always take care to have defaults as
97 	 * zero since that's what it assumes.
98 	 */
99 };
100 
101 struct wmediumd_tx_start {
102 	/*
103 	 * The cookie is set only when telling the sender, otherwise
104 	 * it's set to 0.
105 	 */
106 	uint64_t cookie;
107 	uint32_t freq;
108 	uint32_t reserved[3];
109 };
110 
111 #pragma pack(push, 1)
112 	struct wmediumd_set_snr {
113 	/* MAC address of node 1 */
114 	uint8_t node1_mac[6];
115 	/* MAC address of node 2 */
116 	uint8_t node2_mac[6];
117 	/* New SNR between two nodes */
118 	uint8_t snr;
119 };
120 #pragma pack(pop)
121 
122 struct wmediumd_reload_config {
123 	/* path of wmediumd configuration file */
124 	char config_path[0];
125 };
126 
127 struct wmediumd_start_pcap {
128 	char pcap_path[0];
129 };
130 
131 #pragma pack(push, 1)
132 struct wmediumd_station_info {
133 	char addr[ETH_ALEN];
134 	char hwaddr[ETH_ALEN];
135 
136 	double x;
137 	double y;
138 
139 	int tx_power;
140 };
141 
142 struct wmediumd_station_infos {
143 	uint32_t count;
144 	struct wmediumd_station_info stations[0];
145 };
146 #pragma pack(pop)
147 
148 #endif /* _WMEDIUMD_API_H */
149