Tor 0.4.9.8
Loading...
Searching...
No Matches
relay_msg.h File Reference

Header file for relay_msg.c. More...

#include "core/or/or.h"
#include "core/or/relay_msg_st.h"

Go to the source code of this file.

Macros

#define relay_msg_free(msg)
 

Functions

void relay_msg_free_ (relay_msg_t *msg)
 
void relay_msg_clear (relay_msg_t *msg)
 
relay_msg_trelay_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_trelay_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)
 

Detailed Description

Header file for relay_msg.c.

Definition in file relay_msg.h.

Macro Definition Documentation

◆ relay_msg_free

#define relay_msg_free ( msg)
Value:
FREE_AND_NULL(relay_msg_t, relay_msg_free_, (msg))
void relay_msg_free_(relay_msg_t *msg)
Definition relay_msg.c:30

Definition at line 31 of file relay_msg.h.

Function Documentation

◆ relay_cell_max_payload_size()

static size_t relay_cell_max_payload_size ( relay_cell_fmt_t format,
uint8_t relay_command )
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(), encode_v1_cell(), and relay_send_command_from_edge_().

◆ relay_cmd_expects_streamid_in_v1()

static bool relay_cmd_expects_streamid_in_v1 ( uint8_t relay_command)
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 decode_v1_cell(), encode_v1_cell(), and relay_cell_max_payload_size().

◆ relay_msg_clear()

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_copy()

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.

Referenced by conflux_process_relay_msg().

◆ relay_msg_decode_cell()

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.

◆ relay_msg_decode_cell_in_place()

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.

Referenced by circuit_receive_relay_cell(), and relay_msg_decode_cell().

◆ relay_msg_encode_cell()

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.

Referenced by relay_send_command_from_edge_().

◆ relay_msg_free_()

void relay_msg_free_ ( relay_msg_t * msg)

Free the given relay message.

Definition at line 30 of file relay_msg.c.