Tor 0.4.9.2-alpha-dev
|
Encoding relay messages into cells. More...
#include "app/config/config.h"
#include "core/or/cell_st.h"
#include "core/or/circuitlist.h"
#include "core/or/relay.h"
#include "core/or/relay_msg.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "core/or/relay_msg_st.h"
#include "core/or/crypt_path_st.h"
#include "core/or/or_circuit_st.h"
Go to the source code of this file.
Macros | |
#define | RELAY_MSG_PRIVATE |
#define | V0_CMD_OFFSET 0 |
#define | V0_STREAM_ID_OFFSET 3 |
#define | V0_LEN_OFFSET 9 |
#define | V0_PAYLOAD_OFFSET 11 |
#define | V1_CMD_OFFSET 16 |
#define | V1_LEN_OFFSET 17 |
#define | V1_STREAM_ID_OFFSET 19 |
#define | V1_PAYLOAD_OFFSET_NO_STREAM_ID 19 |
#define | V1_PAYLOAD_OFFSET_WITH_STREAM_ID 21 |
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) |
static void | relay_cell_pad (cell_t *cell, size_t end_of_message) |
static int | encode_v0_cell (const relay_msg_t *msg, cell_t *cell_out) |
static int | encode_v1_cell (const relay_msg_t *msg, cell_t *cell_out) |
static int | decode_v0_cell (const cell_t *cell, relay_msg_t *out) |
static int | decode_v1_cell (const cell_t *cell, relay_msg_t *out) |
int | relay_msg_encode_cell (relay_cell_fmt_t format, const relay_msg_t *msg, cell_t *cell_out) |
int | relay_msg_decode_cell_in_place (relay_cell_fmt_t format, const cell_t *cell, relay_msg_t *msg_out) |
relay_msg_t * | relay_msg_decode_cell (relay_cell_fmt_t format, const cell_t *cell) |
Encoding relay messages into cells.
Definition in file relay_msg.c.
#define RELAY_MSG_PRIVATE |
Definition at line 9 of file relay_msg.c.
#define V0_CMD_OFFSET 0 |
Definition at line 48 of file relay_msg.c.
#define V0_LEN_OFFSET 9 |
Definition at line 50 of file relay_msg.c.
#define V0_PAYLOAD_OFFSET 11 |
Definition at line 51 of file relay_msg.c.
#define V0_STREAM_ID_OFFSET 3 |
Definition at line 49 of file relay_msg.c.
#define V1_CMD_OFFSET 16 |
Definition at line 54 of file relay_msg.c.
#define V1_LEN_OFFSET 17 |
Definition at line 55 of file relay_msg.c.
#define V1_PAYLOAD_OFFSET_NO_STREAM_ID 19 |
Definition at line 57 of file relay_msg.c.
#define V1_PAYLOAD_OFFSET_WITH_STREAM_ID 21 |
Definition at line 58 of file relay_msg.c.
#define V1_STREAM_ID_OFFSET 19 |
Definition at line 56 of file relay_msg.c.
|
static |
Try to decode 'cell' into a V0 relay message.
Return 0 on success, -1 on error.
Definition at line 166 of file relay_msg.c.
Referenced by relay_msg_decode_cell_in_place().
|
static |
Try to decode 'cell' into a V1 relay message.
Return 0 on success, -1 on error.=
Definition at line 189 of file relay_msg.c.
Referenced by relay_msg_decode_cell_in_place().
|
static |
Encode the relay message in 'msg' into cell, according to the v0 rules.
Definition at line 105 of file relay_msg.c.
|
static |
Encode the relay message in 'msg' into cell, according to the v0 rules.
Definition at line 128 of file relay_msg.c.
|
static |
Definition at line 87 of file relay_msg.c.
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.