![]() |
Classes | |
class | protlib::NetMsgError |
class | protlib::NetMsg |
network message More... | |
Namespaces | |
namespace | protlib |
Functions | |
ostream & | protlib::operator<< (ostream &os, NetMsg &msg) |
std::ostream & | protlib::operator<< (std::ostream &out, const NetMsg &msg) |
protlib::NetMsgError::NetMsgError (error_t e) | |
const char * | protlib::NetMsgError::getstr () const |
protlib::NetMsg::NetMsg (uint32 s) | |
constructor | |
protlib::NetMsg::NetMsg (uchar *b, uint32 s, bool copy=true) | |
constructor | |
protlib::NetMsg::NetMsg (const NetMsg &n) | |
copy constructor | |
protlib::NetMsg::~NetMsg () | |
destructor | |
uint32 | protlib::NetMsg::get_size () const |
get buffer size | |
uint32 | protlib::NetMsg::get_bytes_left () const |
get bytes left until buffer ends | |
uint32 | protlib::NetMsg::get_pos () const |
get pointer offset | |
NetMsg & | protlib::NetMsg::set_pos (uint32 p) |
move pointer to offset | |
NetMsg & | protlib::NetMsg::set_pos_r (int32 rp) |
move pointer relative | |
NetMsg & | protlib::NetMsg::to_start () |
set pointer to beginning | |
uint32 | protlib::NetMsg::copy_from (const uchar *b, uint32 n) |
copy into NetMsg buffer | |
uint32 | protlib::NetMsg::copy_from (const uchar *b, uint32 start, uint32 end) |
copy into NetMsg buffer | |
uint32 | protlib::NetMsg::copy_to (uchar *b, uint32 n) const |
copy from NetMsg buffer | |
uint32 | protlib::NetMsg::copy_to (uchar *b, uint32 start, uint32 n) const |
copy from NetMsg buffer | |
uchar * | protlib::NetMsg::get_buffer () const |
get pointer to buffer | |
uint8 | protlib::NetMsg::decode8 (bool move=true) |
decode uint8 | |
uint16 | protlib::NetMsg::decode16 (bool move=true) |
decode uint16 | |
uint32 | protlib::NetMsg::decode32 (bool move=true) |
decode uint32 | |
uint64 | protlib::NetMsg::decode64 (bool move=true) |
decode uint64 | |
uint128 | protlib::NetMsg::decode128 (bool move=true) |
decode uint128 | |
void | protlib::NetMsg::encode8 (uint8 i, bool move=true) |
encode uint8 | |
void | protlib::NetMsg::encode16 (uint16 i, bool move=true) |
encode uint16 | |
void | protlib::NetMsg::encode32 (uint32 i, bool move=true) |
encode uint32 | |
void | protlib::NetMsg::encode64 (uint64 i, bool move=true) |
encode uint64 | |
void | protlib::NetMsg::encode128 (uint128 i, bool move=true) |
encode uint128 | |
void | protlib::NetMsg::decode (uchar *c, uint32 len, bool move=true) |
decode uchars | |
void | protlib::NetMsg::encode (const uchar *c, uint32 len, bool move=true) |
encode uchars | |
uint32 | protlib::NetMsg::decode (string &s, uint32 len, bool move=true) |
decode string | |
uint32 | protlib::NetMsg::encode (const string &s, bool move=true) |
encode string | |
void | protlib::NetMsg::decode (struct in_addr &in, bool move=true) |
decode IPv4 | |
void | protlib::NetMsg::encode (const struct in_addr &in, bool move=true) |
encode IPv4 | |
void | protlib::NetMsg::decode (struct in6_addr &in, bool move=true) |
decode IPv6 | |
void | protlib::NetMsg::encode (const struct in6_addr &in, bool move=true) |
encode IPv6 | |
uint32 | protlib::NetMsg::truncate () |
truncate buffer | |
uint32 | protlib::NetMsg::truncate (uint32 t) |
truncate buffer | |
void | protlib::NetMsg::padding (uint32 len, bool move=true) |
apply padding | |
bool | protlib::NetMsg::operator== (const NetMsg &n) const |
test for equality | |
void | protlib::NetMsg::decode (NetMsg &m, bool move=true) |
decode a NetMsg from this NetMsg | |
void | protlib::NetMsg::encode (const NetMsg &m, uint32 len, bool move=true) |
encode a NetMsg into this NetMsg | |
ostream & | protlib::NetMsg::hexdump (ostream &os, uchar *startpos=0, uint32 length=0) const |
print a raw hexdump of the buffer | |
Variables | |
static const char *const | protlib::NetMsgError::errstr [] |
static const uint32 | protlib::NetMsg::max_size = 128000 |
copy into NetMsg buffer
Copy bytes into NetMsg buffer.
b | source | |
start | offset of first byte to copy | |
n | number of bytes to copy |
Definition at line 207 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_len, and protlib::NetMsgError::ERROR_TOO_SHORT.
copy into NetMsg buffer
Copy n bytes into NetMsg buffer.
b | source | |
n | number of bytes to copy |
Definition at line 198 of file network_message.cpp.
copy from NetMsg buffer
Copy n bytes from NetMsg buffer into b. If the NetMsg buffer is smaller than n, less bytes are copied.
b | destination buffer | |
start | offset into NetMsg buffer | |
n | number of bytes to be copied |
Definition at line 237 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_len, and protlib::NetMsgError::ERROR_INVALID_START_OFFSET.
copy from NetMsg buffer
Copy n bytes from NetMsg buffer into b. If the NetMsg buffer is smaller than n, less bytes are copied.
b | destination buffer | |
n | number of bytes to be copied |
Definition at line 221 of file network_message.cpp.
void protlib::NetMsg::decode | ( | NetMsg & | m, | |
bool | move = true | |||
) | [inherited] |
decode a NetMsg from this NetMsg
Decode NetMsg.
m | NetMsg reference | |
move | determines if current position in buffer is changed or not. |
Definition at line 564 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, protlib::NetMsg::get_size(), protlib::NetMsg::pos, and protlib::NetMsg::to_start().
void protlib::NetMsg::decode | ( | struct in6_addr & | in, | |
bool | move = true | |||
) | [inherited] |
decode IPv6
Decode an IPv6 address.
in | reference to in6_addr | |
move | determines if current position in buffer is changed or not. |
Definition at line 476 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
void protlib::NetMsg::decode | ( | struct in_addr & | in, | |
bool | move = true | |||
) | [inherited] |
decode IPv4
Decode an IPv4 address.
in | reference to in_addr | |
move | determines if current position in buffer is changed or not. |
Definition at line 450 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
uint32 protlib::NetMsg::decode | ( | string & | s, | |
uint32 | len, | |||
bool | move = true | |||
) | [inherited] |
decode string
Decode string.
s | string reference | |
len | number of bytes to decode | |
move | determines if current position in buffer is changed or not. |
Definition at line 421 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
decode uchars
Decode uchars.
c | pointer to uchar array | |
len | uchar array size | |
move | determines if current position in buffer is changed or not. |
Definition at line 396 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
uint128 protlib::NetMsg::decode128 | ( | bool | move = true |
) | [inherited] |
decode uint128
Decode an uint128 integer.
move | determines if current position in buffer is changed or not. |
Definition at line 315 of file network_message.cpp.
References protlib::NetMsg::decode32(), protlib::uint128::w1, protlib::uint128::w2, protlib::uint128::w3, and protlib::uint128::w4.
uint16 protlib::NetMsg::decode16 | ( | bool | move = true |
) | [inherited] |
decode uint16
Decode an uint16 integer.
move | determines if current position in buffer is changed or not. |
Definition at line 270 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
Referenced by ariba::transport::tcpip::receiverThread().
uint32 protlib::NetMsg::decode32 | ( | bool | move = true |
) | [inherited] |
decode uint32
Decode an uint32 integer.
move | determines if current position in buffer is changed or not. |
Definition at line 284 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
Referenced by protlib::NetMsg::decode128(), ariba::transport::get_message_length(), and ariba::transport::tcpip::receiverThread().
uint64 protlib::NetMsg::decode64 | ( | bool | move = true |
) | [inherited] |
decode uint64
Decode an uint64 integer.
move | determines if current position in buffer is changed or not. |
Definition at line 298 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
uint8 protlib::NetMsg::decode8 | ( | bool | move = true |
) | [inherited] |
decode uint8
Decode an uint8 integer.
move | determines if current position in buffer is changed or not. |
Definition at line 254 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
encode a NetMsg into this NetMsg
Encode NetMsg.
m | NetMsg reference | |
len | length of data to encode | |
move | determines if current position in buffer is changed or not. |
Definition at line 579 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
void protlib::NetMsg::encode | ( | const struct in6_addr & | in, | |
bool | move = true | |||
) | [inherited] |
encode IPv6
Encode an IPv6 address.
in | reference to const in6_addr | |
move | determines if current position in buffer is changed or not. |
Definition at line 487 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
void protlib::NetMsg::encode | ( | const struct in_addr & | in, | |
bool | move = true | |||
) | [inherited] |
encode IPv4
Encode an IPv4 address.
in | reference to const in_addr | |
move | determines if current position in buffer is changed or not. |
Definition at line 464 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
uint32 protlib::NetMsg::encode | ( | const string & | s, | |
bool | move = true | |||
) | [inherited] |
encode string
Encode string.
s | string reference | |
move | determines if current position in buffer is changed or not. |
Definition at line 437 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
encode uchars
Encode uchars.
c | pointer to uchar array | |
len | uchar array size | |
move | determines if current position in buffer is changed or not. |
Definition at line 408 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
void protlib::NetMsg::encode128 | ( | uint128 | i, | |
bool | move = true | |||
) | [inherited] |
encode uint128
Encode an uint128 integer.
i | an uint128 | |
move | determines if current position in buffer is changed or not. |
Definition at line 384 of file network_message.cpp.
References protlib::NetMsg::encode32(), protlib::uint128::w1, protlib::uint128::w2, protlib::uint128::w3, and protlib::uint128::w4.
void protlib::NetMsg::encode16 | ( | uint16 | i, | |
bool | move = true | |||
) | [inherited] |
encode uint16
Encode an uint16 integer.
i | an uint16 | |
move | determines if current position in buffer is changed or not. |
Definition at line 345 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
Referenced by ariba::transport::tcpip::send().
void protlib::NetMsg::encode32 | ( | uint32 | i, | |
bool | move = true | |||
) | [inherited] |
encode uint32
Encode an uint32 integer.
i | an uint32 | |
move | determines if current position in buffer is changed or not. |
Definition at line 356 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
Referenced by protlib::NetMsg::encode128(), and ariba::transport::tcpip::send().
void protlib::NetMsg::encode64 | ( | uint64 | i, | |
bool | move = true | |||
) | [inherited] |
encode uint64
Encode an uint64 integer.
i | an uint64 | |
move | determines if current position in buffer is changed or not. |
Definition at line 367 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
void protlib::NetMsg::encode8 | ( | uint8 | i, | |
bool | move = true | |||
) | [inherited] |
encode uint8
Encode an uint8 integer.
i | an uint8 | |
move | determines if current position in buffer is changed or not. |
Definition at line 334 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
Referenced by ariba::transport::tcpip::send().
uchar * protlib::NetMsg::get_buffer | ( | ) | const [inherited] |
get pointer to buffer
returns a pointer to the NetMsg buffer.
Definition at line 245 of file network_message.cpp.
References protlib::NetMsg::buf.
Referenced by protlib::TPoverUDP::listener_thread(), protlib::TPoverTCP::receiver_thread(), ariba::transport::tcpip::receiverThread(), protlib::TPoverTCP::tcpsend(), and protlib::TPoverUDP::udpsend().
uint32 protlib::NetMsg::get_bytes_left | ( | ) | const [inherited] |
get bytes left until buffer ends
Returns the number of bytes left, that is the number of bytes from the current position to the end of the buffer.
should never happen
Definition at line 136 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
uint32 protlib::NetMsg::get_pos | ( | ) | const [inherited] |
get pointer offset
Returns the offset of the buffer pointer. Note that an offset of buf_len means that the pointer is one byte behind the end of the buffer. This means that you reached the buffer end. This leads to a get-pos result of buf_len.
Definition at line 153 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
Referenced by protlib::TPoverTCP::tcpsend().
uint32 protlib::NetMsg::get_size | ( | ) | const [inherited] |
get buffer size
Definition at line 129 of file network_message.cpp.
References protlib::NetMsg::buf_len.
Referenced by protlib::TP::check_send_args(), protlib::NetMsg::decode(), protlib::TPoverTCP::receiver_thread(), protlib::TPoverTCP::tcpsend(), and protlib::TPoverUDP::udpsend().
const char * protlib::NetMsgError::getstr | ( | ) | const [virtual, inherited] |
Deprecated: Use what() instead.
Reimplemented from protlib::ProtLibException.
Definition at line 57 of file network_message.cpp.
References protlib::NetMsgError::err, and protlib::NetMsgError::errstr.
Referenced by protlib::NetMsgError::what().
ostream & protlib::NetMsg::hexdump | ( | ostream & | os, | |
uchar * | startpos = 0 , |
|||
uint32 | length = 0 | |||
) | const [inherited] |
print a raw hexdump of the buffer
hex of dump buffer contents if startpos is 0, the beginning of the buffer is used
Definition at line 591 of file network_message.cpp.
References protlib::log::blue, protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsg::buf_len, protlib::log::clear, and protlib::log::color.
Referenced by protlib::operator<<(), protlib::TPoverTCP::receiver_thread(), protlib::TPoverTCP::tcpsend(), and protlib::TPoverUDP::udpsend().
protlib::NetMsg::NetMsg | ( | const NetMsg & | n | ) | [inherited] |
copy constructor
Definition at line 111 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsg::buf_len, protlib::NetMsgError::ERROR_INVALID_BUFSIZE, protlib::NetMsgError::ERROR_NO_MEM, and protlib::NetMsg::pos.
constructor
Creates a network message object of the desired size if possible.
b | pointer to a buffer to initialize the NetMsg. | |
s | buffer size | |
copy | copy the buffer or use the buffer without copying. |
Definition at line 95 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsg::buf_len, protlib::NetMsgError::ERROR_INVALID_BUFSIZE, protlib::NetMsgError::ERROR_NO_MEM, protlib::NetMsgError::ERROR_NULL_POINTER, protlib::NetMsgError::ERROR_TOO_LONG, protlib::NetMsg::max_size, and protlib::NetMsg::pos.
protlib::NetMsg::NetMsg | ( | uint32 | s | ) | [inherited] |
constructor
Creates a network message object of the desired size if possible.
s | buffer size. |
Definition at line 79 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsg::buf_len, protlib::NetMsgError::ERROR_INVALID_BUFSIZE, protlib::NetMsgError::ERROR_NO_MEM, protlib::NetMsgError::ERROR_TOO_LONG, protlib::NetMsg::max_size, and protlib::NetMsg::pos.
protlib::NetMsgError::NetMsgError | ( | error_t | e | ) | [inherited] |
std::ostream& protlib::operator<< | ( | std::ostream & | out, | |
const NetMsg & | msg | |||
) | [inline] |
ostream& protlib::operator<< | ( | ostream & | os, | |
NetMsg & | msg | |||
) |
bool protlib::NetMsg::operator== | ( | const NetMsg & | n | ) | const [inherited] |
test for equality
Two network messages are equal if their buffers and states are equal.
Definition at line 533 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_len, and protlib::NetMsg::pos.
void protlib::NetMsg::padding | ( | uint32 | len, | |
bool | move = true | |||
) | [inherited] |
apply padding
Set padding bytes to 0.
len | padding length | |
move | determines if current position in buffer is changed or not. |
Definition at line 524 of file network_message.cpp.
References protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
NetMsg & protlib::NetMsg::set_pos | ( | uint32 | p | ) | [inherited] |
move pointer to offset
Move pointer to the given offset.
p | pointer offset |
Definition at line 165 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_len, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
Referenced by ariba::transport::tcpip::receiverThread(), and protlib::NetMsg::truncate().
NetMsg & protlib::NetMsg::set_pos_r | ( | int32 | rp | ) | [inherited] |
move pointer relative
Move pointer relative to current position.
rp | offset relative to current position. |
Definition at line 178 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsgError::ERROR_INVALID_POS, and protlib::NetMsg::pos.
Referenced by ariba::transport::get_message_length().
NetMsg & protlib::NetMsg::to_start | ( | ) | [inherited] |
set pointer to beginning
Set current position to buffer start.
Definition at line 189 of file network_message.cpp.
References protlib::NetMsg::buf, and protlib::NetMsg::pos.
Referenced by protlib::NetMsg::decode(), and protlib::NetMsg::truncate().
uint32 protlib::NetMsg::truncate | ( | uint32 | t | ) | [inherited] |
truncate buffer
Truncates the buffer at given offset.
Definition at line 515 of file network_message.cpp.
References protlib::NetMsg::set_pos(), and protlib::NetMsg::truncate().
uint32 protlib::NetMsg::truncate | ( | ) | [inherited] |
truncate buffer
Truncates the buffer at the current position and sets the current position to buffer start.
Definition at line 503 of file network_message.cpp.
References protlib::NetMsg::buf, protlib::NetMsg::buf_end, protlib::NetMsg::buf_len, protlib::NetMsgError::ERROR_INVALID_POS, protlib::NetMsg::pos, and protlib::NetMsg::to_start().
Referenced by protlib::TPoverUDP::listener_thread(), protlib::TPoverTCP::receiver_thread(), and protlib::NetMsg::truncate().
protlib::NetMsg::~NetMsg | ( | ) | [inherited] |
destructor
Frees the message buffer.
Definition at line 124 of file network_message.cpp.
References protlib::NetMsg::buf.
const char *const protlib::NetMsgError::errstr [static, private, inherited] |
Initial value:
{ "Network message too long.", "Not enough memory to allocate network message.", "Operation not valid because of pointer position in NetMsg buffer.", "NULL pointer argument in call to NetMsg constructor.", "Invalid start offset.", "NetMsg buffer too short.", "Invalid buffer size: zero" }
Definition at line 70 of file network_message.h.
Referenced by protlib::NetMsgError::getstr().
const uint32 protlib::NetMsg::max_size = 128000 [static, inherited] |
Maximum size of a network message. This is set to 128000 to prevent very large messages.
Definition at line 79 of file network_message.h.
Referenced by protlib::TPoverUDP::listener_thread(), protlib::NetMsg::NetMsg(), and protlib::TPoverTCP::receiver_thread().