This repository has been archived by the owner on Dec 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWFBTransmitter.cpp
50 lines (37 loc) · 1.52 KB
/
WFBTransmitter.cpp
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
//
// Created by consti10 on 28.11.20.
//
#include "WFBTransmitter.h"
#include <iostream>
void WFBTransmitter::sendPacket(const uint8_t *data, const std::size_t dataLen, const uint8_t multiplexIndex) {
std::cout << "Send packet" << std::endl;
}
int WFBTransmitter::pb_transmit_packet(int seq_nr, uint8_t *packet_transmit_buffer, int packet_header_len,
const uint8_t *packet_data, int packet_length, int num_interfaces,
int param_transmission_mode, int best_adapter) {
int i = 0;
/*
* Add header outside of FEC
*/
wifi_packet_header_t *wph = (wifi_packet_header_t *)(packet_transmit_buffer + packet_header_len);
wph->sequence_number = seq_nr;
memcpy(packet_transmit_buffer + packet_header_len + sizeof(wifi_packet_header_t), packet_data, packet_length);
int plen = packet_length + packet_header_len + sizeof(wifi_packet_header_t);
/*
* TODO: fix magic number, 5 means "all interfaces"
*/
if (best_adapter == 5) {
for (i = 0; i < num_interfaces; ++i) {
//if (write(socks[i], packet_transmit_buffer, plen) < 0 ) fprintf(stderr, "!");
if (write(socks[i], packet_transmit_buffer, plen) < 0) {
return 1;
}
}
} else {
//if (write(socks[best_adapter], packet_transmit_buffer, plen) < 0 ) fprintf(stderr, "!");
if (write(socks[best_adapter], packet_transmit_buffer, plen) < 0) {
return 1;
}
}
return 0;
}