comparison src/stream/ngx_stream.h @ 6607:c70b7f4537e1

Stream: variables and script. This is a port of corresponding http code with unrelated features excluded.
author Vladimir Homutov <vl@nginx.com>
date Mon, 04 Jul 2016 16:37:36 +0300
parents 2f41d383c9c7
children 070c31a482e6
comparison
equal deleted inserted replaced
6606:2f41d383c9c7 6607:c70b7f4537e1
18 18
19 19
20 typedef struct ngx_stream_session_s ngx_stream_session_t; 20 typedef struct ngx_stream_session_s ngx_stream_session_t;
21 21
22 22
23 #include <ngx_stream_variables.h>
24 #include <ngx_stream_script.h>
23 #include <ngx_stream_upstream.h> 25 #include <ngx_stream_upstream.h>
24 #include <ngx_stream_upstream_round_robin.h> 26 #include <ngx_stream_upstream_round_robin.h>
25 27
26 28
27 typedef struct { 29 typedef struct {
28 void **main_conf; 30 void **main_conf;
29 void **srv_conf; 31 void **srv_conf;
30 } ngx_stream_conf_ctx_t; 32 } ngx_stream_conf_ctx_t;
31 33
32 34
33 typedef struct { 35 typedef struct {
34 ngx_sockaddr_t sockaddr; 36 ngx_sockaddr_t sockaddr;
35 socklen_t socklen; 37 socklen_t socklen;
36 38
37 /* server ctx */ 39 /* server ctx */
38 ngx_stream_conf_ctx_t *ctx; 40 ngx_stream_conf_ctx_t *ctx;
39 41
40 unsigned bind:1; 42 unsigned bind:1;
41 unsigned wildcard:1; 43 unsigned wildcard:1;
42 #if (NGX_STREAM_SSL) 44 #if (NGX_STREAM_SSL)
43 unsigned ssl:1; 45 unsigned ssl:1;
44 #endif 46 #endif
45 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) 47 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
46 unsigned ipv6only:1; 48 unsigned ipv6only:1;
47 #endif 49 #endif
48 #if (NGX_HAVE_REUSEPORT) 50 #if (NGX_HAVE_REUSEPORT)
49 unsigned reuseport:1; 51 unsigned reuseport:1;
50 #endif 52 #endif
51 unsigned so_keepalive:2; 53 unsigned so_keepalive:2;
52 #if (NGX_HAVE_KEEPALIVE_TUNABLE) 54 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
53 int tcp_keepidle; 55 int tcp_keepidle;
54 int tcp_keepintvl; 56 int tcp_keepintvl;
55 int tcp_keepcnt; 57 int tcp_keepcnt;
56 #endif 58 #endif
57 int backlog; 59 int backlog;
58 int type; 60 int type;
59 } ngx_stream_listen_t; 61 } ngx_stream_listen_t;
60 62
61 63
62 typedef struct { 64 typedef struct {
63 ngx_stream_conf_ctx_t *ctx; 65 ngx_stream_conf_ctx_t *ctx;
64 ngx_str_t addr_text; 66 ngx_str_t addr_text;
65 #if (NGX_STREAM_SSL) 67 #if (NGX_STREAM_SSL)
66 ngx_uint_t ssl; /* unsigned ssl:1; */ 68 ngx_uint_t ssl; /* unsigned ssl:1; */
67 #endif 69 #endif
68 } ngx_stream_addr_conf_t; 70 } ngx_stream_addr_conf_t;
69 71
70 typedef struct { 72 typedef struct {
71 in_addr_t addr; 73 in_addr_t addr;
72 ngx_stream_addr_conf_t conf; 74 ngx_stream_addr_conf_t conf;
73 } ngx_stream_in_addr_t; 75 } ngx_stream_in_addr_t;
74 76
75 77
76 #if (NGX_HAVE_INET6) 78 #if (NGX_HAVE_INET6)
77 79
78 typedef struct { 80 typedef struct {
79 struct in6_addr addr6; 81 struct in6_addr addr6;
80 ngx_stream_addr_conf_t conf; 82 ngx_stream_addr_conf_t conf;
81 } ngx_stream_in6_addr_t; 83 } ngx_stream_in6_addr_t;
82 84
83 #endif 85 #endif
84 86
85 87
86 typedef struct { 88 typedef struct {
87 /* ngx_stream_in_addr_t or ngx_stream_in6_addr_t */ 89 /* ngx_stream_in_addr_t or ngx_stream_in6_addr_t */
88 void *addrs; 90 void *addrs;
89 ngx_uint_t naddrs; 91 ngx_uint_t naddrs;
90 } ngx_stream_port_t; 92 } ngx_stream_port_t;
91 93
92 94
93 typedef struct { 95 typedef struct {
94 int family; 96 int family;
95 int type; 97 int type;
96 in_port_t port; 98 in_port_t port;
97 ngx_array_t addrs; /* array of ngx_stream_conf_addr_t */ 99 ngx_array_t addrs; /* array of ngx_stream_conf_addr_t */
98 } ngx_stream_conf_port_t; 100 } ngx_stream_conf_port_t;
99 101
100 102
101 typedef struct { 103 typedef struct {
102 ngx_stream_listen_t opt; 104 ngx_stream_listen_t opt;
103 } ngx_stream_conf_addr_t; 105 } ngx_stream_conf_addr_t;
104 106
105 107
106 typedef ngx_int_t (*ngx_stream_access_pt)(ngx_stream_session_t *s); 108 typedef ngx_int_t (*ngx_stream_access_pt)(ngx_stream_session_t *s);
107 109
108 110
109 typedef struct { 111 typedef struct {
110 ngx_array_t servers; /* ngx_stream_core_srv_conf_t */ 112 ngx_array_t servers; /* ngx_stream_core_srv_conf_t */
111 ngx_array_t listen; /* ngx_stream_listen_t */ 113 ngx_array_t listen; /* ngx_stream_listen_t */
112 ngx_stream_access_pt limit_conn_handler; 114
113 ngx_stream_access_pt access_handler; 115 ngx_stream_access_pt limit_conn_handler;
116 ngx_stream_access_pt access_handler;
117
118 ngx_hash_t variables_hash;
119
120 ngx_array_t variables; /* ngx_stream_variable_t */
121 ngx_uint_t ncaptures;
122
123 ngx_uint_t variables_hash_max_size;
124 ngx_uint_t variables_hash_bucket_size;
125
126 ngx_hash_keys_arrays_t *variables_keys;
114 } ngx_stream_core_main_conf_t; 127 } ngx_stream_core_main_conf_t;
115 128
116 129
117 typedef void (*ngx_stream_handler_pt)(ngx_stream_session_t *s); 130 typedef void (*ngx_stream_handler_pt)(ngx_stream_session_t *s);
118 131
119 132
120 typedef struct { 133 typedef struct {
121 ngx_stream_handler_pt handler; 134 ngx_stream_handler_pt handler;
122 ngx_stream_conf_ctx_t *ctx; 135
123 u_char *file_name; 136 ngx_stream_conf_ctx_t *ctx;
124 ngx_int_t line; 137
125 ngx_log_t *error_log; 138 u_char *file_name;
126 ngx_flag_t tcp_nodelay; 139 ngx_int_t line;
140
141 ngx_flag_t tcp_nodelay;
142
143 ngx_log_t *error_log;
127 } ngx_stream_core_srv_conf_t; 144 } ngx_stream_core_srv_conf_t;
128 145
129 146
130 struct ngx_stream_session_s { 147 struct ngx_stream_session_s {
131 uint32_t signature; /* "STRM" */ 148 uint32_t signature; /* "STRM" */
132 149
133 ngx_connection_t *connection; 150 ngx_connection_t *connection;
134 151
135 off_t received; 152 off_t received;
136 153
137 ngx_log_handler_pt log_handler; 154 ngx_log_handler_pt log_handler;
138 155
139 void **ctx; 156 void **ctx;
140 void **main_conf; 157 void **main_conf;
141 void **srv_conf; 158 void **srv_conf;
142 159
143 ngx_stream_upstream_t *upstream; 160 ngx_stream_upstream_t *upstream;
161
162 ngx_stream_variable_value_t *variables;
163
164 #if (NGX_PCRE)
165 ngx_uint_t ncaptures;
166 int *captures;
167 u_char *captures_data;
168 #endif
144 }; 169 };
145 170
146 171
147 typedef struct { 172 typedef struct {
148 ngx_int_t (*preconfiguration)(ngx_conf_t *cf); 173 ngx_int_t (*preconfiguration)(ngx_conf_t *cf);
149 ngx_int_t (*postconfiguration)(ngx_conf_t *cf); 174 ngx_int_t (*postconfiguration)(ngx_conf_t *cf);
150 175
151 void *(*create_main_conf)(ngx_conf_t *cf); 176 void *(*create_main_conf)(ngx_conf_t *cf);
152 char *(*init_main_conf)(ngx_conf_t *cf, void *conf); 177 char *(*init_main_conf)(ngx_conf_t *cf, void *conf);
153 178
154 void *(*create_srv_conf)(ngx_conf_t *cf); 179 void *(*create_srv_conf)(ngx_conf_t *cf);
155 char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, 180 char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev,
156 void *conf); 181 void *conf);
157 } ngx_stream_module_t; 182 } ngx_stream_module_t;
158 183
159 184
160 #define NGX_STREAM_MODULE 0x4d525453 /* "STRM" */ 185 #define NGX_STREAM_MODULE 0x4d525453 /* "STRM" */
161 186