Tor 0.4.9.2-alpha-dev
|
Header file for relay_msg.c. More...
Go to the source code of this file.
Macros | |
#define | relay_msg_free(msg) FREE_AND_NULL(relay_msg_t, relay_msg_free_, (msg)) |
Functions | |
void | relay_msg_free_ (relay_msg_t *msg) |
void | relay_msg_clear (relay_msg_t *msg) |
relay_msg_t * | relay_msg_copy (const relay_msg_t *msg) |
int | relay_msg_encode_cell (relay_cell_fmt_t format, const relay_msg_t *msg, cell_t *cell_out) ATTR_WUR |
int | relay_msg_decode_cell_in_place (relay_cell_fmt_t format, const cell_t *cell, relay_msg_t *msg_out) ATTR_WUR |
relay_msg_t * | relay_msg_decode_cell (relay_cell_fmt_t format, const cell_t *cell) ATTR_WUR |
static bool | relay_cmd_expects_streamid_in_v1 (uint8_t relay_command) |
static size_t | relay_cell_max_payload_size (relay_cell_fmt_t format, uint8_t relay_command) |
Header file for relay_msg.c.
Definition in file relay_msg.h.
#define relay_msg_free | ( | msg | ) | FREE_AND_NULL(relay_msg_t, relay_msg_free_, (msg)) |
Definition at line 31 of file relay_msg.h.
|
inlinestatic |
Return the size of the relay cell payload for the given relay cell format.
Definition at line 65 of file relay_msg.h.
Referenced by circuit_max_relay_payload(), connection_edge_get_inbuf_bytes_to_package(), encode_v0_cell(), and encode_v1_cell().
|
static |
Return true iff 'cmd' uses a stream ID when using the v1 relay message format.
Definition at line 44 of file relay_msg.h.
Referenced by encode_v1_cell(), and relay_cell_max_payload_size().
void relay_msg_clear | ( | relay_msg_t * | msg | ) |
Clear a relay message as in free its content and reset all fields to 0. This is useful for stack allocated memory.
Definition at line 41 of file relay_msg.c.
relay_msg_t * relay_msg_copy | ( | const relay_msg_t * | msg | ) |
Allocate a new relay message and copy the content of the given message.
This message allocation will own its body, even if the original did not.
Requires that msg is well-formed, and that its length is within allowable bounds.
Definition at line 68 of file relay_msg.c.
relay_msg_t * relay_msg_decode_cell | ( | relay_cell_fmt_t | format, |
const cell_t * | cell | ||
) |
As relay_msg_decode_cell_in_place, but allocate a new relay_msg_t on success.
Return NULL on error.
Definition at line 276 of file relay_msg.c.
int relay_msg_decode_cell_in_place | ( | relay_cell_fmt_t | format, |
const cell_t * | cell, | ||
relay_msg_t * | msg_out | ||
) |
Decode 'cell' (which must be RELAY or RELAY_EARLY) into a newly allocated 'relay_msg_t'.
Note that the resulting relay_msg_t will have a reference to 'cell'. Do not change 'cell' while the resulting message is still in use!
Return -1 on error, and 0 on success.
Definition at line 254 of file relay_msg.c.
int relay_msg_encode_cell | ( | relay_cell_fmt_t | format, |
const relay_msg_t * | msg, | ||
cell_t * | cell_out | ||
) |
Encode 'msg' into 'cell' according to the rules of 'format'.
Does not set any "recognized", "digest" or "tag" fields, since those are necessarily part of the crypto logic.
Clears the circuit ID on the cell.
Return 0 on success, and -1 if 'msg' is not well-formed.
Definition at line 225 of file relay_msg.c.
void relay_msg_free_ | ( | relay_msg_t * | msg | ) |
Free the given relay message.
Definition at line 30 of file relay_msg.c.