DESERT 3.5.1
Loading...
Searching...
No Matches
DESERT_Framework/DESERT/data_link/uwpolling/initlib.cpp
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
38#include <tclcl.h>
39#include "uwpolling_AUV.h"
40#include "uwpolling_NODE.h"
41#include "uwpolling_SINK.h"
42#include "uwpolling_cmn_hdr.h"
43#include "sap.h"
44#include "packet.h"
45
46int hdr_PROBE::offset_ = 0;
48int hdr_POLL::offset_ = 0;
52
53packet_t PT_TRIGGER;
54packet_t PT_PROBE;
56packet_t PT_POLL;
57packet_t PT_AUV_MULE;
58packet_t PT_ACK_SINK;
59
63static class ProbeHeaderClass : public PacketHeaderClass
64{
65public:
70 : PacketHeaderClass("PacketHeader/PROBE", sizeof(hdr_PROBE))
71 {
72 this->bind();
73 bind_offset(&hdr_PROBE::offset_);
74 }
76
80static class TriggerHeaderClass : public PacketHeaderClass
81{
82public:
87 : PacketHeaderClass("PacketHeader/TRIGGER", sizeof(hdr_TRIGGER))
88 {
89 this->bind();
90 bind_offset(&hdr_TRIGGER::offset_);
91 }
93
97static class PollHeaderClass : public PacketHeaderClass
98{
99public:
104 : PacketHeaderClass("PacketHeader/POLL", sizeof(hdr_POLL))
105 {
106 this->bind();
107 bind_offset(&hdr_POLL::offset_);
108 }
110
114static class AuvMuleHeaderClass : public PacketHeaderClass
115{
116public:
121 : PacketHeaderClass("PacketHeader/AUV_MULE", sizeof(hdr_AUV_MULE))
122 {
123 this->bind();
124 bind_offset(&hdr_AUV_MULE::offset_);
125 }
127
131static class AckSinkHeaderClass : public PacketHeaderClass
132{
133public:
138 : PacketHeaderClass("PacketHeader/ACK_SINK", sizeof(hdr_ACK_SINK))
139 {
140 this->bind();
141 bind_offset(&hdr_ACK_SINK::offset_);
142 }
144
148static class ProbeSinkHeaderClass : public PacketHeaderClass
149{
150public:
155 : PacketHeaderClass("PacketHeader/PROBE_SINK", sizeof(hdr_PROBE_SINK))
156 {
157 this->bind();
158 bind_offset(&hdr_PROBE_SINK::offset_);
159 }
161
162extern EmbeddedTcl uwpolling_default;
163
164extern "C" int
166{
167 PT_PROBE = p_info::addPacket("UWPOLLING/PROBE");
168 PT_TRIGGER = p_info::addPacket("UWPOLLING/TRIGGER");
169 PT_POLL = p_info::addPacket("UWPOLLING/POLL");
170 PT_AUV_MULE = p_info::addPacket("UWPOLLING/AUV_MULE");
171 PT_ACK_SINK =p_info::addPacket("UWPOLLING/ACK_SINK");
172 PT_PROBE_SINK = p_info::addPacket("UWPOLLING/PROBE_SINK");
173 uwpolling_default.load();
174 return 0;
175}
Class that describe the Header of ACK sent by the sink.
Class that describe the Header of AUV_MULEt.
Class that describe the Header of POLL Packet.
Class that describe the Header of PROBE Packet.
Class that describe the Header of PROBE_SINK Packet.
Class that describe the Header of TRIGGER Packet.
Header of the ACK sent by the SINK.
static int offset_
Required by the PacketHeaderManager.
Header of the data sent from AUV MULE to SINK.
static int offset_
ID of the last packet transmitted in the round.
Header of the POLL message.
static int offset_
Required by the PacketHeaderManager.
Header of the PROBE message.
static int offset_
Required by the PacketHeaderManager.
Header of the PROBE message.
static int offset_
Required by the PacketHeaderManager.
Header of the TRIGGER message.
static int offset_
Required by the PacketHeaderManager.
Class that represents the AUV of UWPOLLING.
Class that represents a node of UWPOLLING.
Class that represents a node of UWPOLLING.
Common structures and variables in the protocol.