mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-13 14:43:46 +01:00
Define new CONST_TO_*_CONN() functions for const-to-const casts
These names are analogous to the CONST_TO_*_CIRC() functions we have for circuits. Part of #40046.
This commit is contained in:
parent
b0d7b10088
commit
47a48e2f5a
@ -233,6 +233,18 @@ TO_LISTENER_CONN(connection_t *c)
|
|||||||
return DOWNCAST(listener_connection_t, c);
|
return DOWNCAST(listener_connection_t, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cast a `const connection_t *` to a `const listener_connection_t *`.
|
||||||
|
*
|
||||||
|
* Exit with an assertion failure if the input is not a
|
||||||
|
* `listener_connection_t`.
|
||||||
|
**/
|
||||||
|
const listener_connection_t *
|
||||||
|
CONST_TO_LISTENER_CONN(const connection_t *c)
|
||||||
|
{
|
||||||
|
return TO_LISTENER_CONN((connection_t *)c);
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
connection_get_inbuf_len(connection_t *conn)
|
connection_get_inbuf_len(connection_t *conn)
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,8 @@ struct tor_addr_t;
|
|||||||
struct or_options_t;
|
struct or_options_t;
|
||||||
|
|
||||||
struct listener_connection_t *TO_LISTENER_CONN(struct connection_t *);
|
struct listener_connection_t *TO_LISTENER_CONN(struct connection_t *);
|
||||||
|
const struct listener_connection_t *CONST_TO_LISTENER_CONN(
|
||||||
|
const struct connection_t *);
|
||||||
|
|
||||||
struct buf_t;
|
struct buf_t;
|
||||||
|
|
||||||
|
@ -180,6 +180,18 @@ TO_EDGE_CONN(connection_t *c)
|
|||||||
return DOWNCAST(edge_connection_t, c);
|
return DOWNCAST(edge_connection_t, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cast a `const connection_t *` to a `const edge_connection_t *`.
|
||||||
|
*
|
||||||
|
* Exit with an assertion failure if the input is not an
|
||||||
|
* `edge_connection_t`.
|
||||||
|
**/
|
||||||
|
const edge_connection_t *
|
||||||
|
CONST_TO_EDGE_CONN(const connection_t *c)
|
||||||
|
{
|
||||||
|
return TO_EDGE_CONN((connection_t *)c);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast a `connection_t *` to an `entry_connection_t *`.
|
* Cast a `connection_t *` to an `entry_connection_t *`.
|
||||||
*
|
*
|
||||||
@ -193,6 +205,18 @@ TO_ENTRY_CONN(connection_t *c)
|
|||||||
return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_.base_);
|
return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_.base_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cast a `const connection_t *` to a `const entry_connection_t *`.
|
||||||
|
*
|
||||||
|
* Exit with an assertion failure if the input is not an
|
||||||
|
* `entry_connection_t`.
|
||||||
|
**/
|
||||||
|
const entry_connection_t *
|
||||||
|
CONST_TO_ENTRY_CONN(const connection_t *c)
|
||||||
|
{
|
||||||
|
return TO_ENTRY_CONN((connection_t*) c);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast an `edge_connection_t *` to an `entry_connection_t *`.
|
* Cast an `edge_connection_t *` to an `entry_connection_t *`.
|
||||||
*
|
*
|
||||||
@ -206,6 +230,18 @@ EDGE_TO_ENTRY_CONN(edge_connection_t *c)
|
|||||||
return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_);
|
return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cast a `const edge_connection_t *` to a `const entry_connection_t *`.
|
||||||
|
*
|
||||||
|
* Exit with an assertion failure if the input is not an
|
||||||
|
* `entry_connection_t`.
|
||||||
|
**/
|
||||||
|
const entry_connection_t *
|
||||||
|
CONST_EDGE_TO_ENTRY_CONN(const edge_connection_t *c)
|
||||||
|
{
|
||||||
|
return EDGE_TO_ENTRY_CONN((edge_connection_t*)c);
|
||||||
|
}
|
||||||
|
|
||||||
/** An AP stream has failed/finished. If it hasn't already sent back
|
/** An AP stream has failed/finished. If it hasn't already sent back
|
||||||
* a socks reply, send one now (based on endreason). Also set
|
* a socks reply, send one now (based on endreason). Also set
|
||||||
* has_sent_end to 1, and mark the conn.
|
* has_sent_end to 1, and mark the conn.
|
||||||
|
@ -20,6 +20,10 @@ edge_connection_t *TO_EDGE_CONN(connection_t *);
|
|||||||
entry_connection_t *TO_ENTRY_CONN(connection_t *);
|
entry_connection_t *TO_ENTRY_CONN(connection_t *);
|
||||||
entry_connection_t *EDGE_TO_ENTRY_CONN(edge_connection_t *);
|
entry_connection_t *EDGE_TO_ENTRY_CONN(edge_connection_t *);
|
||||||
|
|
||||||
|
const edge_connection_t *CONST_TO_EDGE_CONN(const connection_t *);
|
||||||
|
const entry_connection_t *CONST_TO_ENTRY_CONN(const connection_t *);
|
||||||
|
const entry_connection_t *CONST_EDGE_TO_ENTRY_CONN(const edge_connection_t *);
|
||||||
|
|
||||||
#define EXIT_CONN_STATE_MIN_ 1
|
#define EXIT_CONN_STATE_MIN_ 1
|
||||||
/** State for an exit connection: waiting for response from DNS farm. */
|
/** State for an exit connection: waiting for response from DNS farm. */
|
||||||
#define EXIT_CONN_STATE_RESOLVING 1
|
#define EXIT_CONN_STATE_RESOLVING 1
|
||||||
|
@ -111,6 +111,17 @@ TO_OR_CONN(connection_t *c)
|
|||||||
return DOWNCAST(or_connection_t, c);
|
return DOWNCAST(or_connection_t, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cast a `const connection_t *` to a `const or_connection_t *`.
|
||||||
|
*
|
||||||
|
* Exit with an assertion failure if the input is not an `or_connnection_t`.
|
||||||
|
**/
|
||||||
|
const or_connection_t *
|
||||||
|
CONST_TO_OR_CONN(const connection_t *c)
|
||||||
|
{
|
||||||
|
return TO_OR_CONN((connection_t *)c);
|
||||||
|
}
|
||||||
|
|
||||||
/** Clear clear conn->identity_digest and update other data
|
/** Clear clear conn->identity_digest and update other data
|
||||||
* structures as appropriate.*/
|
* structures as appropriate.*/
|
||||||
void
|
void
|
||||||
|
@ -16,6 +16,7 @@ struct ed25519_public_key_t;
|
|||||||
struct ed25519_keypair_t;
|
struct ed25519_keypair_t;
|
||||||
|
|
||||||
or_connection_t *TO_OR_CONN(connection_t *);
|
or_connection_t *TO_OR_CONN(connection_t *);
|
||||||
|
const or_connection_t *CONST_TO_OR_CONN(const connection_t *);
|
||||||
|
|
||||||
#include "core/or/orconn_event.h"
|
#include "core/or/orconn_event.h"
|
||||||
|
|
||||||
|
@ -74,6 +74,18 @@ TO_CONTROL_CONN(connection_t *c)
|
|||||||
return DOWNCAST(control_connection_t, c);
|
return DOWNCAST(control_connection_t, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cast a `const connection_t *` to a `const control_connection_t *`.
|
||||||
|
*
|
||||||
|
* Exit with an assertion failure if the input is not a
|
||||||
|
* `control_connection_t`.
|
||||||
|
**/
|
||||||
|
const control_connection_t *
|
||||||
|
CONST_TO_CONTROL_CONN(const connection_t *c)
|
||||||
|
{
|
||||||
|
return TO_CONTROL_CONN((connection_t*)c);
|
||||||
|
}
|
||||||
|
|
||||||
/** Create and add a new controller connection on <b>sock</b>. If
|
/** Create and add a new controller connection on <b>sock</b>. If
|
||||||
* <b>CC_LOCAL_FD_IS_OWNER</b> is set in <b>flags</b>, this Tor process should
|
* <b>CC_LOCAL_FD_IS_OWNER</b> is set in <b>flags</b>, this Tor process should
|
||||||
* exit when the connection closes. If <b>CC_LOCAL_FD_IS_AUTHENTICATED</b>
|
* exit when the connection closes. If <b>CC_LOCAL_FD_IS_AUTHENTICATED</b>
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define TOR_CONTROL_H
|
#define TOR_CONTROL_H
|
||||||
|
|
||||||
control_connection_t *TO_CONTROL_CONN(connection_t *);
|
control_connection_t *TO_CONTROL_CONN(connection_t *);
|
||||||
|
const control_connection_t *CONST_TO_CONTROL_CONN(const connection_t *);
|
||||||
|
|
||||||
#define CONTROL_CONN_STATE_MIN_ 1
|
#define CONTROL_CONN_STATE_MIN_ 1
|
||||||
/** State for a control connection: Authenticated and accepting v1 commands. */
|
/** State for a control connection: Authenticated and accepting v1 commands. */
|
||||||
|
@ -92,6 +92,18 @@ TO_DIR_CONN(connection_t *c)
|
|||||||
return DOWNCAST(dir_connection_t, c);
|
return DOWNCAST(dir_connection_t, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cast a `const connection_t *` to a `const dir_connection_t *`.
|
||||||
|
*
|
||||||
|
* Exit with an assertion failure if the input is not a
|
||||||
|
* `dir_connection_t`.
|
||||||
|
**/
|
||||||
|
const dir_connection_t *
|
||||||
|
CONST_TO_DIR_CONN(const connection_t *c)
|
||||||
|
{
|
||||||
|
return TO_DIR_CONN((connection_t *)c);
|
||||||
|
}
|
||||||
|
|
||||||
/** Return false if the directory purpose <b>dir_purpose</b>
|
/** Return false if the directory purpose <b>dir_purpose</b>
|
||||||
* does not require an anonymous (three-hop) connection.
|
* does not require an anonymous (three-hop) connection.
|
||||||
*
|
*
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define TOR_DIRECTORY_H
|
#define TOR_DIRECTORY_H
|
||||||
|
|
||||||
dir_connection_t *TO_DIR_CONN(connection_t *c);
|
dir_connection_t *TO_DIR_CONN(connection_t *c);
|
||||||
|
const dir_connection_t *CONST_TO_DIR_CONN(const connection_t *c);
|
||||||
|
|
||||||
#define DIR_CONN_STATE_MIN_ 1
|
#define DIR_CONN_STATE_MIN_ 1
|
||||||
/** State for connection to directory server: waiting for connect(). */
|
/** State for connection to directory server: waiting for connect(). */
|
||||||
|
Loading…
Reference in New Issue
Block a user