DESERT 4.0.0
uwicrp-module-sink.h
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//
29
40#ifndef UWICRP_MODULE_SINK_H
41#define UWICRP_MODULE_SINK_H
42
43#include "packet.h"
44#include "uwicrp-common.h"
45#include "uwicrp-hdr-ack.h"
46#include "uwicrp-hdr-data.h"
47#include "uwicrp-hdr-status.h"
48#include <uwip-clmsg.h>
49#include <uwip-module.h>
50
51#include <ctime>
52#include <iostream>
53#include <module.h>
54#include <rng.h>
55#include <sstream>
56#include <string>
57#include <tclcl.h>
58#include <vector>
59
63class UwIcrpSink : public Module
64{
65
66public:
70 UwIcrpSink();
71
76
77protected:
85 virtual int recvSyncClMsg(ClMessage *);
86
95 virtual int recvAsyncClMsg(ClMessage *);
96
107 virtual int command(int, const char *const *);
108
114 virtual void recv(Packet *);
115
123 virtual void initStatusPkt(Packet *, Packet *);
124
133 virtual void initialize();
134
144 virtual void sendBackAck(const Packet *p);
145
153 virtual string printIP(const uint8_t);
154
160 static inline const int
162 {
163 return sizeof(hdr_uwicrp_ack);
164 }
165
171 static inline const int
173 {
174 return sizeof(hdr_uwicrp_data);
175 }
176
182 static inline const int
184 {
185 return sizeof(hdr_uwicrp_status);
186 }
187
188 uint8_t ipAddr_;
192private:
193 static long numberofackpkt_;
195 static long numberofstatuspkt_;
197};
198
199#endif // UWICRP_MODULE_SINK_H
Definition uwicrp-module-sink.h:64
virtual void initStatusPkt(Packet *, Packet *)
Definition uwicrp-module-sink.cpp:221
static long numberofackpkt_
Definition uwicrp-module-sink.h:193
virtual void initialize()
Definition uwicrp-module-sink.cpp:96
int printDebug_
Definition uwicrp-module-sink.h:189
virtual void recv(Packet *)
Definition uwicrp-module-sink.cpp:144
virtual int recvSyncClMsg(ClMessage *)
Definition uwicrp-module-sink.cpp:80
uint8_t ipAddr_
Definition uwicrp-module-sink.h:188
static long numberofstatuspkt_
Definition uwicrp-module-sink.h:195
UwIcrpSink()
Definition uwicrp-module-sink.cpp:66
virtual string printIP(const uint8_t)
Definition uwicrp-module-sink.cpp:261
static const int getAckPktHeaderSize()
Definition uwicrp-module-sink.h:161
static const int getStatusPktHeaderSize()
Definition uwicrp-module-sink.h:183
virtual void sendBackAck(const Packet *p)
Definition uwicrp-module-sink.cpp:269
virtual int recvAsyncClMsg(ClMessage *)
Definition uwicrp-module-sink.cpp:86
static const int getDataPktHeaderSize()
Definition uwicrp-module-sink.h:172
virtual int command(int, const char *const *)
Definition uwicrp-module-sink.cpp:105
~UwIcrpSink()
Definition uwicrp-module-sink.cpp:75
Definition uwicrp-hdr-ack.h:51
Definition uwicrp-hdr-data.h:53
Definition uwicrp-hdr-status.h:53
Common structures and definition used by UWICRP.
Provides the Ack Messages header description.
Provides the Data Messages header description.
Provides the Status Messages header description.
Cross layer messages definition for the UWIP Module.
Provides the UWIP packets header description. Definition of the class that define the network layer.