EMANE  1.2.1
virtualtransport.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013,2015-2016 - Adjacent Link LLC, Bridgewater,
3  * New Jersey
4  * Copyright (c) 2008-2010 - DRS CenGen, LLC, Columbia, Maryland
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of DRS CenGen, LLC nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef EMANETRANSPORTSVIRTUALVIRTUALTRANSPORT_HEADER_
36 #define EMANETRANSPORTSVIRTUALVIRTUALTRANSPORT_HEADER_
37 
38 #include "ethernettransport.h"
39 
40 #include "emane/inetaddr.h"
41 #include "emane/utils/bitpool.h"
43 
45 
46 #include "tuntap.h"
47 
48 #include <thread>
49 
50 namespace EMANE
51 {
52  namespace Transports
53  {
54  namespace Virtual
55  {
56 
63  {
64  public:
66  PlatformServiceProvider *pPlatformService);
67 
69 
70  void initialize(Registrar & registrar) override;
71 
72  void configure(const ConfigurationUpdate & update) override;
73 
74  void start() override;
75 
76  void postStart() override;
77 
78  void stop() override;
79 
80  void destroy() throw() override;
81 
83  const ControlMessages & msgs);
84 
85  void processUpstreamControl(const ControlMessages & msgs);
86 
87  private:
88  INETAddr address_;
89 
90  INETAddr mask_;
91 
92  std::string sDeviceName_;
93 
94  std::string sDevicePath_;
95 
96  bool bARPMode_;
97 
98  TunTap * pTunTap_;
99 
100  Utils::BitPool * pBitPool_;
101 
102  std::thread thread_;
103 
104  bool bCanceled_;
105 
106  FlowControlClient flowControlClient_;
107 
108  bool bFlowControlEnable_;
109 
110  std::uint64_t u64BitRate_;
111 
112  Utils::CommonLayerStatistics commonLayerStatistics_;
113 
114  void readDevice();
115 
116  void handleUpstreamControl(const ControlMessages & msgs);
117  };
118  }
119  }
120 }
121 
122 #endif // EMANETRANSPORTSVIRTUALVIRTUALTRANSPORT_HEADER_
VirtualTransport(NEMId id, PlatformServiceProvider *pPlatformService)
A Packet class that allows upstream processing to strip layer headers as the packet travels up the st...
Implementation of a rate limiting bit pool.
Definition: bitpool.h:52
The Registrar interface provides access to all of the emulator registrars.
Definition: registrar.h:50
void initialize(Registrar &registrar) override
std::list< const ControlMessage * > ControlMessages
Common NEM layer statistics and drop reason tables.
The PlatformServiceProvider interface provides access to emulator services.
void processUpstreamPacket(UpstreamPacket &pkt, const ControlMessages &msgs)
std::uint16_t NEMId
Definition: types.h:52
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
void configure(const ConfigurationUpdate &update) override
FlowControlClient is the token consumer side of nem layer to transport flow contol.
Definition: agent.h:43
Virtual Device EMANE Transport.
void processUpstreamControl(const ControlMessages &msgs)