|
DESERT 4.0.0
|
#include <packer.h>


Public Member Functions | |
| packer (bool) | |
| ~packer () | |
| int | command (int, const char *const *) |
| size_t | getPayloadBytesLength () |
| size_t | getHdrBytesLength () |
| size_t | getPayloadBinLength () |
| size_t | getHdrBinLength () |
| std::string | packPayload (Packet *) |
| std::string | packHdr (Packet *) |
| Packet * | unpackPayload (Packet *) |
| Packet * | unpackHdr (Packet *) |
| void | printMap () |
Static Public Member Functions | |
| template<typename T > | |
| static T | restoreSignedValue (T _header_field, const uint32_t &_num_compressed_bits) |
| static std::string | hexdump_nice (std::string) |
| static std::string | hexdump_nice (const char *, size_t) |
| static std::string | hexdump (std::string) |
| static std::string | hex_bytes (float) |
| static std::string | hex_bytes (double) |
| static std::string | hex_bytes (const char &, const uint32_t &) |
| static std::string | hex_bytes (const int8_t &, const uint32_t &) |
| static std::string | hex_bytes (const int16_t &, const uint32_t &) |
| static std::string | hex_bytes (const int32_t &, const uint32_t &) |
| static std::string | hex_bytes (const int64_t &, const uint32_t &) |
| static std::string | hex_bytes (const uint8_t &, const uint32_t &) |
| static std::string | hex_bytes (const uint16_t &, const uint32_t &) |
| static std::string | hex_bytes (const uint32_t &, const uint32_t &) |
| static std::string | hex_bytes (const uint64_t &, const uint32_t &) |
| static std::string | hexdump (const char *, size_t) |
| static std::string | bindump (std::string) |
| static std::string | bindump (const char *, size_t) |
Protected Member Functions | |
| virtual void | init () |
| virtual size_t | packMyHdr (Packet *, unsigned char *, size_t) |
| virtual size_t | unpackMyHdr (unsigned char *, size_t, Packet *) |
| virtual void | printMyHdrMap () |
| virtual void | printMyHdrFields (Packet *) |
| virtual void | printMyHdrField (Packet *, int) |
| size_t | getMyHdrBinLength () |
| size_t | get (unsigned char *buffer, size_t offset, void *val, size_t h) |
| size_t | put (unsigned char *buffer, size_t offset, void *val, size_t h) |
Protected Attributes | |
| std::vector< size_t > | n_bits |
| int | debug_ |
Private Attributes | |
| std::vector< packer * > | activePackers |
| size_t | payload_length |
| size_t | hdr_length |
| bool | printAllFields |
| size_t | SRC_ID_Bits |
| size_t | PKT_ID_Bits |
| size_t | FRAME_OFFSET_Bits |
| size_t | M_BIT_Bits |
| size_t | DUMMY_CONTENT_Bits |
Class exploited by the Uwal module to map an NS-Miracle packet into a bit stream, and vice-versa.
| packer::packer | ( | bool | init_ | ) |
Class constructor.
References debug_, DUMMY_CONTENT_Bits, FRAME_OFFSET_Bits, getMyHdrBinLength(), hdr_length, M_BIT_Bits, n_bits, PKT_ID_Bits, printAllFields, and SRC_ID_Bits.

| packer::~packer | ( | ) |
Class destructor.
|
static |
|
static |
References bindump().
Referenced by bindump(), and RxFrameSet::displaySet().

| int packer::command | ( | int | argc, |
| const char *const * | argv | ||
| ) |
Method to map tcl commands into c++ methods.
| argc | number of arguments in argv |
| argv | array of arguments where argv[3] is the tcl command name and argv[4, 5, ...] are the parameters for the corresponding c++ method. |
References activePackers, debug_, getMyHdrBinLength(), getPayloadBinLength(), hdr_length, init(), payload_length, printAllFields, and printMap().

