tor  0.4.2.1-alpha-dev
Functions
control_proto.h File Reference

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,...) CHECK_PRINTF(2
 
void 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_DECL (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) CHECK_PRINTF(4
 
void 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,...) CHECK_PRINTF(3
 
void 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,...) CHECK_PRINTF(3
 
void 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,...) CHECK_PRINTF(3
 
void void control_write_data (control_connection_t *conn, const char *data)
 

Detailed Description

Header file for control_proto.c.

Definition in file control_proto.h.

Function Documentation

◆ 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_write_data()

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

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

void 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().