tor  0.4.2.1-alpha-dev
Functions
control_proto.c File Reference
#include "core/or/or.h"
#include "core/mainloop/connection.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "core/or/connection_edge.h"
#include "feature/control/control_proto.h"
#include "feature/nodelist/nodelist.h"
#include "core/or/cpath_build_state_st.h"
#include "core/or/entry_connection_st.h"
#include "core/or/or_connection_st.h"
#include "core/or/origin_circuit_st.h"
#include "core/or/socks_request_st.h"
#include "feature/control/control_connection_st.h"

Go to the source code of this file.

Functions

void connection_write_str_to_buf (const char *s, control_connection_t *conn)
 
void connection_printf_to_buf (control_connection_t *conn, const char *format,...)
 
size_t write_escaped_data (const char *data, size_t len, char **out)
 
size_t read_escaped_data (const char *data, size_t len, char **out)
 
void send_control_done (control_connection_t *conn)
 
 MOCK_IMPL (void, control_write_reply,(control_connection_t *conn, int code, int c, const char *s))
 
void control_vprintf_reply (control_connection_t *conn, int code, int c, const char *fmt, va_list ap)
 
void control_write_endreply (control_connection_t *conn, int code, const char *s)
 
void control_printf_endreply (control_connection_t *conn, int code, const char *fmt,...)
 
void control_write_midreply (control_connection_t *conn, int code, const char *s)
 
void control_printf_midreply (control_connection_t *conn, int code, const char *fmt,...)
 
void control_write_datareply (control_connection_t *conn, int code, const char *s)
 
void control_printf_datareply (control_connection_t *conn, int code, const char *fmt,...)
 
void control_write_data (control_connection_t *conn, const char *data)
 

Detailed Description

Formatting functions for controller data.

Definition in file control_proto.c.

Function Documentation

◆ connection_printf_to_buf()

void connection_printf_to_buf ( control_connection_t conn,
const char *  format,
  ... 
)

Acts like sprintf, but writes its formatted string to the end of conn->outbuf.

Definition at line 39 of file control_proto.c.

References tor_vasprintf().

Referenced by MOCK_IMPL().

◆ connection_write_str_to_buf()

void connection_write_str_to_buf ( const char *  s,
control_connection_t conn 
)

Append a NUL-terminated string s to the end of conn->outbuf.

Definition at line 30 of file control_proto.c.

◆ control_printf_datareply()

void control_printf_datareply ( control_connection_t conn,
int  code,
const char *  fmt,
  ... 
)

Write a formatted DataReplyLine

Definition at line 257 of file control_proto.c.

References control_vprintf_reply().

◆ control_printf_endreply()

void control_printf_endreply ( control_connection_t conn,
int  code,
const char *  fmt,
  ... 
)

◆ control_printf_midreply()

void control_printf_midreply ( control_connection_t conn,
int  code,
const char *  fmt,
  ... 
)

Write a formatted MidReplyLine

Definition at line 238 of file control_proto.c.

References control_vprintf_reply().

◆ control_vprintf_reply()

void control_vprintf_reply ( control_connection_t conn,
int  code,
int  c,
const char *  fmt,
va_list  ap 
)

Write a formatted reply to the control channel.

Parameters
conncontrol connection
codenumeric result code
cseparator character, usually ' ', '-', or '+'
fmtformat string
apva_list from caller

Definition at line 195 of file control_proto.c.

References tor_vasprintf().

Referenced by control_printf_datareply(), control_printf_endreply(), and control_printf_midreply().

◆ control_write_data()

void control_write_data ( control_connection_t conn,
const char *  data 
)

Write a CmdData

Definition at line 269 of file control_proto.c.

References write_escaped_data().

◆ control_write_datareply()

void control_write_datareply ( control_connection_t conn,
int  code,
const char *  s 
)

Write a DataReplyLine

Definition at line 250 of file control_proto.c.

◆ control_write_endreply()

void control_write_endreply ( control_connection_t conn,
int  code,
const char *  s 
)

Write an EndReplyLine

Definition at line 212 of file control_proto.c.

Referenced by handle_control_getinfo(), handle_control_postdescriptor(), handle_control_saveconf(), and send_control_done().

◆ control_write_midreply()

void control_write_midreply ( control_connection_t conn,
int  code,
const char *  s 
)

Write a MidReplyLine

Definition at line 231 of file control_proto.c.

◆ MOCK_IMPL()

MOCK_IMPL ( void  ,
control_write_reply  ,
(control_connection_t *conn, int code, int c, const char *s)   
)

Write a reply to the control channel.

Parameters
conncontrol connection
codenumeric result code
cseparator character, usually ' ', '-', or '+'
sstring

Definition at line 179 of file control_proto.c.

References connection_printf_to_buf().

◆ read_escaped_data()

size_t read_escaped_data ( const char *  data,
size_t  len,
char **  out 
)

Given a len-character string in data, made of lines terminated by CRLF, allocate a new string in *out, and copy the contents of data into *out, removing any period that appears at the start of a line, and replacing all CRLF sequences with LF. Return the number of bytes in *out.

This corresponds to CmdData in control-spec.txt.

Definition at line 128 of file control_proto.c.

◆ send_control_done()

void send_control_done ( control_connection_t conn)

Send a "DONE" message down the control connection conn.

Definition at line 167 of file control_proto.c.

References control_write_endreply().

Referenced by handle_control_postdescriptor(), and handle_control_saveconf().

◆ write_escaped_data()

size_t write_escaped_data ( const char *  data,
size_t  len,
char **  out 
)

Given a len-character string in data, made of lines terminated by CRLF, allocate a new string in *out, and copy the contents of data into *out, adding a period before any period that appears at the start of a line, and adding a period-CRLF line at the end. Replace all LF characters sequences with CRLF. Return the number of bytes in *out.

This corresponds to CmdData in control-spec.txt.

Definition at line 69 of file control_proto.c.

References SIZE_T_CEILING, and tor_assert().

Referenced by control_write_data().