libglass::Packet Class Reference
#include <packet.h>
List of all members.
Detailed Description
Definition at line 34 of file packet.h.
Constructor & Destructor Documentation
libglass::Packet::Packet |
( |
|
) |
|
virtual libglass::Packet::~Packet |
( |
|
) |
[virtual] |
Member Function Documentation
void libglass::Packet::addTargetNodes |
( |
std::set< nodeId > & |
id_set |
) |
|
Sets the target node id field.
- Parameters:
-
| id_set | The target node ids set. |
- See also:
- getTargetNodes().
void libglass::Packet::addTargetNodes |
( |
nodeId |
id |
) |
|
void libglass::Packet::appendData |
( |
chain & |
s |
) |
|
void libglass::Packet::appendData |
( |
string & |
s |
) |
|
void libglass::Packet::appendData |
( |
const char * |
data, |
|
|
unsigned int |
length | |
|
) |
| | |
Appends to the data field.
- Parameters:
-
| data | The data. May contain '\0's. |
| length | The length of data. |
- See also:
- setData().
void libglass::Packet::appendData |
( |
unsigned char * |
data, |
|
|
unsigned int |
length | |
|
) |
| | |
Appends to the data field.
- Parameters:
-
| data | The data. May contain ''s. |
| length | The length of data. |
- See also:
- setData().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
void libglass::Packet::clearTargetNodes |
( |
void |
|
) |
|
bool libglass::Packet::decode |
( |
unsigned char * |
header, |
|
|
unsigned int |
headerlen, |
|
|
unsigned char * |
databuf, |
|
|
unsigned int |
datalen | |
|
) |
| | |
bool libglass::Packet::decode |
( |
unsigned char * |
buffer, |
|
|
unsigned int |
length | |
|
) |
| | |
bool libglass::Packet::decode |
( |
chain & |
s |
) |
|
Decodes a string to a packet.
The from field (which you can get with getSenderNode()) is set with the id of the sender.
The target field (getTargetNode()) is NOT set, and its value is meaningless. This behaviour may change in future versions.
The caller should always pass a valid packet, but checks are made to avoid buffer security attacks. If the packet does not pass these tests, false is returned. Obviously, no checks are made on the data field.
- Parameters:
-
- Return values:
-
| true | If correctly decoded. This doesn't mean that the values are meaningful. |
| false | Otherwise. |
- See also:
- encode().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
| buffer | The buffer to decode |
| length | The buffer length. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
| header | The packet header. User is responsible for freeing this buffer. |
| headerlen | The header length. |
| databuf | The data packet. This buffer is freed by libGlass. |
| datalen | The data packet length. |
virtual chain libglass::Packet::encode |
( |
unsigned int * |
len = NULL |
) |
[virtual] |
Encodes the packet to a string that can be sent over the network.
The from field (which you can get with getSenderNode()) is automatically set. You must set the target node, since the default is nobodyId.
- See also:
- decode().
- Parameters:
-
| len | A pointer to a variable. |
- Returns:
- The encoded data, and the total length in the len argument, if not NULL.
void libglass::Packet::getData |
( |
chain & |
s |
) |
|
unsigned int libglass::Packet::getDataLength |
( |
void |
|
) |
const |
PluginId libglass::Packet::getPluginId |
( |
void |
|
) |
const |
Gets the plugin id field.
- Returns:
- The plugin id.
- See also:
- setPluginId().
nodeId libglass::Packet::getSenderNode |
( |
void |
|
) |
const |
Gets the sender node id field.
- Returns:
- The target node id.
- See also:
- setSenderNodes().
std::set<nodeFD>& libglass::Packet::getTargetFDs |
( |
void |
|
) |
|
std::set<nodeId>& libglass::Packet::getTargetNodes |
( |
void |
|
) |
|
bool libglass::Packet::isReliable |
( |
void |
|
) |
const |
Sets if this packet must be sent reliably (i.e., guaranteeing delivery) or not.
See the protocol documentation to see if this field is supported. Not all protocols may support this flag.
- Returns:
- true if is a reliable packet, false otherwise.
virtual std::ostream& libglass::Packet::print |
( |
std::ostream & |
o |
) |
[virtual] |
A nice outputter, for debugging purposes.
void libglass::Packet::setData |
( |
chain & |
s |
) |
|
void libglass::Packet::setData |
( |
const char * |
data, |
|
|
unsigned int |
length | |
|
) |
| | |
Sets the data field.
- Parameters:
-
| data | The data. May contain '\0's. |
| length | The length of data. |
void libglass::Packet::setData |
( |
unsigned char * |
data, |
|
|
unsigned int |
length | |
|
) |
| | |
Sets the data field.
- Parameters:
-
| data | The data. May contain ''s. |
| length | The length of data. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
void libglass::Packet::setPluginId |
( |
PluginId |
id |
) |
|
void libglass::Packet::setReliable |
( |
bool |
reliable |
) |
|
Sets if this packet must be sent reliably (i.e., guaranteeing delivery) or not.
See the protocol documentation to see if this field is supported.
- Parameters:
-
| reliable | True if it must, false otherwise. |
void libglass::Packet::setSenderNode |
( |
nodeId |
id |
) |
|
void libglass::Packet::setTargetFDs |
( |
std::set< nodeFD > & |
fds |
) |
|
void libglass::Packet::setTargetFDs |
( |
nodeFD |
fd |
) |
|
void libglass::Packet::setTargetNodes |
( |
std::vector< nodeId > & |
id_set |
) |
|
Sets the target node id field.
- Parameters:
-
| id_set | The target node ids set. |
- See also:
- getTargetNodes().
void libglass::Packet::setTargetNodes |
( |
std::set< nodeId > & |
id_set |
) |
|
Sets the target node id field.
- Parameters:
-
| id_set | The target node ids set. |
- See also:
- getTargetNodes().
void libglass::Packet::setTargetNodes |
( |
nodeId |
id |
) |
|
Friends And Related Function Documentation
friend class Glass [friend] |
std::ostream& operator<< |
( |
std::ostream & |
o, |
|
|
Packet & |
p | |
|
) |
| | [friend] |
The documentation for this class was generated from the following file: