EMANE  1.2.1
libemane/maclayer.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 "maclayer.h"
36 #include "logservice.h"
37 
39  NEMLayer * pImplementor,
40  PlatformServiceProvider *pPlatformService):
41  NEMQueuedLayer{id, pPlatformService},
42  pImplementor_{pImplementor},
43  pPlatformService_{pPlatformService}
44 {}
45 
47 
49 {
50  NEMQueuedLayer::initialize(registrar);
51 
52  pImplementor_->initialize(registrar);
53 }
54 
56 {
57  pImplementor_->configure(update);
58 }
59 
61 {
62  // start the queue processing thread
64 
65  pImplementor_->start();
66 }
67 
69 {
70  pImplementor_->postStart();
71 }
72 
74 {
75  pImplementor_->stop();
76 
77  // stop the queue processing thread
79 }
80 
82  throw()
83 {
84  pImplementor_->destroy();
85 }
86 
87 void EMANE::MACLayer::doProcessConfiguration(const ConfigurationUpdate & update)
88 {
89  pImplementor_->processConfiguration(update);
90 }
91 
92 void EMANE::MACLayer::doProcessUpstreamPacket(UpstreamPacket & pkt,
93  const ControlMessages & msgs)
94 {
95  static_cast<UpstreamTransport *>(pImplementor_.get())->processUpstreamPacket(pkt,msgs);
96 }
97 
98 void EMANE::MACLayer::doProcessDownstreamPacket(DownstreamPacket & pkt,
99  const ControlMessages & ctrl)
100 {
101  pImplementor_->processDownstreamPacket(pkt,ctrl);
102 }
103 
104 void EMANE::MACLayer::doProcessUpstreamControl(const ControlMessages & msg)
105 {
106  pImplementor_->processUpstreamControl(msg);
107 }
108 
109 void EMANE::MACLayer::doProcessDownstreamControl(const ControlMessages & msg)
110 {
111  pImplementor_->processDownstreamControl(msg);
112 }
113 
115 {
116  pImplementor_->setUpstreamTransport(pUpstreamTransport);
117 }
118 
120 {
121  pImplementor_->setDownstreamTransport(pDownstreamTransport);
122 }
123 
124 void EMANE::MACLayer::doProcessEvent(const EventId & eventId,
125  const Serialization & serialization)
126 {
127  pImplementor_->processEvent(eventId,serialization);
128 }
129 
130 
131 void EMANE::MACLayer::doProcessTimedEvent(TimerEventId eventId,
132  const TimePoint & requestExpireTime,
133  const TimePoint & scheduleTime,
134  const TimePoint & fireTime,
135  const void * arg)
136 {
137  pImplementor_->processTimedEvent(eventId,requestExpireTime,scheduleTime,fireTime,arg);
138 }
void initialize(Registrar &registrar) override
std::string Serialization
Definition: serializable.h:42
void postStart() override
A Packet class that allows upstream processing to strip layer headers as the packet travels up the st...
The Registrar interface provides access to all of the emulator registrars.
Definition: registrar.h:50
void setDownstreamTransport(DownstreamTransport *) override
MACLayer(NEMId id, NEMLayer *pImplementor, PlatformServiceProvider *pPlatformService)
std::list< const ControlMessage * > ControlMessages
Base class for NEMLayer containers. Builders construct NEMLayer objects to contain derived instances ...
Definition: nemlayer.h:57
std::uint16_t EventId
Definition: types.h:53
The PlatformServiceProvider interface provides access to emulator services.
void start() override
void setUpstreamTransport(UpstreamTransport *) override
void stop() override
Specialized packet the allows downstream processing to add layer specific headers as the packet trave...
void destroy() override
void configure(const ConfigurationUpdate &update) override
std::uint16_t NEMId
Definition: types.h:52
void initialize(Registrar &registrar) override
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
UpstreamTransport allows for processing upstream data and control messages. Upstream packets and cont...
std::size_t TimerEventId
Definition: types.h:54
Clock::time_point TimePoint
Definition: types.h:50
void stop() override
void start() override
DownstreamTransport allows for processing downstream data and control messages.
void processUpstreamPacket(UpstreamPacket &pkt, const ControlMessages &msgs) override
A layer stack with a porcessing queue between each layer to decouple to intra queue processing...