Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7100021

Browse files
committed
Implement dual AP/client mode
1 parent b032fe0 commit 7100021

File tree

7 files changed

+547
-231
lines changed

7 files changed

+547
-231
lines changed

components/80211_mac_rust/80211_mac_interface.c

+15-9
Original file line numberDiff line numberDiff line change
@@ -189,29 +189,35 @@ void rs_change_channel(uint8_t channel) {
189189
request_channel_change(channel);
190190
}
191191

192-
void filters_set_scanning_mode();
193-
void filters_set_client_mode(const uint8_t* bssid);
192+
void filters_set_scanning_mode(uint8_t interface, const uint8_t* own_mac);
193+
void filters_set_client_mode(uint8_t interface, const uint8_t* own_mac, const uint8_t* bssid);
194+
void filters_set_ap_mode(uint8_t interface, const uint8_t* bssid);
194195

195-
void rs_filters_set_scanning() {
196-
filters_set_scanning_mode();
196+
void rs_filters_set_scanning(uint8_t interface, const uint8_t* own_mac) {
197+
filters_set_scanning_mode(interface, own_mac);
197198
}
198199

199-
void rs_filters_set_client_with_bssid(const uint8_t* addr) {
200-
filters_set_client_mode(addr);
200+
void rs_filters_set_client_with_bssid(uint8_t interface, const uint8_t* own_mac, const uint8_t* bssid) {
201+
filters_set_client_mode(interface, own_mac, bssid);
202+
}
203+
204+
void rs_filters_set_ap_mode(uint8_t interface, const uint8_t* addr) {
205+
filters_set_ap_mode(interface, addr);
201206
}
202207

203208
// Called from the C ESP-NETIF stack to request the Rust MAC stack to TX a frame
204209
// This function does NOT take ownership of the frame, so you're allowed to reuse the buffer directly after this returns
205210
void c_transmit_data_frame(rs_mac_interface_type_t interface, uint8_t* frame, size_t len) {
206211
// TODO make sure we don't flood the stack by sending too much frames
207212
// maybe use a counting semaphore?
208-
void* queued_buffer = malloc(len);
209-
memcpy(queued_buffer, frame, len);
213+
uint8_t* queued_buffer = malloc(1 + len);
214+
queued_buffer[0] = interface;
215+
memcpy(queued_buffer + 1, frame, len);
210216

211217
rust_mac_event_queue_item_t to_queue = {0};
212218
to_queue.event_type = EVENT_TYPE_MAC_TX_DATA_FRAME;
213219
to_queue.ptr = queued_buffer;
214-
to_queue.len = len;
220+
to_queue.len = len + 1;
215221
if (xQueueSendToBack(rust_mac_event_queue, &to_queue, 0) != pdTRUE) {
216222
rs_recycle_mac_tx_data(queued_buffer);
217223
}

components/80211_mac_rust/include/80211_mac_interface.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ typedef struct {
1616
unsigned rate:5; /**< PHY rate encoding of the packet. Only valid for non HT(11bg) packet */
1717
unsigned :1; /**< reserved */
1818
unsigned sig_mode:2; /**< 0: non HT(11bg) packet; 1: HT(11n) packet; 3: VHT(11ac) packet */
19-
unsigned :16; /**< reserved */
19+
unsigned :8; /**< reserved */
20+
unsigned :4;
21+
unsigned filter_match:2;
22+
unsigned :2;
2023
unsigned mcs:7; /**< Modulation Coding Scheme. If is HT(11n) packet, shows the modulation, range from 0 to 76(MSC0 ~ MCS76) */
2124
unsigned cwb:1; /**< Channel Bandwidth of the packet. 0: 20MHz; 1: 40MHz */
2225
unsigned :16; /**< reserved */
@@ -148,6 +151,7 @@ uint8_t* rs_get_mac_rx_frame(size_t size_required);
148151
void c_recycle_mac_rx_frame(uint8_t* buffer);
149152

150153
void rs_change_channel(uint8_t channel);
151-
void rs_filters_set_scanning();
152-
void rs_filters_set_client_with_bssid(const uint8_t* addr);
154+
void rs_filters_set_scanning(uint8_t interface, const uint8_t* own_addr);
155+
void rs_filters_set_client_with_bssid(uint8_t interface, const uint8_t* own_addr, const uint8_t* bssid);
156+
void rs_filters_set_ap_mode(uint8_t interface, const uint8_t* bssid);
153157

components/80211_mac_rust/rust_crate/Cargo.lock

+8-101
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/80211_mac_rust/rust_crate/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
crate-type = ["staticlib"]
88

99
[dependencies]
10-
ieee80211 = { git = "https://github.com/Frostie314159/ieee80211-rs", rev = "66c863cf2768742397e90c01211b31b4285a5e67" }
10+
ieee80211 = { git = "https://github.com/Frostie314159/ieee80211-rs", rev = "aa4e40084744dd58e42b44cc2a2fccbed87d40c9" }
1111
esp-println = { version = "0.9.1", features = ["esp32", "uart"], default-features = false }
1212
llc = { git = "https://github.com/Frostie314159/llc-rs.git", version = "0.1.0" }
1313
ether-type = { version = "0.1.3" }

0 commit comments

Comments
 (0)