tor  0.4.0.0-alpha-dev
Macros | Functions
reasons.c File Reference
#include "core/or/or.h"
#include "app/config/config.h"
#include "core/or/reasons.h"
#include "feature/nodelist/node_select.h"
#include "lib/tls/tortls.h"

Go to the source code of this file.

Macros

#define E_CASE(s)   case s
 
#define S_CASE(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.

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 435 of file reasons.c.

◆ 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 324 of file reasons.c.

References END_CIRC_AT_ORIGIN, and END_CIRC_REASON_FLAG_REMOTE.

◆ 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 457 of file reasons.c.

References END_STREAM_REASON_MASK.

◆ 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 287 of file reasons.c.

Referenced by connection_handle_read_impl().

◆ 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 177 of file reasons.c.

Referenced by connection_edge_end_errno().

◆ 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 225 of file reasons.c.

◆ 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 389 of file reasons.c.

◆ 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 407 of file reasons.c.

◆ 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.

Definition at line 28 of file reasons.c.

References END_STREAM_REASON_MASK.

◆ 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 100 of file reasons.c.

References END_STREAM_REASON_MASK.

◆ 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 64 of file reasons.c.

References log_fn.

◆ 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 261 of file reasons.c.