|
protected |
Method used to retrieve a given variable from a certain number of bits contained in a buffer of chars.
| [in] | buffer | pointer to a buffer of characters. |
| [in] | offset | position from which to start reading the buffer of characters. |
| [in,out] | val | pointer to variable to retrieve (passed as reference). |
| h | the number of bits to read. |
Referenced by packerUWCBR::unpackMyHdr(), packerUwCsmaCa::unpackMyHdr(), PackerUwFlooding::unpackMyHdr(), packerUWIP::unpackMyHdr(), packerUwpolling::unpackMyHdr(), packerUWUDP::unpackMyHdr(), packer_uwUFetch::unpackMyHdr(), unpackMyHdr(), packerCOMMON::unpackMyHdr(), packerMAC::unpackMyHdr(), packer_uwApplication::unpackMyHdr(), and packer_uwRangingTDOA::unpackMyHdr().
| size_t packer::getHdrBinLength | ( | ) |
|
inline |
References hdr_length.
Referenced by Uwal::fragmentPkt().
|
protected |
References n_bits.
Referenced by command(), getHdrBinLength(), and packer().
| size_t packer::getPayloadBinLength | ( | ) |
References activePackers.
Referenced by command().
|
inline |
References payload_length.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
References hexdump().
Referenced by Uwal::fragmentPkt(), hexdump(), packHdr(), packPayload(), printMyHdrField(), unpackHdr(), and unpackPayload().

|
static |
|
static |
Function used for log and debug purposes (in order to print binary strings, even if they contain special characters)
| str | the binary string to print |
References hexdump_nice().
Referenced by RxFrameSet::displaySet(), and hexdump_nice().

|
protectedvirtual |
Reimplemented in packer_uwApplication, packerUWCBR, packerUwCsmaCa, PackerUwFlooding, packerUWIP, packerUwpolling, packerUWUDP, packer_uwUFetch, packerCOMMON, packerMAC, and packer_uwRangingTDOA.
References debug_, DUMMY_CONTENT_Bits, FRAME_OFFSET_Bits, M_BIT_Bits, n_bits, PKT_ID_Bits, and SRC_ID_Bits.
Referenced by command().
| std::string packer::packHdr | ( | Packet * | p | ) |
References hdr_uwal::binHdrLength(), hdr_uwal::binPkt(), hdr_uwal::binPktLength(), debug_, hdr_length, hexdump(), packMyHdr(), and payload_length.
Referenced by Uwal::fragmentPkt(), Uwal::recv(), and Uwal::recvSyncClMsg().

|
protectedvirtual |
Reimplemented in packerUWCBR, packerUwCsmaCa, PackerUwFlooding, packerUWIP, packerUwpolling, packerUWUDP, packer_uwUFetch, packerCOMMON, packerMAC, packer_uwApplication, and packer_uwRangingTDOA.
References debug_, hdr_uwal::dummyStr_, hdr_uwal::framePayloadOffset_, hdr_uwal::Mbit_, n_bits, hdr_uwal::pktID_, printMyHdrFields(), put(), and hdr_uwal::srcID_.
Referenced by packHdr().

| std::string packer::packPayload | ( | Packet * | p | ) |
Method to map an NS-Miracle packet into a legal modem payload (i.e., a string of binary characters) when one among the following protocol stack is in use (see UWMPhy_modem::stack):
NOTE: With the currently implemented map:
| p | pointer to the NS-Miracle packet that must be mapped into a modem payload. |
References activePackers, hdr_uwal::binPkt(), hdr_uwal::binPktLength(), debug_, hdr_length, hexdump(), and payload_length.
Referenced by Uwal::recv(), and Uwal::recvSyncClMsg().

| void packer::printMap | ( | ) |
References activePackers, hdr_length, payload_length, and printMyHdrMap().
Referenced by command().

|
protectedvirtual |
References hdr_uwal::dummyStr(), hdr_uwal::framePayloadOffset(), hex_bytes(), hexdump(), hdr_uwal::Mbit(), n_bits, hdr_uwal::pktID(), and hdr_uwal::srcID().
Referenced by printMyHdrFields().

|
protectedvirtual |
Reimplemented in packer_uwApplication, packerUWCBR, packerUwCsmaCa, PackerUwFlooding, packerUWIP, packerUwpolling, packerUWUDP, packer_uwUFetch, packerCOMMON, packerMAC, and packer_uwRangingTDOA.
References n_bits, printAllFields, and printMyHdrField().
Referenced by packMyHdr(), and unpackMyHdr().

