Commit 232861ba authored by Nick Mathewson's avatar Nick Mathewson 🥄
Browse files

Docment or add DOCDOC comments to undocumented functions in src/or. Make...

Docment or add DOCDOC comments to undocumented functions in src/or.  Make function definition format uniform.


svn:r4411
parent df029fc9
......@@ -101,7 +101,8 @@ const char compat_c_id[] = "$Id$";
* easiest to emulate "return -1" with conformant implementations than
* it is to emulate "return number that would be written" with
* non-conformant implementations.) */
int tor_snprintf(char *str, size_t size, const char *format, ...)
int
tor_snprintf(char *str, size_t size, const char *format, ...)
{
va_list ap;
int r;
......@@ -114,7 +115,8 @@ int tor_snprintf(char *str, size_t size, const char *format, ...)
/** Replacement for vsnprintf; behavior differs as tor_snprintf differs from
* snprintf.
*/
int tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
int
tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
{
int r;
if (size == 0)
......@@ -162,7 +164,8 @@ _tor_fix_source_file(const char *fname)
* *(uint16_t*)(cp), but will not cause segfaults on platforms that forbid
* unaligned memory access.
*/
uint16_t get_uint16(const char *cp)
uint16_t
get_uint16(const char *cp)
{
uint16_t v;
memcpy(&v,cp,2);
......@@ -173,7 +176,8 @@ uint16_t get_uint16(const char *cp)
* *(uint32_t*)(cp), but will not cause segfaults on platforms that forbid
* unaligned memory access.
*/
uint32_t get_uint32(const char *cp)
uint32_t
get_uint32(const char *cp)
{
uint32_t v;
memcpy(&v,cp,4);
......@@ -183,7 +187,8 @@ uint32_t get_uint32(const char *cp)
* Set a 16-bit value beginning at <b>cp</b> to <b>v</b>. Equivalent to
* *(uint16_t)(cp) = v, but will not cause segfaults on platforms that forbid
* unaligned memory access. */
void set_uint16(char *cp, uint16_t v)
void
set_uint16(char *cp, uint16_t v)
{
memcpy(cp,&v,2);
}
......@@ -191,7 +196,8 @@ void set_uint16(char *cp, uint16_t v)
* Set a 32-bit value beginning at <b>cp</b> to <b>v</b>. Equivalent to
* *(uint32_t)(cp) = v, but will not cause segfaults on platforms that forbid
* unaligned memory access. */
void set_uint32(char *cp, uint32_t v)
void
set_uint32(char *cp, uint32_t v)
{
memcpy(cp,&v,4);
}
......@@ -202,7 +208,8 @@ void set_uint32(char *cp, uint32_t v)
* rename(2). On windows, this removes 'to' first if it already exists.
* Returns 0 on success. Returns -1 and sets errno on failure.
*/
int replace_file(const char *from, const char *to)
int
replace_file(const char *from, const char *to)
{
#ifndef MS_WINDOWS
return rename(from,to);
......@@ -226,7 +233,8 @@ int replace_file(const char *from, const char *to)
/** Turn <b>socket</b> into a nonblocking socket.
*/
void set_socket_nonblocking(int socket)
void
set_socket_nonblocking(int socket)
{
#ifdef MS_WINDOWS
int nonblocking = 1;
......@@ -419,7 +427,8 @@ set_max_file_descriptors(unsigned long limit, unsigned long cap) {
/** Call setuid and setgid to run as <b>user</b>:<b>group</b>. Return 0 on
* success. On failure, log and return -1.
*/
int switch_id(char *user, char *group) {
int
switch_id(char *user, char *group) {
#ifndef MS_WINDOWS
struct passwd *pw = NULL;
struct group *gr = NULL;
......@@ -490,7 +499,8 @@ get_user_homedir(const char *username)
* Return 1 on success, 0 if c is badly formatted. (Like inet_aton(c,addr),
* but works on Windows and Solaris.)
*/
int tor_inet_aton(const char *c, struct in_addr* addr)
int
tor_inet_aton(const char *c, struct in_addr* addr)
{
#ifdef HAVE_INET_ATON
return inet_aton(c, addr);
......@@ -517,7 +527,8 @@ int tor_inet_aton(const char *c, struct in_addr* addr)
* (This function exists because standard windows gethostbyname
* doesn't treat raw IP addresses properly.)
*/
int tor_lookup_hostname(const char *name, uint32_t *addr)
int
tor_lookup_hostname(const char *name, uint32_t *addr)
{
/* Perhaps eventually this should be replaced by a tor_getaddrinfo or
* something.
......@@ -744,7 +755,8 @@ spawn_func(int (*func)(void *), void *data)
/** End the current thread/process.
*/
void spawn_exit()
void
spawn_exit()
{
#if defined(USE_WIN32_THREADS)
_endthread();
......@@ -760,7 +772,9 @@ void spawn_exit()
/** Set *timeval to the current time of day. On error, log and terminate.
* (Same as gettimeofday(timeval,NULL), but never returns -1.)
*/
void tor_gettimeofday(struct timeval *timeval) {
void
tor_gettimeofday(struct timeval *timeval)
{
#ifdef HAVE_GETTIMEOFDAY
if (gettimeofday(timeval, NULL)) {
log_fn(LOG_ERR, "gettimeofday failed.");
......@@ -785,7 +799,8 @@ void tor_gettimeofday(struct timeval *timeval) {
#ifndef HAVE_LOCALTIME_R
#ifdef TIME_FNS_NEED_LOCKS
struct tm *tor_localtime_r(const time_t *timep, struct tm *result)
struct tm *
tor_localtime_r(const time_t *timep, struct tm *result)
{
struct tm *r;
static tor_mutex_t *m=NULL;
......@@ -798,7 +813,8 @@ struct tm *tor_localtime_r(const time_t *timep, struct tm *result)
return result;
}
#else
struct tm *tor_localtime_r(const time_t *timep, struct tm *result)
struct tm *
tor_localtime_r(const time_t *timep, struct tm *result)
{
struct tm *r;
tor_assert(result);
......@@ -811,7 +827,8 @@ struct tm *tor_localtime_r(const time_t *timep, struct tm *result)
#ifndef HAVE_GMTIME_R
#ifdef TIME_FNS_NEED_LOCKS
struct tm *tor_gmtime_r(const time_t *timep, struct tm *result)
struct tm *
tor_gmtime_r(const time_t *timep, struct tm *result)
{
struct tm *r;
static tor_mutex_t *m=NULL;
......@@ -824,7 +841,8 @@ struct tm *tor_gmtime_r(const time_t *timep, struct tm *result)
return result;
}
#else
struct tm *tor_gmtime_r(const time_t *timep, struct tm *result)
struct tm *
tor_gmtime_r(const time_t *timep, struct tm *result)
{
struct tm *r;
tor_assert(result);
......@@ -839,7 +857,8 @@ struct tm *tor_gmtime_r(const time_t *timep, struct tm *result)
struct tor_mutex_t {
HANDLE handle;
};
tor_mutex_t *tor_mutex_new(void)
tor_mutex_t *
tor_mutex_new(void)
{
tor_mutex_t *m;
m = tor_malloc_zero(sizeof(tor_mutex_t));
......@@ -847,12 +866,14 @@ tor_mutex_t *tor_mutex_new(void)
tor_assert(m->handle != NULL);
return m;
}
void tor_mutex_free(tor_mutex_t *m)
void
tor_mutex_free(tor_mutex_t *m)
{
CloseHandle(m->handle);
tor_free(m);
}
void tor_mutex_acquire(tor_mutex_t *m)
void
tor_mutex_acquire(tor_mutex_t *m)
{
DWORD r;
r = WaitForSingleObject(m->handle, INFINITE);
......@@ -867,7 +888,8 @@ void tor_mutex_acquire(tor_mutex_t *m)
log_fn(LOG_WARN, "Failed to acquire mutex: %d", GetLastError());
}
}
void tor_mutex_release(tor_mutex_t *m)
void
tor_mutex_release(tor_mutex_t *m)
{
BOOL r;
r = ReleaseMutex(m->handle);
......@@ -884,23 +906,27 @@ tor_get_thread_id(void)
struct tor_mutex_t {
pthread_mutex_t mutex;
};
tor_mutex_t *tor_mutex_new(void)
tor_mutex_t *
tor_mutex_new(void)
{
tor_mutex_t *mutex = tor_malloc_zero(sizeof(tor_mutex_t));
pthread_mutex_init(&mutex->mutex, NULL);
return mutex;
}
void tor_mutex_acquire(tor_mutex_t *m)
void
tor_mutex_acquire(tor_mutex_t *m)
{
tor_assert(m);
pthread_mutex_lock(&m->mutex);
}
void tor_mutex_release(tor_mutex_t *m)
void
tor_mutex_release(tor_mutex_t *m)
{
tor_assert(m);
pthread_mutex_unlock(&m->mutex);
}
void tor_mutex_free(tor_mutex_t *m)
void
tor_mutex_free(tor_mutex_t *m)
{
tor_assert(m);
pthread_mutex_destroy(&m->mutex);
......@@ -1007,7 +1033,8 @@ struct { int code; const char *msg; } windows_socket_errors[] = {
/** There does not seem to be a strerror equivalent for winsock errors.
* Naturally, we have to roll our own.
*/
const char *tor_socket_strerror(int e)
const char *
tor_socket_strerror(int e)
{
int i;
for (i=0; windows_socket_errors[i].code >= 0; ++i) {
......@@ -1021,7 +1048,8 @@ const char *tor_socket_strerror(int e)
/** Called before we make any calls to network-related functions.
* (Some operating systems require their network libraries to be
* initialized.) */
int network_init(void)
int
network_init(void)
{
#ifdef MS_WINDOWS
/* This silly exercise is necessary before windows will allow gethostbyname to work.
......
......@@ -76,7 +76,8 @@ static INLINE void peek_from_buf(char *string, size_t string_len, buf_t *buf);
* beginning. This operation is relatively expensive, so it shouldn't
* be used e.g. for every single read or write.
*/
static void buf_normalize(buf_t *buf)
static void
buf_normalize(buf_t *buf)
{
check();
if (buf->cur + buf->datalen <= buf->mem+buf->len) {
......@@ -96,7 +97,8 @@ static void buf_normalize(buf_t *buf)
}
/** Return the point in the buffer where the next byte will get stored. */
static INLINE char *_buf_end(buf_t *buf)
static INLINE char *
_buf_end(buf_t *buf)
{
char *next = buf->cur + buf->datalen;
char *end = buf->mem + buf->len;
......@@ -105,7 +107,8 @@ static INLINE char *_buf_end(buf_t *buf)
/** If the pointer <b>cp</b> has passed beyond the end of the buffer, wrap it
* around. */
static INLINE char *_wrap_ptr(buf_t *buf, char *cp) {
static INLINE char *
_wrap_ptr(buf_t *buf, char *cp) {
return (cp >= buf->mem + buf->len) ? (cp - buf->len) : cp;
}
......@@ -114,7 +117,8 @@ static INLINE char *_wrap_ptr(buf_t *buf, char *cp) {
* at <b>at</b>, and set *<b>more_len</b> to the number of bytes starting
* at <b>buf-&gt;mem</b>. Otherwise, set *<b>more_len</b> to 0.
*/
static INLINE void _split_range(buf_t *buf, char *at, size_t *len,
static INLINE void
_split_range(buf_t *buf, char *at, size_t *len,
size_t *more_len)
{
char *eos = at + *len;
......@@ -128,7 +132,8 @@ static INLINE void _split_range(buf_t *buf, char *at, size_t *len,
}
/** Change a buffer's capacity. <b>new_capacity</b> must be \>= buf->datalen. */
static void buf_resize(buf_t *buf, size_t new_capacity)
static void
buf_resize(buf_t *buf, size_t new_capacity)
{
off_t offset;
#ifdef CHECK_AFTER_RESIZE
......@@ -225,7 +230,8 @@ static void buf_resize(buf_t *buf, size_t new_capacity)
* it so that it can. (The new size will be a power of 2 times the old
* size.)
*/
static INLINE int buf_ensure_capacity(buf_t *buf, size_t capacity)
static INLINE int
buf_ensure_capacity(buf_t *buf, size_t capacity)
{
size_t new_len;
if (buf->len >= capacity) /* Don't grow if we're already big enough. */
......@@ -251,7 +257,8 @@ static INLINE int buf_ensure_capacity(buf_t *buf, size_t capacity)
* one of the above no longer holds. (We shrink the buffer by
* dividing by powers of 2.)
*/
static INLINE void buf_shrink_if_underfull(buf_t *buf) {
static INLINE void
buf_shrink_if_underfull(buf_t *buf) {
size_t new_len;
/* If the buffer is at least 1/8 full, or if shrinking the buffer would
* put it under MIN_GREEDY_SHRINK_SIZE, don't do it. */
......@@ -298,7 +305,8 @@ buf_shrink(buf_t *buf)
/** Remove the first <b>n</b> bytes from buf.
*/
static INLINE void buf_remove_from_front(buf_t *buf, size_t n) {
static INLINE void
buf_remove_from_front(buf_t *buf, size_t n) {
tor_assert(buf->datalen >= n);
buf->datalen -= n;
buf_total_used -= n;
......@@ -312,7 +320,8 @@ static INLINE void buf_remove_from_front(buf_t *buf, size_t n) {
}
/** Make sure that the memory in buf ends with a zero byte. */
static INLINE int buf_nul_terminate(buf_t *buf)
static INLINE int
buf_nul_terminate(buf_t *buf)
{
if (buf_ensure_capacity(buf,buf->datalen+1)<0)
return -1;
......@@ -322,7 +331,8 @@ static INLINE int buf_nul_terminate(buf_t *buf)
/** Create and return a new buf with capacity <b>size</b>.
*/
buf_t *buf_new_with_capacity(size_t size) {
buf_t *
buf_new_with_capacity(size_t size) {
buf_t *buf;
buf = tor_malloc_zero(sizeof(buf_t));
buf->magic = BUFFER_MAGIC;
......@@ -336,13 +346,15 @@ buf_t *buf_new_with_capacity(size_t size) {
}
/** Allocate and return a new buffer with default capacity. */
buf_t *buf_new()
buf_t *
buf_new(void)
{
return buf_new_with_capacity(INITIAL_BUF_SIZE);
}
/** Remove all data from <b>buf</b> */
void buf_clear(buf_t *buf)
void
buf_clear(buf_t *buf)
{
buf_total_used -= buf->datalen;
buf->datalen = 0;
......@@ -350,28 +362,33 @@ void buf_clear(buf_t *buf)
}
/** Return the number of bytes stored in <b>buf</b> */
size_t buf_datalen(const buf_t *buf)
size_t
buf_datalen(const buf_t *buf)
{
return buf->datalen;
}
/** Return the maximum bytes that can be stored in <b>buf</b> before buf
* needs to resize. */
size_t buf_capacity(const buf_t *buf)
size_t
buf_capacity(const buf_t *buf)
{
return buf->len;
}
/** For testing only: Return a pointer to the raw memory stored in <b>buf</b>.
*/
const char *_buf_peek_raw_buffer(const buf_t *buf)
const char *
_buf_peek_raw_buffer(const buf_t *buf)
{
return buf->cur;
}
/** Release storage held by <b>buf</b>.
*/
void buf_free(buf_t *buf) {
void
buf_free(buf_t *buf)
{
assert_buf_ok(buf);
buf->magic = 0xDEADBEEF;
free(RAW_MEM(buf->mem));
......@@ -380,8 +397,15 @@ void buf_free(buf_t *buf) {
tor_free(buf);
}
static INLINE int read_to_buf_impl(int s, size_t at_most, buf_t *buf,
char *pos, int *reached_eof)
/** Helper for read_to_buf: read no more than at_most bytes from
* socket s into buffer buf, starting at the position pos. (Does not
* check for overflow.) Set *reached_eof to true on EOF. Return
* number of bytes read on success, 0 if the read would block, -1 on
* failure.
*/
static INLINE int
read_to_buf_impl(int s, size_t at_most, buf_t *buf,
char *pos, int *reached_eof)
{
int read_result;
......@@ -414,7 +438,8 @@ static INLINE int read_to_buf_impl(int s, size_t at_most, buf_t *buf,
* else return the number of bytes read. Return 0 if recv() would
* block.
*/
int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof)
int
read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof)
{
int r;
char *next;
......@@ -456,6 +481,11 @@ int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof)
return r;
}
/** Helper for read_to_buf_tls: read no more than at_most bytes from
* the TLS connection tlsinto buffer buf, starting at the position
* next. (Does not check for overflow.) Return number of bytes read
* on success, 0 if the read would block, -1 on failure.
*/
static INLINE int
read_to_buf_tls_impl(tor_tls *tls, size_t at_most, buf_t *buf, char *next)
{
......@@ -495,7 +525,9 @@ read_to_buf_tls_impl(tor_tls *tls, size_t at_most, buf_t *buf, char *next)
* events: sometimes, before a TLS stream can read, the network must be
* ready to write -- or vice versa.
*/
int read_to_buf_tls(tor_tls *tls, size_t at_most, buf_t *buf) {
int
read_to_buf_tls(tor_tls *tls, size_t at_most, buf_t *buf)
{
int r;
char *next;
size_t at_start;
......@@ -537,6 +569,10 @@ int read_to_buf_tls(tor_tls *tls, size_t at_most, buf_t *buf) {
return r;
}
/** Helper for flush_buf: try to write sz bytes from buffer buf onto
* socket s. On success, deduct the bytes written from *buf_flushlen.
* Return the number of bytes written on success, -1 on failure.
*/
static INLINE int
flush_buf_impl(int s, buf_t *buf, size_t sz, size_t *buf_flushlen)
{
......@@ -565,7 +601,8 @@ flush_buf_impl(int s, buf_t *buf, size_t sz, size_t *buf_flushlen)
* from the buffer. Return the number of bytes written on success,
* -1 on failure. Return 0 if write() would block.
*/
int flush_buf(int s, buf_t *buf, size_t *buf_flushlen)
int
flush_buf(int s, buf_t *buf, size_t *buf_flushlen)
{
int r;
size_t flushed = 0;
......@@ -604,6 +641,10 @@ int flush_buf(int s, buf_t *buf, size_t *buf_flushlen)
return flushed;
}
/** Helper for flush_buf_tls: try to write sz bytes from buffer buf onto
* TLS object tls. On success, deduct the bytes written from *buf_flushlen.
* Return the number of bytes written on success, -1 on failure.
*/
static INLINE int
flush_buf_tls_impl(tor_tls *tls, buf_t *buf, size_t sz, size_t *buf_flushlen)
{
......@@ -699,7 +740,10 @@ write_to_buf(const char *string, size_t string_len, buf_t *buf)
return buf->datalen;
}
static INLINE void peek_from_buf(char *string, size_t string_len, buf_t *buf)
/** Helper: copy the first string_len bytes from buf onto string.
*/
static INLINE void
peek_from_buf(char *string, size_t string_len, buf_t *buf)
{
size_t len2;
......@@ -724,7 +768,8 @@ static INLINE void peek_from_buf(char *string, size_t string_len, buf_t *buf)
* into <b>string</b>. Return the new buffer size. <b>string_len</b> must be \<=
* the number of bytes on the buffer.
*/
int fetch_from_buf(char *string, size_t string_len, buf_t *buf)
int
fetch_from_buf(char *string, size_t string_len, buf_t *buf)
{
/* There must be string_len bytes in buf; write them onto string,
* then memmove buf back (that is, remove them from buf).
......@@ -755,9 +800,11 @@ int fetch_from_buf(char *string, size_t string_len, buf_t *buf)
*
* Else, change nothing and return 0.
*/
int fetch_from_buf_http(buf_t *buf,
char **headers_out, size_t max_headerlen,
char **body_out, size_t *body_used, size_t max_bodylen) {
int
fetch_from_buf_http(buf_t *buf,
char **headers_out, size_t max_headerlen,
char **body_out, size_t *body_used, size_t max_bodylen)
{
char *headers, *body, *p;
size_t headerlen, bodylen, contentlen;
......@@ -846,7 +893,9 @@ int fetch_from_buf_http(buf_t *buf,
*
* If returning 0 or -1, <b>req->address</b> and <b>req->port</b> are undefined.
*/
int fetch_from_buf_socks(buf_t *buf, socks_request_t *req) {
int
fetch_from_buf_socks(buf_t *buf, socks_request_t *req)
{
unsigned char len;
char tmpbuf[INET_NTOA_BUF_LEN];
uint32_t destip;
......@@ -1059,8 +1108,9 @@ int fetch_from_buf_socks(buf_t *buf, socks_request_t *req) {
*
* Return -1 on error.
*/
int fetch_from_buf_control(buf_t *buf, uint32_t *len_out, uint16_t *type_out,
char **body_out)
int
fetch_from_buf_control(buf_t *buf, uint32_t *len_out, uint16_t *type_out,
char **body_out)
{
uint32_t msglen;
uint16_t type;
......
......@@ -36,7 +36,9 @@ static int onion_append_hop(crypt_path_t **head_ptr, routerinfo_t *choice);
*
* Return it, or 0 if can't get a unique circ_id.
*/
static uint16_t get_unique_circ_id_by_conn(connection_t *conn) {
static uint16_t
get_unique_circ_id_by_conn(connection_t *conn)
{
uint16_t test_circ_id;
int attempts=0;
uint16_t high_bit;
......@@ -130,7 +132,9 @@ circuit_list_path(circuit_t *circ, int verbose)
* circ's cpath. Also log the length of the cpath, and the intended
* exit point.
*/
void circuit_log_path(int severity, circuit_t *circ) {
void
circuit_log_path(int severity, circuit_t *circ)
{
char *s = circuit_list_path(circ,1);
log_fn(severity,"%s",s);
tor_free(s);
......@@ -141,7 +145,9 @@ void circuit_log_path(int severity, circuit_t *circ) {
* extended; the _first_ hop that isn't open (if any) is marked as
* unable to extend.
*/
void circuit_rep_hist_note_result(circuit_t *circ) {
void
circuit_rep_hist_note_result(circuit_t *circ)
{
struct crypt_path_t *hop;
char *prev_digest = NULL;
routerinfo_t *router;
......@@ -183,7 +189,8 @@ void circuit_rep_hist_note_result(circuit_t *circ) {
*/
static void
circuit_dump_details(int severity, circuit_t *circ, int poll_index,
const char *type, int this_circid, int other_circid) {
const char *type, int this_circid, int other_circid)
{
log(severity,"Conn %d has %s circuit: circID %d (other side %d), state %d (%s), born %d:",
poll_index, type, this_circid, other_circid, circ->state,
circuit_state_to_string(circ->state), (int)circ->timestamp_created);
......@@ -195,7 +202,9 @@ circuit_dump_details(int severity, circuit_t *circ, int poll_index,
/** Log, at severity <b>severity</b>, information about each circuit
* that is connected to <b>conn</b>.
*/
void circuit_dump_by_conn(connection_t *conn, int severity) {
void
circuit_dump_by_conn(connection_t *conn, int severity)
{
circuit_t *circ;
connection_t *tmpconn;
......@@ -233,7 +242,8 @@ void circuit_dump_by_conn(connection_t *conn, int severity) {
/** Pick all the entries in our cpath. Stop and return 0 when we're
* happy, or return -1 if an error occurs. */
static int
onion_populate_cpath(circuit_t *circ) {
onion_populate_cpath(circuit_t *circ)
{
int r;
again:
r = onion_extend_cpath(circ->purpose, &circ->cpath, circ->build_state);
......@@ -250,7 +260,8 @@ again:
/** Create and return a new circuit. Initialize its purpose and
* build-state based on our arguments. */
circuit_t *
circuit_init(uint8_t purpose, int need_uptime, int need_capacity, int internal) {
circuit_init(uint8_t purpose, int need_uptime, int need_capacity, int internal)
{
circuit_t *circ = circuit_new(0, NULL); /* sets circ->p_circ_id and circ->p_conn */
circ->state = CIRCUIT_STATE_OR_WAIT;
circ->build_state = tor_malloc_zero(sizeof(cpath_build_state_t));
......@@ -270,7 +281,8 @@ circuit_init(uint8_t purpose, int need_uptime, int need_capacity, int internal)
*/
circuit_t *
circuit_establish_circuit(uint8_t purpose, routerinfo_t *exit,
int need_uptime, int need_capacity, int internal) {
int need_uptime, int need_capacity, int internal)
{
circuit_t *circ;
circ = circuit_init(purpose, need_uptime, need_capacity, internal);
......@@ -294,7 +306,9 @@ circuit_establish_circuit(uint8_t purpose, routerinfo_t *exit,
* OR we should connect to, and if necessary start the connection to
* it. If we're already connected, then send the 'create' cell.
* Return 0 for ok, -1 if circ should be marked-for-close. */
int circuit_handle_first_hop(circuit_t *circ) {
int
circuit_handle_first_hop(circuit_t *circ)
{
routerinfo_t *firsthop;
connection_t *n_conn;
......@@ -344,7 +358,9 @@ int circuit_handle_first_hop(circuit_t *circ) {
*
* Status is 1 if connect succeeded, or 0 if connect failed.
*/
void circuit_n_conn_done(connection_t *or_conn, int status) {
void
circuit_n_conn_done(connection_t *or_conn, int status)
{
circuit_t *circ;
log_fn(LOG_DEBUG,"or_conn to %s, status=%d",
......@@ -384,8 +400,10 @@ void circuit_n_conn_done(connection_t *or_conn, int status) {
}
}
/** DOCDOC */
static int
circuit_deliver_create_cell(circuit_t *circ, uint8_t cell_type, char *payload) {
circuit_deliver_create_cell(circuit_t *circ, uint8_t cell_type, char *payload)
{