EMANE  1.2.1
libemane/phylayer.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 "phylayer.h"
36 
38  NEMLayer * pImplementor,
39  PlatformServiceProvider * pPlatformService) :
40  NEMQueuedLayer{id, pPlatformService},
41  pImplementor_{pImplementor},
42  pPlatformService_{pPlatformService}
43 {}
44 
46 {}
47 
49 {
50  NEMQueuedLayer::initialize(registrar);
51 
52  pImplementor_->initialize(registrar);
53 }
54 
55 
57 {
58  pImplementor_->configure(update);
59 }
60 
61 
63 {
64  // start the queue processing thread
66 
67  pImplementor_->start();
68 }
69 
70 
72 {
73  pImplementor_->postStart();
74 }
75 
76 
78 {
79  pImplementor_->stop();
80 
81  // stop the queue processing thread
83 }
84 
85 
87 {
88  pImplementor_->destroy();
89 }
90 
91 
93 {
94  pImplementor_->setUpstreamTransport(pUpstreamTransport);
95 }
96 
97 
99 {
100  pImplementor_->setDownstreamTransport(pDownstreamTransport);
101 }
102 
103 void EMANE::PHYLayer::doProcessConfiguration(const ConfigurationUpdate & update)
104 {
105  pImplementor_->processConfiguration(update);
106 }
107 
108 void EMANE::PHYLayer::doProcessDownstreamPacket(DownstreamPacket & pkt,
109  const ControlMessages & msgs)
110 {
111  pImplementor_->processDownstreamPacket(pkt,msgs);
112 }
113 
114 
115 void EMANE::PHYLayer::doProcessDownstreamControl(const ControlMessages & msgs)
116 {
117  pImplementor_->processDownstreamControl(msgs);
118 }
119 
120 
121 void EMANE::PHYLayer::doProcessUpstreamPacket(UpstreamPacket & pkt,
122  const ControlMessages & ctrl)
123 {
124  static_cast<UpstreamTransport *>(pImplementor_.get())->processUpstreamPacket(pkt,ctrl);
125 }
126 
127 
128 void EMANE::PHYLayer::doProcessUpstreamControl(const ControlMessages &)
129 {}
130 
131 
132 void EMANE::PHYLayer::doProcessEvent(const EventId & eventId,
133  const Serialization & serialization)
134 {
135  pImplementor_->processEvent(eventId,serialization);
136 }
137 
138 
139 
140 void EMANE::PHYLayer::doProcessTimedEvent(TimerEventId eventId,
141  const TimePoint & expireTime,
142  const TimePoint & scheduleTime,
143  const TimePoint & fireTime,
144  const void * arg)
145 {
146  pImplementor_->processTimedEvent(eventId,expireTime,scheduleTime,fireTime,arg);
147 }
std::string Serialization
Definition: serializable.h:42
A Packet class that allows upstream processing to strip layer headers as the packet travels up the st...
PHYLayer(NEMId id, NEMLayer *pImplementor, PlatformServiceProvider *pPlatformService)
The Registrar interface provides access to all of the emulator registrars.
Definition: registrar.h:50
std::list< const ControlMessage * > ControlMessages
void postStart() override
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 start() override
void stop() override
Specialized packet the allows downstream processing to add layer specific headers as the packet trave...
void stop() override
void initialize(Registrar &registrar) override
std::uint16_t NEMId
Definition: types.h:52
void destroy() override
void setUpstreamTransport(UpstreamTransport *) override
void configure(const ConfigurationUpdate &update) override
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
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...
void setDownstreamTransport(DownstreamTransport *) override