|
protectedvirtual |
Reimplemented in packer_uwApplication, packerUWCBR, packerUwCsmaCa, PackerUwFlooding, packerUWIP, packerUwpolling, packerUWUDP, packer_uwUFetch, packerCOMMON, packerMAC, and packer_uwRangingTDOA.
References DUMMY_CONTENT_Bits, FRAME_OFFSET_Bits, M_BIT_Bits, PKT_ID_Bits, and SRC_ID_Bits.
Referenced by printMap().
|
protected |
Method used to map in a certain number of bits, contained in a buffer of chars, a given variable.
| [in] | buffer | pointer to a buffer of characters. |
| [in] | offset | position from which to start writing to the buffer of characters. |
| [in,out] | val | pointer to the variable to map (passed as reference). |
| h | the number of bits to use for the mapping. |
Referenced by packerUWCBR::packMyHdr(), packerUwCsmaCa::packMyHdr(), PackerUwFlooding::packMyHdr(), packerUWIP::packMyHdr(), packerUwpolling::packMyHdr(), packerUWUDP::packMyHdr(), packer_uwUFetch::packMyHdr(), packMyHdr(), packerCOMMON::packMyHdr(), packerMAC::packMyHdr(), packer_uwApplication::packMyHdr(), and packer_uwRangingTDOA::packMyHdr().
|
inlinestatic |
Referenced by packerCOMMON::unpackMyHdr(), and packerMAC::unpackMyHdr().
| Packet * packer::unpackHdr | ( | Packet * | p | ) |
References hdr_uwal::binHdrLength(), hdr_uwal::binPkt(), debug_, hdr_length, hexdump(), and unpackMyHdr().
Referenced by Uwal::recv().

|
protectedvirtual |
Reimplemented in packerUWCBR, packerUwCsmaCa, PackerUwFlooding, packerUWIP, packerUwpolling, packerUWUDP, packer_uwUFetch, packerCOMMON, packerMAC, packer_uwApplication, and packer_uwRangingTDOA.
References debug_, hdr_uwal::dummyStr_, hdr_uwal::framePayloadOffset_, get(), hdr_uwal::Mbit_, n_bits, hdr_uwal::pktID_, printMyHdrFields(), and hdr_uwal::srcID_.
Referenced by unpackHdr().

| Packet * packer::unpackPayload | ( | Packet * | p | ) |
Method to de-map a legal modem payload (i.e., a string of binary characters) into an NS-Miracle packet, when one among the following protocol stack is in use (see UWMPhy_modem::stack):
| s | the node ID from which the last received packet arrives. |
| d | the node ID to which the last received packet is sent. |
| src | the payload of the last packet received from the modem. |
References activePackers, hdr_uwal::binHdrLength(), hdr_uwal::binPkt(), hdr_uwal::binPktLength(), debug_, hexdump(), and payload_length.
Referenced by Uwal::checkRxFrameSet().

