libtins  4.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
radiotap_writer.h
1 /*
2  * Copyright (c) 2017, Matias Fontanini
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #ifndef TINS_RADIOTAP_WRITER_H
31 #define TINS_RADIOTAP_WRITER_H
32 
33 #include <vector>
34 #include <stdint.h>
35 #include "../radiotap.h"
36 
37 namespace Tins {
38 namespace Utils {
39 
40 class RadioTapParser;
41 
53 public:
60  RadioTapWriter(std::vector<uint8_t>& buffer);
61 
70  void write_option(const RadioTap::option& option);
71 private:
72  std::vector<uint8_t> build_padding_vector(const uint8_t* last_ptr, RadioTapParser& parser);
73  void update_paddings(const std::vector<uint8_t>& paddings, uint32_t offset);
74 
75  std::vector<uint8_t>& buffer_;
76 };
77 
78 } // Utils
79 } // Tins
80 
81 #endif // TINS_RADIOTAP_WRITER_H
Represents a PDU option field.
Definition: pdu_option.h:201
void write_option(const RadioTap::option &option)
Writes an option, adding/removing padding as needed.
Definition: radiotap_writer.cpp:52
RadioTapWriter(std::vector< uint8_t > &buffer)
Constructs a RadioTapWriter object.
Definition: radiotap_writer.cpp:48
Allows parsing RadioTap options.
Definition: radiotap_parser.h:50
Writes RadioTap options into a buffer.
Definition: radiotap_writer.h:52