* Initialize conn's timestamps to now.
*/
connection_t *connection_new(int type) {
+ static uint32_t n_connections_allocated = 0;
connection_t *conn;
time_t now = time(NULL);
conn->magic = CONNECTION_MAGIC;
conn->s = -1; /* give it a default of 'not used' */
conn->poll_index = -1; /* also default to 'not used' */
+ conn->global_identifier = n_connections_allocated++;
conn->type = type;
if (!connection_is_listener(conn)) { /* listeners never use their buf */
len = strlen(buf);
msg = tor_malloc(5+len+1);
msg[0] = (uint8_t) tp;
- set_uint32(msg+1, htonl(conn->s)); /* ???? Is this a security problem? */
+ set_uint32(msg+1, htonl(conn->global_identifier));
strlcpy(msg+5, buf, len+1);
send_control_event(EVENT_STREAM_STATUS, (uint16_t)(5+len+1), msg);
socks_request_t *socks_request; /**< SOCKS structure describing request (AP
* only.) */
+ /** Quasi-global identifier for this connection; used for control.c */
+ /* XXXX NM This can get re-used after 2**32 circuits. */
+ uint32_t global_identifier;
+
/* Used only by control connections */
uint32_t event_mask;
};
struct circuit_t *rend_splice;
/** Quasi-global identifier for this circuit; used for control.c */
- /* XXXX009 NM This can get re-used after 2**32 circuits. */
+ /* XXXX NM This can get re-used after 2**32 circuits. */
uint32_t global_identifier;
struct circuit_t *next; /**< Next circuit in linked list. */