Tor 0.4.9.8
Loading...
Searching...
No Matches
reasons.c File Reference

Convert circuit, stream, and orconn error reasons to and/or from strings and errno values. More...

Go to the source code of this file.

Macros

#define E_CASE(s)
 
#define S_CASE(s)
 

Functions

const char * stream_end_reason_to_control_string (int reason)
 
const char * stream_end_reason_to_string (int reason)
 
socks5_reply_status_t stream_end_reason_to_socks5_response (int reason)
 
uint8_t errno_to_stream_end_reason (int e)
 
const char * orconn_end_reason_to_control_string (int r)
 
int tls_error_to_orconn_end_reason (int e)
 
int errno_to_orconn_end_reason (int e)
 
const char * circuit_end_reason_to_control_string (int reason)
 
const char * socks4_response_code_to_string (uint8_t code)
 
const char * socks5_response_code_to_string (uint8_t code)
 
const char * bandwidth_weight_rule_to_string (bandwidth_weight_rule_t rule)
 
const char * end_reason_to_http_connect_response_line (int endreason)
 

Detailed Description

Convert circuit, stream, and orconn error reasons to and/or from strings and errno values.

This module is just a bunch of functions full of case statements that convert from one representation of our error codes to another. These are mainly used in generating log messages, in sending messages to the controller in control.c, and in converting errors from one protocol layer to another.

Definition in file reasons.c.

Macro Definition Documentation

◆ E_CASE

#define E_CASE ( s)
Value:
case s

Definition at line 174 of file reasons.c.

◆ S_CASE

#define S_CASE ( s)
Value:
case s

Definition at line 175 of file reasons.c.

Function Documentation

◆ bandwidth_weight_rule_to_string()

const char * bandwidth_weight_rule_to_string ( bandwidth_weight_rule_t rule)

Return a string corresponding to a bandwidth_weight_rule_t

Definition at line 443 of file reasons.c.

Referenced by compute_weighted_bandwidths().

◆ circuit_end_reason_to_control_string()

const char * circuit_end_reason_to_control_string ( int reason)

Convert a numeric reason for destroying a circuit into a string for a CIRCUIT event.

Definition at line 332 of file reasons.c.

Referenced by control_event_circuit_status().

◆ end_reason_to_http_connect_response_line()

const char * end_reason_to_http_connect_response_line ( int endreason)

Given a RELAY_END reason value, convert it to an HTTP response to be send over an HTTP tunnel connection.

Definition at line 465 of file reasons.c.

Referenced by connection_ap_handshake_socks_reply().

◆ errno_to_orconn_end_reason()

int errno_to_orconn_end_reason ( int e)

Given an errno from a failed ORConn connection, return a reason code appropriate for use in the controller orconn events.

Definition at line 295 of file reasons.c.

Referenced by connection_handle_read_impl(), connection_handle_write_impl(), and connection_or_connect().

◆ errno_to_stream_end_reason()

uint8_t errno_to_stream_end_reason ( int e)

Given an errno from a failed exit connection, return a reason code appropriate for use in a RELAY END cell.

Definition at line 181 of file reasons.c.

Referenced by connection_edge_end_errno(), and connection_exit_connect().

◆ orconn_end_reason_to_control_string()

const char * orconn_end_reason_to_control_string ( int r)

Convert the reason for ending an OR connection r into the format used in ORCONN events. Return "UNKNOWN" if the reason is unrecognized.

Definition at line 229 of file reasons.c.

Referenced by connection_or_about_to_close(), control_event_bootstrap_prob_or(), and control_event_or_conn_status().

◆ socks4_response_code_to_string()

const char * socks4_response_code_to_string ( uint8_t code)

Return a string corresponding to a SOCKS4 response code.

Definition at line 397 of file reasons.c.

Referenced by parse_socks_client().

◆ socks5_response_code_to_string()

const char * socks5_response_code_to_string ( uint8_t code)

Return a string corresponding to a SOCKS5 response code.

Definition at line 415 of file reasons.c.

Referenced by parse_socks_client().

◆ stream_end_reason_to_control_string()

const char * stream_end_reason_to_control_string ( int reason)

Convert the reason for ending a stream reason into the format used in STREAM events. Return NULL if the reason is unrecognized.

Note: For all specified remote reasons that can occur in a Relay END message, these are the same as the specified name of the END reason.

Definition at line 32 of file reasons.c.

Referenced by connection_ap_handshake_socks_reply(), and control_event_stream_status().

◆ stream_end_reason_to_socks5_response()

socks5_reply_status_t stream_end_reason_to_socks5_response ( int reason)

Translate reason (as from a relay 'end' cell) into an appropriate SOCKS5 reply code.

A reason of 0 means that we're not actually expecting to send this code back to the socks client; we just call it 'succeeded' to keep things simple.

Definition at line 104 of file reasons.c.

Referenced by connection_ap_handshake_socks_reply().

◆ stream_end_reason_to_string()

const char * stream_end_reason_to_string ( int reason)

Translate reason, which came from a relay 'end' cell, into a static const string describing why the stream is closing. reason is -1 if no reason was provided.

Definition at line 68 of file reasons.c.

Referenced by close_all_socks_conns_waiting_for_desc(), connection_ap_process_end_not_open(), and handle_relay_msg().

◆ tls_error_to_orconn_end_reason()

int tls_error_to_orconn_end_reason ( int e)

Convert a TOR_TLS_* error code into an END_OR_CONN_* reason.

Definition at line 267 of file reasons.c.

Referenced by connection_or_about_to_close().