tor  0.4.2.0-alpha-dev
connection_st.h
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 #ifndef CONNECTION_ST_H
8 #define CONNECTION_ST_H
9 
10 struct buf_t;
11 
12 /* Values for connection_t.magic: used to make sure that downcasts (casts from
13 * connection_t to foo_connection_t) are safe. */
14 #define BASE_CONNECTION_MAGIC 0x7C3C304Eu
15 #define OR_CONNECTION_MAGIC 0x7D31FF03u
16 #define EDGE_CONNECTION_MAGIC 0xF0374013u
17 #define ENTRY_CONNECTION_MAGIC 0xbb4a5703
18 #define DIR_CONNECTION_MAGIC 0x9988ffeeu
19 #define CONTROL_CONNECTION_MAGIC 0x8abc765du
20 #define LISTENER_CONNECTION_MAGIC 0x1a1ac741u
21 
40 struct connection_t {
41  uint32_t magic;
44  uint8_t state;
45  unsigned int type:5;
46  unsigned int purpose:5;
48  /* The next fields are all one-bit booleans. Some are only applicable to
49  * connection subtypes, but we hold them here anyway, to save space.
50  */
51  unsigned int read_blocked_on_bw:1;
53  unsigned int write_blocked_on_bw:1;
56  unsigned int hold_open_until_flushed:1;
59  unsigned int inbuf_reached_eof:1;
63  unsigned int in_flushed_some:1;
67 
68  /* For linked connections:
69  */
70  unsigned int linked:1;
73  unsigned int reading_from_linked_conn:1;
75  unsigned int writing_to_linked_conn:1;
78  unsigned int active_on_link:1;
81  unsigned int linked_conn_is_closed:1;
82 
84  unsigned int proxy_state:4;
85 
91  struct event *read_event;
92  struct event *write_event;
93  struct buf_t *inbuf;
94  struct buf_t *outbuf;
96  size_t outbuf_flushlen;
111  uint16_t port;
114  uint16_t marked_for_close;
118  const char *marked_for_close_file;
120  char *address;
128 
131 
134  uint32_t n_read_conn_bw;
135 
139 };
140 
142 #define CONN_IS_EDGE(x) \
143  ((x)->type == CONN_TYPE_EXIT || (x)->type == CONN_TYPE_AP)
144 
147 #define DIR_CONN_IS_SERVER(conn) ((conn)->purpose == DIR_PURPOSE_SERVER)
148 
149 #endif /* !defined(CONNECTION_ST_H) */
tor_socket_t s
Definition: connection_st.h:88
uint64_t global_identifier
tor_addr_t addr
unsigned int write_blocked_on_bw
Definition: connection_st.h:53
uint32_t n_written_conn_bw
unsigned int proxy_state
Definition: connection_st.h:84
uint8_t state
Definition: connection_st.h:44
unsigned int inbuf_reached_eof
Definition: connection_st.h:59
unsigned int read_blocked_on_bw
Definition: connection_st.h:51
struct connection_t * linked_conn
unsigned int writing_to_linked_conn
Definition: connection_st.h:75
unsigned int reading_from_linked_conn
Definition: connection_st.h:73
uint16_t port
unsigned int purpose
Definition: connection_st.h:46
size_t outbuf_flushlen
Definition: connection_st.h:96
unsigned int linked
Definition: connection_st.h:70
unsigned int active_on_link
Definition: connection_st.h:78
struct buf_t * inbuf
Definition: connection_st.h:93
int conn_array_index
Definition: connection_st.h:89
uint16_t marked_for_close
unsigned int type
Definition: connection_st.h:45
#define tor_socket_t
Definition: nettypes.h:36
struct buf_t * outbuf
Definition: connection_st.h:94
struct event * write_event
Definition: connection_st.h:92
time_t timestamp_last_read_allowed
Definition: connection_st.h:98
unsigned int linked_conn_is_closed
Definition: connection_st.h:81
struct event * read_event
Definition: connection_st.h:91
unsigned int in_connection_handle_write
Definition: connection_st.h:66
unsigned int hold_open_until_flushed
Definition: connection_st.h:56
uint32_t magic
Definition: connection_st.h:41
const char * marked_for_close_file
time_t timestamp_created
uint32_t n_read_conn_bw
unsigned int in_flushed_some
Definition: connection_st.h:63
time_t timestamp_last_write_allowed