DESERT 3.5.1
Loading...
Searching...
No Matches
hdr-uwal.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
38#ifndef HDR_UWAL_H
39#define HDR_UWAL_H
40
41#include <packet.h>
42
43#define HDR_UWAL(p) (hdr_uwal::access(p))
44#define MAX_BIN_PKT_ARRAY_LENGTH 2240
45#define MAX_DUMMY_STRING_LENGTH 2240
46
47extern packet_t PT_UWAL;
48
52typedef struct hdr_uwal {
53
54 // This members are always needed by NS
55 static int offset_;
56 inline static int &
58 {
59 return offset_;
60 }
61 inline static struct hdr_uwal *
62 access(const Packet *p)
63 {
64 return (struct hdr_uwal *) p->access(offset_);
65 }
66
67 // Custom header fields
68 // Fields that can be encoded and sent over the channel
69 uint8_t srcID_;
70 unsigned int pktID_;
72 uint8_t Mbit_;
78 // Fields to handle only locally (actually, this is the information to be
79 // sent over and retrieved from the channel ad modem payload...)
88 uint32_t binPktLength_;
89 uint32_t binHdrLength_;
95 inline uint8_t &
97 {
98 return srcID_;
99 }
100
104 inline unsigned int &
106 {
107 return pktID_;
108 }
109
113 inline uint16_t &
115 {
116 return framePayloadOffset_;
117 }
118
122 inline uint8_t &
124 {
125 return Mbit_;
126 }
127
131 inline char *
133 {
134 return dummyStr_;
135 }
136
140 inline char *
142 {
143 return binPkt_;
144 }
145
149 inline uint32_t &
151 {
152 return binPktLength_;
153 }
154
158 inline uint32_t &
160 {
161 return binHdrLength_;
162 }
163
165
166#endif // HDR_UWAL_H
#define MAX_BIN_PKT_ARRAY_LENGTH
Definition hdr-uwal.h:44
#define MAX_DUMMY_STRING_LENGTH
Definition hdr-uwal.h:45
packet_t PT_UWAL
Definition hdr-uwal.cpp:40
hdr_uwal describes the packet header used by Uwal objects.
Definition hdr-uwal.h:52
char * dummyStr()
Return the pointer to the dummyStr_ array.
Definition hdr-uwal.h:132
uint8_t & Mbit()
Reference to the Mbit_ variable.
Definition hdr-uwal.h:123
uint32_t & binHdrLength()
Reference to the binHdrLength_ variable.
Definition hdr-uwal.h:159
uint16_t & framePayloadOffset()
Reference to the frameOffset_ variable.
Definition hdr-uwal.h:114
char dummyStr_[MAX_DUMMY_STRING_LENGTH]
array containing a dummy string.
Definition hdr-uwal.h:75
unsigned int & pktID()
Reference to the pktID_ variable.
Definition hdr-uwal.h:105
char * binPkt()
Return to the binPkt_ array pointer.
Definition hdr-uwal.h:141
uint8_t srcID_
ID of the packet's source node.
Definition hdr-uwal.h:69
unsigned int pktID_
ID of the packet.
Definition hdr-uwal.h:70
uint16_t framePayloadOffset_
Offset of the frame payload.
Definition hdr-uwal.h:71
uint8_t & srcID()
Reference to the srcID_ variable.
Definition hdr-uwal.h:96
uint32_t binHdrLength_
number of chars in binPkt_ to consider as header.
Definition hdr-uwal.h:89
static int offset_
Definition hdr-uwal.h:55
uint32_t & binPktLength()
Reference to the binPktLength_ variable.
Definition hdr-uwal.h:150
uint32_t binPktLength_
number of chars in binPkt_ to consider.
Definition hdr-uwal.h:88
uint8_t Mbit_
M bit: if set to 0 the current frame is the last or the only one; if set to 1 the current frame is no...
Definition hdr-uwal.h:72
static struct hdr_uwal * access(const Packet *p)
Definition hdr-uwal.h:62
char binPkt_[MAX_BIN_PKT_ARRAY_LENGTH]
array to store binary data as encoded from or to be decoded to this NS-Miracle packet header (NOTE: t...
Definition hdr-uwal.h:80
static int & offset()
Definition hdr-uwal.h:57