|
private |
Vector of elements containing the pointers to the active packers (i.e., the derived classed of packer actually in charge of pack and unpack packets. These are set by the tcl user through the command "addPacker". See packer::command).
Referenced by command(), getPayloadBinLength(), packPayload(), printMap(), and unpackPayload().
|
protected |
Flag to enable debug messages.
Referenced by command(), packer_uwApplication::init(), packerUWCBR::init(), PackerUwFlooding::init(), packerUWIP::init(), packerUWUDP::init(), packer_uwUFetch::init(), init(), packerCOMMON::init(), packerMAC::init(), packer_uwRangingTDOA::init(), packer(), packerCOMMON::packerCOMMON(), packerMAC::packerMAC(), packerUWCBR::packerUWCBR(), PackerUwFlooding::PackerUwFlooding(), packerUWIP::packerUWIP(), packerUWUDP::packerUWUDP(), packHdr(), packerUWCBR::packMyHdr(), packerUwCsmaCa::packMyHdr(), PackerUwFlooding::packMyHdr(), packerUWIP::packMyHdr(), packerUwpolling::packMyHdr(), packerUWUDP::packMyHdr(), packer_uwUFetch::packMyHdr(), packMyHdr(), packerCOMMON::packMyHdr(), packerMAC::packMyHdr(), packer_uwApplication::packMyHdr(), packer_uwRangingTDOA::packMyHdr(), packPayload(), unpackHdr(), packerUWCBR::unpackMyHdr(), packerUwCsmaCa::unpackMyHdr(), PackerUwFlooding::unpackMyHdr(), packerUWIP::unpackMyHdr(), packerUwpolling::unpackMyHdr(), packerUWUDP::unpackMyHdr(), packer_uwUFetch::unpackMyHdr(), unpackMyHdr(), packerCOMMON::unpackMyHdr(), packerMAC::unpackMyHdr(), packer_uwApplication::unpackMyHdr(), packer_uwRangingTDOA::unpackMyHdr(), and unpackPayload().
|
private |
Bit length of the Mbit_ field to be put in the header stream of bits.
Referenced by init(), packer(), and printMyHdrMap().
|
private |
Bit length of the pktID_ field to be put in the header stream of bits.
Referenced by init(), packer(), and printMyHdrMap().
|
private |
The minimum number of elements that a buffer of char must have in order to store the header fields of the AL.
Referenced by command(), getHdrBytesLength(), packer(), packHdr(), packPayload(), printMap(), and unpackHdr().
|
private |
Bit length of the frameID_ field to be put in the header stream of bits.
Referenced by init(), packer(), and printMyHdrMap().
|
protected |
Vector of elements containing the indication of the number of bits to consider for each header field.
Referenced by getMyHdrBinLength(), packer_uwApplication::init(), packerUWCBR::init(), packerUwCsmaCa::init(), PackerUwFlooding::init(), packerUWIP::init(), packerUwpolling::init(), packerUWUDP::init(), packer_uwUFetch::init(), init(), packerCOMMON::init(), packerMAC::init(), packer_uwRangingTDOA::init(), packer(), packerCOMMON::packerCOMMON(), packerMAC::packerMAC(), packerUWCBR::packerUWCBR(), PackerUwFlooding::PackerUwFlooding(), packerUWIP::packerUWIP(), packerUWUDP::packerUWUDP(), packerUWCBR::packMyHdr(), PackerUwFlooding::packMyHdr(), packerUWIP::packMyHdr(), packerUwpolling::packMyHdr(), packerUWUDP::packMyHdr(), packer_uwUFetch::packMyHdr(), packMyHdr(), packerCOMMON::packMyHdr(), packerMAC::packMyHdr(), packer_uwApplication::packMyHdr(), packer_uwRangingTDOA::packMyHdr(), printMyHdrField(), packerUWCBR::printMyHdrFields(), PackerUwFlooding::printMyHdrFields(), packerUWIP::printMyHdrFields(), packerUWUDP::printMyHdrFields(), printMyHdrFields(), packerCOMMON::printMyHdrFields(), packerMAC::printMyHdrFields(), packer_uwApplication::printMyHdrMap(), packer_uwUFetch::printMyHdrMap(), packer_uwRangingTDOA::printMyHdrMap(), packerUWCBR::unpackMyHdr(), PackerUwFlooding::unpackMyHdr(), packerUWIP::unpackMyHdr(), packerUwpolling::unpackMyHdr(), packerUWUDP::unpackMyHdr(), packer_uwUFetch::unpackMyHdr(), unpackMyHdr(), packerCOMMON::unpackMyHdr(), packerMAC::unpackMyHdr(), packer_uwApplication::unpackMyHdr(), and packer_uwRangingTDOA::unpackMyHdr().
|
private |
The minimum number of elements that a buffer of char must have in order to store the fields to be coded by the activePackers into a string of bytes.
Referenced by command(), getPayloadBytesLength(), packHdr(), packPayload(), printMap(), and unpackPayload().
|
private |
Bit length of the srcID_ field to be put in the header stream of bits.
Referenced by init(), packer(), and printMyHdrMap().
|
private |
Referenced by command(), packer(), and printMyHdrFields().
|
private |
Referenced by init(), packer(), and printMyHdrMap().