EMANE  1.2.1
libemane/shimlayer.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014,2016 - Adjacent Link LLC, Bridgewater,
3  * New Jersey
4  * Copyright (c) 2008 - 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 #include "shimlayer.h"
36 
38  NEMLayer * pImplementor,
39  PlatformServiceProvider * pPlatformService) :
40  NEMQueuedLayer{id,pPlatformService},
41  pImplementor_{pImplementor},
42  pPlatformService_{pPlatformService}
43 {}
44 
46 {}
47 
48 
50 {
51  NEMQueuedLayer::initialize(registrar);
52 
53  pImplementor_->initialize(registrar);
54 }
55 
56 
58 {
59  pImplementor_->configure(update);
60 }
61 
62 
64 {
65  // start the queue processing thread
67 
68  pImplementor_->start();
69 }
70 
71 
73 {
74  pImplementor_->postStart();
75 }
76 
77 
79 {
80  pImplementor_->stop();
81 
82  // stop the queue processing thread
84 }
85 
86 
88 {
89  pImplementor_->destroy();
90 }
91 
92 
93 void EMANE::ShimLayer::doProcessConfiguration(const ConfigurationUpdate & update)
94 {
95  pImplementor_->processConfiguration(update);
96 }
97 
98 
99 void EMANE::ShimLayer::doProcessUpstreamPacket(UpstreamPacket & pkt,
100  const ControlMessages & msgs)
101 {
102  pImplementor_->processUpstreamPacket(pkt,msgs);
103 }
104 
105 
106 void EMANE::ShimLayer::doProcessDownstreamPacket(DownstreamPacket & pkt,
107  const ControlMessages & msgs)
108 {
109  pImplementor_->processDownstreamPacket(pkt,msgs);
110 }
111 
112 
113 void EMANE::ShimLayer::doProcessUpstreamControl(const ControlMessages & msgs)
114 {
115  pImplementor_->processUpstreamControl(msgs);
116 }
117 
118 
119 void EMANE::ShimLayer::doProcessDownstreamControl(const ControlMessages & msgs)
120 {
121  pImplementor_->processDownstreamControl(msgs);
122 }
123 
124 
126 {
127  pImplementor_->setUpstreamTransport(pUpstreamTransport);
128 }
129 
130 
132 {
133  pImplementor_->setDownstreamTransport(pDownstreamTransport);
134 }
135 
136 
137 void EMANE::ShimLayer::doProcessEvent(const EventId & eventId,
138  const Serialization & serialization)
139 {
140  pImplementor_->processEvent(eventId,serialization);
141 }
142 
143 
144 void EMANE::ShimLayer::doProcessTimedEvent(TimerEventId eventId,
145  const TimePoint & expireTime,
146  const TimePoint & scheduleTime,
147  const TimePoint & fireTime,
148  const void * arg)
149 {
150  pImplementor_->processTimedEvent(eventId,expireTime,scheduleTime,fireTime,arg);
151 }
void setDownstreamTransport(DownstreamTransport *) override
std::string Serialization
Definition: serializable.h:42
void start() override
A Packet class that allows upstream processing to strip layer headers as the packet travels up the st...
void setUpstreamTransport(UpstreamTransport *) override
void postStart() override
The Registrar interface provides access to all of the emulator registrars.
Definition: registrar.h:50
void destroy() override
std::list< const ControlMessage * > ControlMessages
Base class for NEMLayer containers. Builders construct NEMLayer objects to contain derived instances ...
Definition: nemlayer.h:57
void stop() override
std::uint16_t EventId
Definition: types.h:53
The PlatformServiceProvider interface provides access to emulator services.
void start() override
void stop() override
Specialized packet the allows downstream processing to add layer specific headers as the packet trave...
void initialize(Registrar &registrar) override
std::uint16_t NEMId
Definition: types.h:52
ShimLayer(NEMId id, NEMLayer *pImplementor, PlatformServiceProvider *pPlatformService)
void initialize(Registrar &registrar) override
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
UpstreamTransport allows for processing upstream data and control messages. Upstream packets and cont...
void configure(const ConfigurationUpdate &update) override
std::size_t TimerEventId
Definition: types.h:54
Clock::time_point TimePoint
Definition: types.h:50
DownstreamTransport allows for processing downstream data and control messages.
A layer stack with a porcessing queue between each layer to decouple to intra queue processing...