EMANE  1.0.1
otamanager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2016 - Adjacent Link LLC, Bridgewater, New Jersey
3  * Copyright (c) 2008-2012 - DRS CenGen, LLC, Columbia, Maryland
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of DRS CenGen, LLC nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef EMANEOTAMANAGER_HEADER_
35 #define EMANEOTAMANAGER_HEADER_
36 
37 #include "otaprovider.h"
38 #include "emane/inetaddr.h"
39 #include "multicastsocket.h"
40 #include "otastatisticpublisher.h"
42 
43 #include "emane/utils/singleton.h"
44 
45 #include <map>
46 #include <queue>
47 #include <atomic>
48 #include <thread>
49 
50 #include <uuid.h>
51 
52 
53 namespace EMANE
54 {
61  class OTAManager : public OTAProvider,
62  public Utils::Singleton<OTAManager>
63  {
64  public:
65  OTAManager();
66 
67  ~OTAManager();
68 
69  void sendOTAPacket(NEMId id,
70  const DownstreamPacket & pkt,
71  const ControlMessages & msgs) const override;
72 
73  void registerOTAUser(NEMId id, OTAUser * pOTAUser) override;
74 
75  void unregisterOTAUser(NEMId id) override;
76 
86  void open(const INETAddr & otaGroupAddress,
87  const std::string & sDevice,
88  bool bLoopback,
89  int iTTL,
90  const uuid_t & uuid);
91 
92  void setStatPacketCountRowLimit(size_t rows);
93 
94  void setStatEventCountRowLimit(size_t rows);
95 
96  private:
97  typedef std::map<NEMId,OTAUser *> NEMUserMap;
98  std::thread thread_;
99  NEMUserMap nemUserMap_;
100  INETAddr otaGroupAddress_;
101  MulticastSocket mcast_;
102  bool bOpen_;
103  uuid_t uuid_;
104  mutable OTAStatisticPublisher otaStatisticPublisher_;
105  mutable EventStatisticPublisher eventStatisticPublisher_;
106  mutable std::atomic<std::uint64_t> u64SequenceNumber_;
107 
108  void processOTAMessage();
109  };
110 
112 }
113 
114 #endif //EMANEOTAMANAGER_HEADER_
Interface for OTA.
Definition: otaprovider.h:49
void registerOTAUser(NEMId id, OTAUser *pOTAUser) override
Definition: otamanager.cc:270
void sendOTAPacket(NEMId id, const DownstreamPacket &pkt, const ControlMessages &msgs) const override
Definition: otamanager.cc:81
Ensure a class only has one instance, and provide a global point of access to it. ...
Definition: singleton.h:47
std::list< const ControlMessage * > ControlMessages
Provides OTA access to all platform NEMs and handles intra and inter platform OTA message disseminati...
Definition: otamanager.h:61
Specialized packet the allows downstream processing to add layer specific headers as the packet trave...
std::uint16_t NEMId
Definition: types.h:52
void open(const INETAddr &otaGroupAddress, const std::string &sDevice, bool bLoopback, int iTTL, const uuid_t &uuid)
Definition: otamanager.cc:292
void unregisterOTAUser(NEMId id) override
Definition: otamanager.cc:282
void setStatEventCountRowLimit(size_t rows)
Definition: otamanager.cc:76
OTA user interface that allows access to the OTA provider.
Definition: otauser.h:50
void setStatPacketCountRowLimit(size_t rows)
Definition: otamanager.cc:71
Definition: agent.h:43