|
Tor 0.4.9.3-alpha-dev
|
Header file for relay.c. More...
#include "core/or/relay_msg_st.h"Go to the source code of this file.
Macros | |
| #define | CONTROL_CELL_ID 0 |
| #define | relay_send_command_from_edge(stream_id, circ, relay_command, payload, payload_len, cpath_layer) |
| #define | packed_cell_free(cell) FREE_AND_NULL(packed_cell_t, packed_cell_free_, (cell)) |
| #define | update_circuit_on_cmux(circ, direction) update_circuit_on_cmux_((circ), (direction), SHORT_FILE__, __LINE__) |
Variables | |
| uint64_t | stats_n_relay_cells_relayed |
| uint64_t | stats_n_relay_cells_delivered |
| uint64_t | stats_n_circ_max_cell_reached |
| uint64_t | stats_n_circ_max_cell_outq_reached |
| uint64_t | stats_n_data_cells_packaged |
| uint64_t | stats_n_data_bytes_packaged |
| uint64_t | stats_n_data_cells_received |
| uint64_t | stats_n_data_bytes_received |
| uint64_t | oom_stats_n_bytes_removed_dns |
| uint64_t | oom_stats_n_bytes_removed_cell |
| uint64_t | oom_stats_n_bytes_removed_geoip |
| uint64_t | oom_stats_n_bytes_removed_hsdir |
| #define packed_cell_free | ( | cell | ) | FREE_AND_NULL(packed_cell_t, packed_cell_free_, (cell)) |
| #define relay_send_command_from_edge | ( | stream_id, | |
| circ, | |||
| relay_command, | |||
| payload, | |||
| payload_len, | |||
| cpath_layer | |||
| ) |
| #define update_circuit_on_cmux | ( | circ, | |
| direction | |||
| ) | update_circuit_on_cmux_((circ), (direction), SHORT_FILE__, __LINE__) |
| int append_address_to_payload | ( | uint8_t * | payload_out, |
| const tor_addr_t * | addr | ||
| ) |
Append an encoded value of addr to payload_out, which must have at least 18 bytes of free space. The encoding is, as specified in tor-spec.txt: RESOLVED_TYPE_IPV4 or RESOLVED_TYPE_IPV6 [1 byte] LENGTH [1 byte] ADDRESS [length bytes] Return the number of bytes added, or -1 on error
| int append_cell_to_circuit_queue | ( | circuit_t * | circ, |
| channel_t * | chan, | ||
| cell_t * | cell, | ||
| cell_direction_t | direction, | ||
| streamid_t | fromstream | ||
| ) |
Add cell to the queue of circ writing to chan transmitting in direction.
The given cell is copied onto the circuit queue so the caller must cleanup the memory.
This function is part of the fast path.
Return 1 if the cell was successfully sent. Return 0 if the cell can not be sent. The caller MUST NOT close the circuit. Return -1 indicating an error and that the caller should mark the circuit for close.
Definition at line 3352 of file relay.c.
Referenced by circuit_deliver_create_cell(), circuit_package_relay_cell(), circuit_receive_relay_cell(), and onionskin_answer().
| void cell_queue_append | ( | cell_queue_t * | queue, |
| packed_cell_t * | cell | ||
| ) |
Append cell to the end of queue.
Definition at line 2702 of file relay.c.
Referenced by cell_queue_append_packed_copy().
| void cell_queue_append_packed_copy | ( | circuit_t * | circ, |
| cell_queue_t * | queue, | ||
| int | exitward, | ||
| const cell_t * | cell, | ||
| int | wide_circ_ids, | ||
| int | use_stats | ||
| ) |
Append a newly allocated copy of cell to the end of the exitward (or app-ward) queue of circ. If use_stats is true, record statistics about the cell.
Definition at line 2713 of file relay.c.
Referenced by append_cell_to_circuit_queue().
| void cell_queue_clear | ( | cell_queue_t * | queue | ) |
Remove and free every cell in queue.
Definition at line 2737 of file relay.c.
Referenced by circuit_clear_cell_queue(), circuit_free_(), and marked_circuit_free_cells().
| void cell_queue_init | ( | cell_queue_t * | queue | ) |
Initialize queue as an empty cell queue.
Definition at line 2729 of file relay.c.
Referenced by init_circuit_base(), and or_circuit_new().
| int channel_flush_from_first_active_circuit | ( | channel_t * | chan, |
| int | max | ||
| ) |
Pull as many cells as possible (but no more than max) from the queue of the first active circuit on chan, and write them to chan->outbuf. Return the number of cells written. Advance the active circuit pointer to the next active circuit in the ring.
Definition at line 3092 of file relay.c.
Referenced by channel_flush_some_cells().
| void channel_unlink_all_circuits | ( | channel_t * | chan, |
| smartlist_t * | circuits_out | ||
| ) |
Remove all circuits from the cmux on chan.
If circuits_out is non-NULL, add all detached circuits to circuits_out.
Definition at line 2984 of file relay.c.
Referenced by circuit_unlink_all_from_channel().
Remove all the cells queued on circ for chan.
Definition at line 3497 of file relay.c.
Referenced by circuit_about_to_free(), circuit_about_to_free_atexit(), and handle_relay_msg().
| relay_cell_fmt_t circuit_get_relay_format | ( | const circuit_t * | circ, |
| const crypt_path_t * | cpath | ||
| ) |
Return the format to use.
NULL can be passed but not for both.
Definition at line 3537 of file relay.c.
Referenced by circuit_max_relay_payload(), circuit_receive_relay_cell(), connection_edge_get_inbuf_bytes_to_package(), and relay_send_command_from_edge_().
| size_t circuit_max_relay_payload | ( | const circuit_t * | circ, |
| const crypt_path_t * | cpath, | ||
| uint8_t | relay_command | ||
| ) |
Return the maximum relay payload that can be sent to the chosen point, with the specified command.
Definition at line 3555 of file relay.c.
Referenced by circuit_send_intermediate_onion_skin(), command_process_created_cell(), and connection_ap_handshake_send_begin().
| int circuit_package_relay_cell | ( | cell_t * | cell, |
| circuit_t * | circ, | ||
| cell_direction_t | cell_direction, | ||
| crypt_path_t * | layer_hint, | ||
| streamid_t | on_stream, | ||
| const char * | filename, | ||
| int | lineno | ||
| ) |
Package a relay cell from an edge:
Return 1 if the cell was successfully sent as in queued on the circuit. Return 0 if the cell needs to be dropped as in ignored. Return -1 on error for which the circuit should be marked for close.
Definition at line 390 of file relay.c.
Referenced by relay_send_command_from_edge_().
| int circuit_receive_relay_cell | ( | cell_t * | cell, |
| circuit_t * | circ, | ||
| cell_direction_t | cell_direction | ||
| ) |
Receive a relay cell:
Return -reason on failure, else 0.
Definition at line 236 of file relay.c.
Referenced by circuit_receive_relay_cell(), and command_process_relay_cell().
| void circuit_reset_sendme_randomness | ( | circuit_t * | circ | ) |
Called when initializing a circuit, or when we have reached the end of the window in which we need to send some randomness so that incoming sendme cells will be unpredictable. Resets the flags and picks a new window.
Definition at line 2193 of file relay.c.
Referenced by connection_edge_get_inbuf_bytes_to_package(), and init_circuit_base().
| int connection_edge_package_raw_inbuf | ( | edge_connection_t * | conn, |
| int | package_partial, | ||
| int * | max_cells | ||
| ) |
If conn has an entire relay payload of bytes on its inbuf (or package_partial is true), and the appropriate package windows aren't empty, grab a cell and send it down the circuit.
If *max_cells is given, package no more than max_cells. Decrement *max_cells by the number of cells packaged.
Return -1 (and send a RELAY_COMMAND_END cell if necessary) if conn should be marked for close, else return 0.
Definition at line 2277 of file relay.c.
Referenced by circuit_resume_edge_reading_helper(), connection_ap_handshake_send_begin(), connection_edge_process_inbuf(), connection_edge_process_relay_cell_not_open(), and process_sendme_cell().
| int connection_edge_send_command | ( | edge_connection_t * | fromconn, |
| uint8_t | relay_command, | ||
| const char * | payload, | ||
| size_t | payload_len | ||
| ) |
Make a relay cell out of relay_command and payload, and send it onto the open circuit circ. fromconn is the stream that's sending the relay cell, or NULL if it's a control cell. cpath_layer is NULL for OR->OP cells, or the destination hop for OP->OR cells.
If you can't send the cell, mark the circuit for close and return -1. Else return 0.
Definition at line 762 of file relay.c.
Referenced by circuit_send_stream_xoff(), circuit_send_stream_xon(), connection_ap_handshake_send_begin(), connection_ap_handshake_send_resolve(), connection_edge_end(), connection_edge_finished_connecting(), connection_edge_package_raw_inbuf(), connection_exit_connect(), connection_exit_connect_dir(), send_resolved_cell(), send_resolved_hostname_cell(), and sendme_connection_edge_consider_sending().
| const uint8_t * decode_address_from_payload | ( | tor_addr_t * | addr_out, |
| const uint8_t * | payload, | ||
| int | payload_len | ||
| ) |
Given payload_len bytes at payload, starting with an address encoded as by append_address_to_payload(), try to decode the address into *addr_out. Return the next byte in the payload after the address on success, or NULL on failure.
| void destroy_cell_queue_append | ( | destroy_cell_queue_t * | queue, |
| circid_t | circid, | ||
| uint8_t | reason | ||
| ) |
| void destroy_cell_queue_clear | ( | destroy_cell_queue_t * | queue | ) |
Remove and free every cell in queue.
Definition at line 2771 of file relay.c.
Referenced by circuitmux_free_().
| void destroy_cell_queue_init | ( | destroy_cell_queue_t * | queue | ) |
Initialize queue as an empty cell queue.
Definition at line 2763 of file relay.c.
Referenced by circuitmux_alloc().
| void dump_cell_pool_usage | ( | int | severity | ) |
Log current statistics for cell pool allocation at log level severity.
Definition at line 2675 of file relay.c.
Referenced by dumpmemusage().
| int have_been_under_memory_pressure | ( | void | ) |
| void packed_cell_free_ | ( | packed_cell_t * | cell | ) |
| circid_t packed_cell_get_circid | ( | const packed_cell_t * | cell, |
| int | wide_circ_ids | ||
| ) |
| uint8_t packed_cell_get_command | ( | const packed_cell_t * | cell, |
| int | wide_circ_ids | ||
| ) |
Extract the command from a packed cell.
Definition at line 3067 of file relay.c.
Referenced by channel_flush_from_first_active_circuit(), and write_packed_cell().
| size_t packed_cell_mem_cost | ( | void | ) |
Return the total number of bytes used for each packed_cell in a queue. Approximate.
Definition at line 2830 of file relay.c.
Referenced by circuits_handle_oom().
| const char * relay_command_to_string | ( | uint8_t | command | ) |
Convert the relay command into a human-readable string.
Definition at line 526 of file relay.c.
Referenced by fill_single_stream_value(), and relay_send_command_from_edge_().
| void relay_consensus_has_changed | ( | const networkstatus_t * | ns | ) |
| int relay_send_command_from_edge_ | ( | streamid_t | stream_id, |
| circuit_t * | orig_circ, | ||
| uint8_t | relay_command, | ||
| const char * | payload, | ||
| size_t | payload_len, | ||
| crypt_path_t * | cpath_layer, | ||
| const char * | filename, | ||
| int | lineno | ||
| ) |
Make a relay cell out of relay_command and payload, and send it onto the open circuit circ. stream_id is the ID on circ for the stream that's sending the relay cell, or 0 if it's a control cell. cpath_layer is NULL for OR->OP cells, or the destination hop for OP->OR cells.
If you can't send the cell, mark the circuit for close and return -1. Else return 0.
| void update_circuit_on_cmux_ | ( | circuit_t * | circ, |
| cell_direction_t | direction, | ||
| const char * | file, | ||
| int | lineno | ||
| ) |
|
extern |
Statistics on how many bytes were removed by the OOM per type.
Definition at line 2849 of file relay.c.
Referenced by cell_queues_check_size(), and fill_oom_values().
|
extern |
Stats: how many circuits have we closed due to the cell queue limit being reached (see append_cell_to_circuit_queue())
Definition at line 144 of file relay.c.
Referenced by append_cell_to_circuit_queue(), and fill_dos_values().
|
extern |
How many bytes of data have we put in relay_data cells have we built, ever? This would be RELAY_PAYLOAD_SIZE*stats_n_data_cells_packaged if every relay cell we ever sent were completely full of data.
Definition at line 2179 of file relay.c.
Referenced by connection_edge_package_raw_inbuf(), dumpstats(), and log_heartbeat().
|
extern |
How many bytes of data have we received relay_data cells, ever? This would be RELAY_PAYLOAD_SIZE*stats_n_data_cells_packaged if every relay cell we ever received were completely full of data.
Definition at line 2185 of file relay.c.
Referenced by dumpstats(), and handle_relay_msg().
|
extern |
How many relay_data cells have we built, ever?
Definition at line 2175 of file relay.c.
Referenced by connection_edge_package_raw_inbuf(), dumpstats(), and log_heartbeat().
|
extern |
How many relay_data cells have we received, ever?
Definition at line 2181 of file relay.c.
Referenced by dumpstats(), and handle_relay_msg().
|
extern |
Stats: how many relay cells have been delivered to streams at this hop?
Definition at line 141 of file relay.c.
Referenced by circuit_receive_relay_cell(), and dumpstats().
|
extern |
Stats: how many relay cells have originated at this hop, or have been relayed onward (not recognized at this hop)?
Definition at line 137 of file relay.c.
Referenced by circuit_package_relay_cell(), circuit_receive_relay_cell(), and dumpstats().