mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-20 10:12:15 +01:00
r13328@catbus: nickm | 2007-06-08 17:14:55 -0400
Arg. Irix apparently #defines sa_family to something. Thus, naming fields or variables "sa_family" will not work. svn:r10541
This commit is contained in:
parent
1d6db7ec3d
commit
19389a3674
@ -157,7 +157,7 @@ conn_state_to_string(int type, int state)
|
|||||||
* Initialize conn's timestamps to now.
|
* Initialize conn's timestamps to now.
|
||||||
*/
|
*/
|
||||||
connection_t *
|
connection_t *
|
||||||
connection_new(int type, int sa_family)
|
connection_new(int type, int socket_family)
|
||||||
{
|
{
|
||||||
static uint32_t n_connections_allocated = 1;
|
static uint32_t n_connections_allocated = 1;
|
||||||
connection_t *conn;
|
connection_t *conn;
|
||||||
@ -195,7 +195,7 @@ connection_new(int type, int sa_family)
|
|||||||
conn->conn_array_index = -1; /* also default to 'not used' */
|
conn->conn_array_index = -1; /* also default to 'not used' */
|
||||||
|
|
||||||
conn->type = type;
|
conn->type = type;
|
||||||
conn->sa_family = sa_family;
|
conn->socket_family = socket_family;
|
||||||
if (!connection_is_listener(conn)) { /* listeners never use their buf */
|
if (!connection_is_listener(conn)) { /* listeners never use their buf */
|
||||||
conn->inbuf = buf_new();
|
conn->inbuf = buf_new();
|
||||||
conn->outbuf = buf_new();
|
conn->outbuf = buf_new();
|
||||||
@ -296,7 +296,7 @@ _connection_free(connection_t *conn)
|
|||||||
buf_free(conn->inbuf);
|
buf_free(conn->inbuf);
|
||||||
buf_free(conn->outbuf);
|
buf_free(conn->outbuf);
|
||||||
} else {
|
} else {
|
||||||
if (conn->sa_family == AF_UNIX) {
|
if (conn->socket_family == AF_UNIX) {
|
||||||
/* For now only control ports can be unix domain sockets
|
/* For now only control ports can be unix domain sockets
|
||||||
* and listeners at the same time */
|
* and listeners at the same time */
|
||||||
tor_assert(conn->type == CONN_TYPE_CONTROL_LISTENER);
|
tor_assert(conn->type == CONN_TYPE_CONTROL_LISTENER);
|
||||||
@ -830,7 +830,7 @@ connection_create_listener(struct sockaddr *listensockaddr, int type,
|
|||||||
set_socket_nonblocking(s);
|
set_socket_nonblocking(s);
|
||||||
|
|
||||||
conn = connection_new(type, listensockaddr->sa_family);
|
conn = connection_new(type, listensockaddr->sa_family);
|
||||||
conn->sa_family = listensockaddr->sa_family;
|
conn->socket_family = listensockaddr->sa_family;
|
||||||
conn->s = s;
|
conn->s = s;
|
||||||
conn->address = tor_strdup(address);
|
conn->address = tor_strdup(address);
|
||||||
conn->port = usePort;
|
conn->port = usePort;
|
||||||
@ -923,9 +923,9 @@ connection_handle_listener_read(connection_t *conn, int new_type)
|
|||||||
|
|
||||||
set_socket_nonblocking(news);
|
set_socket_nonblocking(news);
|
||||||
|
|
||||||
tor_assert(((struct sockaddr*)addrbuf)->sa_family == conn->sa_family);
|
tor_assert(((struct sockaddr*)addrbuf)->sa_family == conn->socket_family);
|
||||||
|
|
||||||
if (conn->sa_family == AF_INET) {
|
if (conn->socket_family == AF_INET) {
|
||||||
if (check_sockaddr_in((struct sockaddr*)addrbuf, remotelen, LOG_INFO)<0) {
|
if (check_sockaddr_in((struct sockaddr*)addrbuf, remotelen, LOG_INFO)<0) {
|
||||||
log_info(LD_NET,
|
log_info(LD_NET,
|
||||||
"accept() returned a strange address; trying getsockname().");
|
"accept() returned a strange address; trying getsockname().");
|
||||||
@ -969,7 +969,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newconn = connection_new(new_type, conn->sa_family);
|
newconn = connection_new(new_type, conn->socket_family);
|
||||||
newconn->s = news;
|
newconn->s = news;
|
||||||
|
|
||||||
/* remember the remote address */
|
/* remember the remote address */
|
||||||
@ -977,12 +977,12 @@ connection_handle_listener_read(connection_t *conn, int new_type)
|
|||||||
newconn->port = ntohs(remote.sin_port);
|
newconn->port = ntohs(remote.sin_port);
|
||||||
newconn->address = tor_dup_addr(newconn->addr);
|
newconn->address = tor_dup_addr(newconn->addr);
|
||||||
|
|
||||||
} else if (conn->sa_family == AF_UNIX) {
|
} else if (conn->socket_family == AF_UNIX) {
|
||||||
/* For now only control ports can be unix domain sockets
|
/* For now only control ports can be unix domain sockets
|
||||||
* and listeners at the same time */
|
* and listeners at the same time */
|
||||||
tor_assert(conn->type == CONN_TYPE_CONTROL_LISTENER);
|
tor_assert(conn->type == CONN_TYPE_CONTROL_LISTENER);
|
||||||
|
|
||||||
newconn = connection_new(new_type, conn->sa_family);
|
newconn = connection_new(new_type, conn->socket_family);
|
||||||
newconn->s = news;
|
newconn->s = news;
|
||||||
|
|
||||||
/* remember the remote address -- do we have anything sane to put here? */
|
/* remember the remote address -- do we have anything sane to put here? */
|
||||||
@ -1150,7 +1150,7 @@ retry_listeners(int type, config_line_t *cfg,
|
|||||||
smartlist_t *replaced_conns,
|
smartlist_t *replaced_conns,
|
||||||
smartlist_t *new_conns,
|
smartlist_t *new_conns,
|
||||||
int never_open_conns,
|
int never_open_conns,
|
||||||
int sa_family)
|
int socket_family)
|
||||||
{
|
{
|
||||||
smartlist_t *launch = smartlist_create(), *conns;
|
smartlist_t *launch = smartlist_create(), *conns;
|
||||||
int free_launch_elts = 1;
|
int free_launch_elts = 1;
|
||||||
@ -1159,7 +1159,7 @@ retry_listeners(int type, config_line_t *cfg,
|
|||||||
connection_t *conn;
|
connection_t *conn;
|
||||||
config_line_t *line;
|
config_line_t *line;
|
||||||
|
|
||||||
tor_assert(sa_family == AF_INET || sa_family == AF_UNIX);
|
tor_assert(socket_family == AF_INET || socket_family == AF_UNIX);
|
||||||
|
|
||||||
if (cfg && port_option) {
|
if (cfg && port_option) {
|
||||||
for (c = cfg; c; c = c->next) {
|
for (c = cfg; c; c = c->next) {
|
||||||
@ -1182,7 +1182,7 @@ retry_listeners(int type, config_line_t *cfg,
|
|||||||
SMARTLIST_FOREACH(conns, connection_t *, conn,
|
SMARTLIST_FOREACH(conns, connection_t *, conn,
|
||||||
{
|
{
|
||||||
if (conn->type != type ||
|
if (conn->type != type ||
|
||||||
conn->sa_family != sa_family ||
|
conn->socket_family != socket_family ||
|
||||||
conn->marked_for_close)
|
conn->marked_for_close)
|
||||||
continue;
|
continue;
|
||||||
/* Okay, so this is a listener. Is it configured? */
|
/* Okay, so this is a listener. Is it configured? */
|
||||||
@ -1191,7 +1191,7 @@ retry_listeners(int type, config_line_t *cfg,
|
|||||||
{
|
{
|
||||||
char *address=NULL;
|
char *address=NULL;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
switch (sa_family) {
|
switch (socket_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
if (!parse_addr_port(LOG_WARN,
|
if (!parse_addr_port(LOG_WARN,
|
||||||
wanted->value, &address, NULL, &port)) {
|
wanted->value, &address, NULL, &port)) {
|
||||||
@ -1243,7 +1243,7 @@ retry_listeners(int type, config_line_t *cfg,
|
|||||||
char *address = NULL;
|
char *address = NULL;
|
||||||
struct sockaddr *listensockaddr;
|
struct sockaddr *listensockaddr;
|
||||||
|
|
||||||
switch (sa_family) {
|
switch (socket_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
listensockaddr = (struct sockaddr *)
|
listensockaddr = (struct sockaddr *)
|
||||||
create_inet_sockaddr(cfg_line->value,
|
create_inet_sockaddr(cfg_line->value,
|
||||||
|
@ -786,9 +786,9 @@ typedef struct connection_t {
|
|||||||
time_t timestamp_created; /**< When was this connection_t created? */
|
time_t timestamp_created; /**< When was this connection_t created? */
|
||||||
|
|
||||||
/* XXXX020 make this ipv6-capable */
|
/* XXXX020 make this ipv6-capable */
|
||||||
int sa_family; /**< Address family of this connection's socket. Usually
|
int socket_family; /**< Address family of this connection's socket. Usually
|
||||||
* AF_INET, but it can also be AF_UNIX, or in the future
|
* AF_INET, but it can also be AF_UNIX, or in the future
|
||||||
* AF_INET6 */
|
* AF_INET6 */
|
||||||
uint32_t addr; /**< IP of the other side of the connection; used to identify
|
uint32_t addr; /**< IP of the other side of the connection; used to identify
|
||||||
* routers, along with port. */
|
* routers, along with port. */
|
||||||
uint16_t port; /**< If non-zero, port on the other end
|
uint16_t port; /**< If non-zero, port on the other end
|
||||||
@ -2347,7 +2347,7 @@ or_options_t *options_new(void);
|
|||||||
const char *conn_type_to_string(int type);
|
const char *conn_type_to_string(int type);
|
||||||
const char *conn_state_to_string(int type, int state);
|
const char *conn_state_to_string(int type, int state);
|
||||||
|
|
||||||
connection_t *connection_new(int type, int sa_family);
|
connection_t *connection_new(int type, int socket_family);
|
||||||
void connection_link_connections(connection_t *conn_a, connection_t *conn_b);
|
void connection_link_connections(connection_t *conn_a, connection_t *conn_b);
|
||||||
void connection_unregister_events(connection_t *conn);
|
void connection_unregister_events(connection_t *conn);
|
||||||
void connection_free(connection_t *conn);
|
void connection_free(connection_t *conn);
|
||||||
|
Loading…
Reference in New Issue
Block a user