libtins  3.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
pktap.h
1 /*
2  * Copyright (c) 2016, 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_PKTAP_H
31 #define TINS_PKTAP_H
32 
33 #include "pdu.h"
34 #include "macros.h"
35 
36 namespace Tins {
37 
41 class TINS_API PKTAP : public PDU {
42 public:
46  static const PDU::PDUType pdu_flag = PDU::PKTAP;
47 
51  PKTAP();
52 
64  PKTAP(const uint8_t* buffer, uint32_t total_sz);
65 
70  PDUType pdu_type() const {
71  return pdu_flag;
72  }
73 
80  uint32_t header_size() const;
81 
85  PKTAP* clone() const {
86  return new PKTAP(*this);
87  }
88 private:
89  struct pktap_header {
90  uint32_t length;
91  uint32_t next;
92  uint32_t dlt;
93  uint8_t pth_ifname[24];
94  uint32_t flags;
95  uint32_t protocol_family;
96  uint32_t header_length;
97  uint32_t trailer_length;
98  uint32_t pid;
99  uint8_t command[20];
100  uint32_t service_class;
101  uint16_t interface_type;
102  uint16_t interface_unit;
103  uint32_t epid;
104  uint8_t ecommand[20];
105  };
106 
107  void write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent);
108 
109  pktap_header header_;
110 };
111 
112 } // Tins
113 
114 #endif // TINS_PKTAP_H
PDUType
Enum which identifies each type of PDU.
Definition: pdu.h:128
PKTAP * clone() const
Definition: pktap.h:85
Represents a PKTAP PDU.
Definition: pktap.h:41
Base class for protocol data units.
Definition: pdu.h:108
PDUType pdu_type() const
Getter for the PDU's type.
Definition: pktap.h:70