#include <NpPacket.h>
Inheritance diagram for NpPacket::
Public Methods | |
NpPacket () | |
Create a default packet. More... | |
NpPacket (NpType type, unsigned int vcn) | |
Used to create control packets. More... | |
NpPacket (TpPacket *packet, unsigned int vcn) | |
data packets. More... | |
NpPacket (unsigned char *rawData) | |
Parse the raw packet. More... | |
virtual | ~NpPacket () |
int | getVersionNumber () |
unsigned int | getVcn () |
unsigned char * | getData () |
unsigned int | getDataLength () const |
virtual unsigned char * | getRawData () |
Used by the Node.writePacket function right before sending over network. More... | |
unsigned int | getRawLength () const |
Return the length of the entire packet, including headers. More... | |
NpType | getPacketType () const |
Return the type of packet. More... | |
bool | isControlPacket () const |
Return true if this packet is anything but a data packet. More... | |
virtual unsigned int | getHeaderLength () |
Return the length of the header, in bytes. More... | |
void | setVersionNumber (int) |
void | setVcn (unsigned int vcn) |
void | setPacketType (NpType type) |
int | write (ConnectionInterface *) |
Write the specified packet to the Connection. More... | |
virtual void | toStream (std::ostream &) |
Gets the length of the whole packet and makes sure the length makes sense. More... | |
void | dumpHeader (std::ostream &out) |
Dumps hex output of the packet header. More... | |
void | dumpData (std::ostream &out) |
Dumps hex output of the data portion of the packet. More... | |
char * | getControlTypeString () const |
Return a string that describes the packet type. More... | |
Static Public Methods | |
NpPacket * | createPacket (NpType) |
Use this function to create any type of packet you want. More... | |
NpPacket * | decode (unsigned char *rawData, NpType packetType) |
Creates the correct type of packet from the rawData. More... | |
unsigned int | getHeaderLength (NpType packetType) |
int | parseMiniHeader (unsigned char *rawData, unsigned int *rawLength, int *versionNumber, NpType *packetType) |
This function decodes and checks the packet type and length. More... | |
NpPacket * | read (ConnectionInterface *) |
Read a packet from the Connection. More... | |
Protected Attributes | |
NpType | m_controlType |
packet type. More... | |
unsigned short | m_length |
the payload length; header length is fixed. More... | |
unsigned int | m_vcn |
Source VCN of requester. More... | |
unsigned char * | m_data |
The data portion of the packet. More... | |
unsigned char * | m_rawData |
the entire packet, including the header. More... | |
unsigned int | m_headerLength |
length of the packet header (not variable). More... | |
int | m_versionNumber |
Version number. More... |
Definition at line 12 of file NpPacket.h.
|
Create a default packet.
Definition at line 17 of file NpPacket.cpp. Referenced by createPacket(), and decode().
|
|
Used to create control packets.
Definition at line 34 of file NpPacket.cpp. |
|
data packets.
Definition at line 49 of file NpPacket.cpp. |
|
Parse the raw packet.
Definition at line 65 of file NpPacket.cpp. |
|
Definition at line 198 of file NpPacket.cpp. |
|
Use this function to create any type of packet you want. This uses the Factory Method design pattern. This is a static function. Definition at line 93 of file NpPacket.cpp. |
|
Creates the correct type of packet from the rawData. This method is somewhat similiar to a Factory Method. This is a static function.
Definition at line 129 of file NpPacket.cpp. Referenced by read().
|
|
Dumps hex output of the data portion of the packet.
Definition at line 394 of file NpPacket.cpp. Referenced by NetworkLayer::handleControlPacket().
|
|
Dumps hex output of the packet header.
Definition at line 377 of file NpPacket.cpp. |
|
Return a string that describes the packet type.
Definition at line 411 of file NpPacket.cpp. Referenced by decode(), NetworkLayer::forwardPacket(), LinkLayerInterface::pollAllSocketsImpl(), read(), LinkLayerInterface::sendPacket(), and toStream().
|
|
Definition at line 229 of file NpPacket.cpp. Referenced by ServiceTable::handleDataPacket().
|
|
Definition at line 236 of file NpPacket.cpp. Referenced by ServiceTable::handleDataPacket().
|
|
Definition at line 322 of file NpPacket.cpp. |
|
Return the length of the header, in bytes.
Definition at line 312 of file NpPacket.cpp. Referenced by parseMiniHeader().
|
|
Return the type of packet.
Definition at line 292 of file NpPacket.cpp. Referenced by NetworkLayer::handleControlPacket().
|
|
Used by the Node.writePacket function right before sending over network. Make sure m_length and m_headerLength are set correctly before calling this because this is how it knows how much memory to allocate. This function creates the raw data on the fly. Reimplemented in ConnectionPacket, DiscoveryPacket, FinPacket, and ImHerePacket. Definition at line 248 of file NpPacket.cpp. Referenced by dumpHeader(), ImHerePacket::getRawData(), FinPacket::getRawData(), DiscoveryPacket::getRawData(), ConnectionPacket::getRawData(), and write().
|
|
Return the length of the entire packet, including headers.
Definition at line 282 of file NpPacket.cpp. Referenced by NetworkLayer::connectForward(), NetworkLayer::handleDiscoveryPacket(), NetworkLayer::handleEstablishedPacket(), NetworkLayer::handleImHerePacket(), NetworkLayer::handlePingPacket(), and write().
|
|
|
Reimplemented in ImHerePacket. |
|
Return true if this packet is anything but a data packet.
Definition at line 302 of file NpPacket.cpp. Referenced by NpPacket(), and NetworkLayer::processPacketsImpl().
|
|
This function decodes and checks the packet type and length. From this information you can get the total length of the packet.
Definition at line 164 of file NpPacket.cpp. Referenced by read().
|
|
Read a packet from the Connection.
Definition at line 451 of file NpPacket.cpp. Referenced by LinkLayerInterface::pollAllSocketsImpl().
|
|
Definition at line 223 of file NpPacket.cpp. Referenced by NetworkLayer::handlePingPacket(), and NetworkLayer::ping().
|
|
Definition at line 217 of file NpPacket.cpp. Referenced by NetworkLayer::connectForward(), NetworkLayer::destroyVc(), NetworkLayer::destroyVcsTo(), NetworkLayer::forwardPacket(), NetworkLayer::handleEstablishedPacket(), and NetworkLayer::makeVc().
|
|
|
|
Gets the length of the whole packet and makes sure the length makes sense.
Reimplemented from BasicObject. Reimplemented in ConnectionPacket, DiscoveryPacket, FinPacket, and ImHerePacket. Definition at line 365 of file NpPacket.cpp. Referenced by ImHerePacket::toStream(), FinPacket::toStream(), DiscoveryPacket::toStream(), and ConnectionPacket::toStream().
|
|
Write the specified packet to the Connection.
Definition at line 511 of file NpPacket.cpp. Referenced by LinkLayerInterface::broadcast(), and LinkLayerInterface::sendPacket().
|
|
packet type.
Definition at line 136 of file NpPacket.h. |
|
The data portion of the packet.
Definition at line 145 of file NpPacket.h. |
|
length of the packet header (not variable).
Definition at line 151 of file NpPacket.h. |
|
the payload length; header length is fixed.
Definition at line 139 of file NpPacket.h. |
|
the entire packet, including the header.
Definition at line 148 of file NpPacket.h. |
|
Source VCN of requester.
Definition at line 142 of file NpPacket.h. |
|
Version number.
Reimplemented in ImHerePacket. Definition at line 154 of file NpPacket.h. |