blob: a02a869660518cbd5ab7950d02ff24b728b5a02b [file] [log] [blame]
Willy Tarreaud4c33c82013-01-07 21:59:07 +01001/*
2 * General protocol-agnostic payload-based sample fetches and ACLs
3 *
4 * Copyright 2000-2013 Willy Tarreau <w@1wt.eu>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#include <stdlib.h>
14#include <string.h>
15
16#include <proto/acl.h>
17#include <proto/arg.h>
18#include <proto/channel.h>
Thierry FOURNIERed66c292013-11-28 11:05:19 +010019#include <proto/pattern.h>
Willy Tarreaud4c33c82013-01-07 21:59:07 +010020#include <proto/payload.h>
21#include <proto/sample.h>
22
23
24/************************************************************************/
25/* All supported sample fetch functions must be declared here */
26/************************************************************************/
27
28/* wait for more data as long as possible, then return TRUE. This should be
29 * used with content inspection.
30 */
31static int
Thierry FOURNIER0786d052015-05-11 15:42:45 +020032smp_fetch_wait_end(const struct arg *args, struct sample *smp, const char *kw, void *private)
Willy Tarreaud4c33c82013-01-07 21:59:07 +010033{
Thierry FOURNIER0786d052015-05-11 15:42:45 +020034 if (!(smp->opt & SMP_OPT_FINAL)) {
Willy Tarreaud4c33c82013-01-07 21:59:07 +010035 smp->flags |= SMP_F_MAY_CHANGE;
36 return 0;
37 }
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +020038 smp->data.type = SMP_T_BOOL;
Thierry FOURNIER136f9d32015-08-19 09:07:19 +020039 smp->data.u.sint = 1;
Willy Tarreaud4c33c82013-01-07 21:59:07 +010040 return 1;
41}
42
43/* return the number of bytes in the request buffer */
44static int
Thierry FOURNIER0786d052015-05-11 15:42:45 +020045smp_fetch_len(const struct arg *args, struct sample *smp, const char *kw, void *private)
Willy Tarreaud4c33c82013-01-07 21:59:07 +010046{
Willy Tarreau22ec1ea2014-11-27 20:45:39 +010047 struct channel *chn;
48
Willy Tarreaube508f12016-03-10 11:47:01 +010049 if (!smp->strm)
50 return 0;
51
Thierry FOURNIER0786d052015-05-11 15:42:45 +020052 chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +020053 smp->data.type = SMP_T_SINT;
Thierry FOURNIER136f9d32015-08-19 09:07:19 +020054 smp->data.u.sint = chn->buf->i;
Willy Tarreaud4c33c82013-01-07 21:59:07 +010055 smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE;
56 return 1;
57}
58
Pradeep Jindalbb2acf52015-09-29 10:12:57 +053059/* Returns 0 if the client didn't send a SessionTicket Extension
60 * Returns 1 if the client sent SessionTicket Extension
61 * Returns 2 if the client also sent non-zero length SessionTicket
62 * Returns SMP_T_SINT data type
63 */
64static int
65smp_fetch_req_ssl_st_ext(const struct arg *args, struct sample *smp, const char *kw, void *private)
66{
67 int hs_len, ext_len, bleft;
68 struct channel *chn;
69 unsigned char *data;
70
Willy Tarreaube508f12016-03-10 11:47:01 +010071 if (!smp->strm)
72 goto not_ssl_hello;
73
Pradeep Jindalbb2acf52015-09-29 10:12:57 +053074 chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
Pradeep Jindalbb2acf52015-09-29 10:12:57 +053075 bleft = chn->buf->i;
76 data = (unsigned char *)chn->buf->p;
77
78 /* Check for SSL/TLS Handshake */
79 if (!bleft)
80 goto too_short;
81 if (*data != 0x16)
82 goto not_ssl_hello;
83
84 /* Check for SSLv3 or later (SSL version >= 3.0) in the record layer*/
85 if (bleft < 3)
86 goto too_short;
87 if (data[1] < 0x03)
88 goto not_ssl_hello;
89
90 if (bleft < 5)
91 goto too_short;
92 hs_len = (data[3] << 8) + data[4];
93 if (hs_len < 1 + 3 + 2 + 32 + 1 + 2 + 2 + 1 + 1 + 2 + 2)
94 goto not_ssl_hello; /* too short to have an extension */
95
96 data += 5; /* enter TLS handshake */
97 bleft -= 5;
98
99 /* Check for a complete client hello starting at <data> */
100 if (bleft < 1)
101 goto too_short;
102 if (data[0] != 0x01) /* msg_type = Client Hello */
103 goto not_ssl_hello;
104
105 /* Check the Hello's length */
106 if (bleft < 4)
107 goto too_short;
108 hs_len = (data[1] << 16) + (data[2] << 8) + data[3];
109 if (hs_len < 2 + 32 + 1 + 2 + 2 + 1 + 1 + 2 + 2)
110 goto not_ssl_hello; /* too short to have an extension */
111
112 /* We want the full handshake here */
113 if (bleft < hs_len)
114 goto too_short;
115
116 data += 4;
117 /* Start of the ClientHello message */
118 if (data[0] < 0x03 || data[1] < 0x01) /* TLSv1 minimum */
119 goto not_ssl_hello;
120
121 ext_len = data[34]; /* session_id_len */
122 if (ext_len > 32 || ext_len > (hs_len - 35)) /* check for correct session_id len */
123 goto not_ssl_hello;
124
125 /* Jump to cipher suite */
126 hs_len -= 35 + ext_len;
127 data += 35 + ext_len;
128
129 if (hs_len < 4 || /* minimum one cipher */
130 (ext_len = (data[0] << 8) + data[1]) < 2 || /* minimum 2 bytes for a cipher */
131 ext_len > hs_len)
132 goto not_ssl_hello;
133
134 /* Jump to the compression methods */
135 hs_len -= 2 + ext_len;
136 data += 2 + ext_len;
137
138 if (hs_len < 2 || /* minimum one compression method */
139 data[0] < 1 || data[0] > hs_len) /* minimum 1 bytes for a method */
140 goto not_ssl_hello;
141
142 /* Jump to the extensions */
143 hs_len -= 1 + data[0];
144 data += 1 + data[0];
145
146 if (hs_len < 2 || /* minimum one extension list length */
147 (ext_len = (data[0] << 8) + data[1]) > hs_len - 2) /* list too long */
148 goto not_ssl_hello;
149
150 hs_len = ext_len; /* limit ourselves to the extension length */
151 data += 2;
152
153 while (hs_len >= 4) {
154 int ext_type, ext_len;
155
156 ext_type = (data[0] << 8) + data[1];
157 ext_len = (data[2] << 8) + data[3];
158
159 if (ext_len > hs_len - 4) /* Extension too long */
160 goto not_ssl_hello;
161
162 /* SesstionTicket extension */
163 if (ext_type == 35) {
164 smp->data.type = SMP_T_SINT;
165 /* SessionTicket also present */
166 if (ext_len > 0)
167 smp->data.u.sint = 2;
168 /* SessionTicket absent */
169 else
170 smp->data.u.sint = 1;
171 smp->flags = SMP_F_VOLATILE;
172 return 1;
173 }
174
175 hs_len -= 4 + ext_len;
176 data += 4 + ext_len;
177 }
178 /* SessionTicket Extension not found */
179 smp->data.type = SMP_T_SINT;
180 smp->data.u.sint = 0;
181 smp->flags = SMP_F_VOLATILE;
182 return 1;
183
Pradeep Jindalbb2acf52015-09-29 10:12:57 +0530184 too_short:
185 smp->flags = SMP_F_MAY_CHANGE;
186
187 not_ssl_hello:
188 return 0;
189}
190
Nenad Merdanovic5fc7d7e2015-07-07 22:00:17 +0200191/* Returns TRUE if the client sent Supported Elliptic Curves Extension (0x000a)
192 * Mainly used to detect if client supports ECC cipher suites.
193 */
194static int
195smp_fetch_req_ssl_ec_ext(const struct arg *args, struct sample *smp, const char *kw, void *private)
196{
197 int hs_len, ext_len, bleft;
198 struct channel *chn;
199 unsigned char *data;
200
Willy Tarreaube508f12016-03-10 11:47:01 +0100201 if (!smp->strm)
202 goto not_ssl_hello;
203
Nenad Merdanovic5fc7d7e2015-07-07 22:00:17 +0200204 chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
Nenad Merdanovic5fc7d7e2015-07-07 22:00:17 +0200205 bleft = chn->buf->i;
206 data = (unsigned char *)chn->buf->p;
207
208 /* Check for SSL/TLS Handshake */
209 if (!bleft)
210 goto too_short;
211 if (*data != 0x16)
212 goto not_ssl_hello;
213
214 /* Check for SSLv3 or later (SSL version >= 3.0) in the record layer*/
215 if (bleft < 3)
216 goto too_short;
217 if (data[1] < 0x03)
218 goto not_ssl_hello;
219
220 if (bleft < 5)
221 goto too_short;
222 hs_len = (data[3] << 8) + data[4];
223 if (hs_len < 1 + 3 + 2 + 32 + 1 + 2 + 2 + 1 + 1 + 2 + 2)
224 goto not_ssl_hello; /* too short to have an extension */
225
226 data += 5; /* enter TLS handshake */
227 bleft -= 5;
228
229 /* Check for a complete client hello starting at <data> */
230 if (bleft < 1)
231 goto too_short;
232 if (data[0] != 0x01) /* msg_type = Client Hello */
233 goto not_ssl_hello;
234
235 /* Check the Hello's length */
236 if (bleft < 4)
237 goto too_short;
238 hs_len = (data[1] << 16) + (data[2] << 8) + data[3];
239 if (hs_len < 2 + 32 + 1 + 2 + 2 + 1 + 1 + 2 + 2)
240 goto not_ssl_hello; /* too short to have an extension */
241
242 /* We want the full handshake here */
243 if (bleft < hs_len)
244 goto too_short;
245
246 data += 4;
247 /* Start of the ClientHello message */
248 if (data[0] < 0x03 || data[1] < 0x01) /* TLSv1 minimum */
249 goto not_ssl_hello;
250
251 ext_len = data[34]; /* session_id_len */
252 if (ext_len > 32 || ext_len > (hs_len - 35)) /* check for correct session_id len */
253 goto not_ssl_hello;
254
255 /* Jump to cipher suite */
256 hs_len -= 35 + ext_len;
257 data += 35 + ext_len;
258
259 if (hs_len < 4 || /* minimum one cipher */
260 (ext_len = (data[0] << 8) + data[1]) < 2 || /* minimum 2 bytes for a cipher */
261 ext_len > hs_len)
262 goto not_ssl_hello;
263
264 /* Jump to the compression methods */
265 hs_len -= 2 + ext_len;
266 data += 2 + ext_len;
267
268 if (hs_len < 2 || /* minimum one compression method */
269 data[0] < 1 || data[0] > hs_len) /* minimum 1 bytes for a method */
270 goto not_ssl_hello;
271
272 /* Jump to the extensions */
273 hs_len -= 1 + data[0];
274 data += 1 + data[0];
275
276 if (hs_len < 2 || /* minimum one extension list length */
277 (ext_len = (data[0] << 8) + data[1]) > hs_len - 2) /* list too long */
278 goto not_ssl_hello;
279
280 hs_len = ext_len; /* limit ourselves to the extension length */
281 data += 2;
282
283 while (hs_len >= 4) {
284 int ext_type, ext_len;
285
286 ext_type = (data[0] << 8) + data[1];
287 ext_len = (data[2] << 8) + data[3];
288
289 if (ext_len > hs_len - 4) /* Extension too long */
290 goto not_ssl_hello;
291
292 /* Elliptic curves extension */
293 if (ext_type == 10) {
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +0200294 smp->data.type = SMP_T_BOOL;
Thierry FOURNIER136f9d32015-08-19 09:07:19 +0200295 smp->data.u.sint = 1;
Nenad Merdanovic8a39a1f2015-07-15 12:51:11 +0200296 smp->flags = SMP_F_VOLATILE;
Nenad Merdanovic5fc7d7e2015-07-07 22:00:17 +0200297 return 1;
298 }
299
300 hs_len -= 4 + ext_len;
301 data += 4 + ext_len;
302 }
303 /* server name not found */
304 goto not_ssl_hello;
305
306 too_short:
307 smp->flags = SMP_F_MAY_CHANGE;
308
309 not_ssl_hello:
310
311 return 0;
312}
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100313/* returns the type of SSL hello message (mainly used to detect an SSL hello) */
314static int
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200315smp_fetch_ssl_hello_type(const struct arg *args, struct sample *smp, const char *kw, void *private)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100316{
317 int hs_len;
318 int hs_type, bleft;
319 struct channel *chn;
320 const unsigned char *data;
321
Willy Tarreaube508f12016-03-10 11:47:01 +0100322 if (!smp->strm)
323 goto not_ssl_hello;
324
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200325 chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100326 bleft = chn->buf->i;
327 data = (const unsigned char *)chn->buf->p;
328
329 if (!bleft)
330 goto too_short;
331
332 if ((*data >= 0x14 && *data <= 0x17) || (*data == 0xFF)) {
333 /* SSLv3 header format */
334 if (bleft < 9)
335 goto too_short;
336
337 /* ssl version 3 */
338 if ((data[1] << 16) + data[2] < 0x00030000)
339 goto not_ssl_hello;
340
341 /* ssl message len must present handshake type and len */
342 if ((data[3] << 8) + data[4] < 4)
343 goto not_ssl_hello;
344
345 /* format introduced with SSLv3 */
346
347 hs_type = (int)data[5];
348 hs_len = ( data[6] << 16 ) + ( data[7] << 8 ) + data[8];
349
350 /* not a full handshake */
351 if (bleft < (9 + hs_len))
352 goto too_short;
353
354 }
355 else {
356 goto not_ssl_hello;
357 }
358
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +0200359 smp->data.type = SMP_T_SINT;
Thierry FOURNIER136f9d32015-08-19 09:07:19 +0200360 smp->data.u.sint = hs_type;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100361 smp->flags = SMP_F_VOLATILE;
362
363 return 1;
364
365 too_short:
366 smp->flags = SMP_F_MAY_CHANGE;
367
368 not_ssl_hello:
369
370 return 0;
371}
372
373/* Return the version of the SSL protocol in the request. It supports both
374 * SSLv3 (TLSv1) header format for any message, and SSLv2 header format for
375 * the hello message. The SSLv3 format is described in RFC 2246 p49, and the
376 * SSLv2 format is described here, and completed p67 of RFC 2246 :
377 * http://wp.netscape.com/eng/security/SSL_2.html
378 *
379 * Note: this decoder only works with non-wrapping data.
380 */
381static int
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200382smp_fetch_req_ssl_ver(const struct arg *args, struct sample *smp, const char *kw, void *private)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100383{
384 int version, bleft, msg_len;
385 const unsigned char *data;
Willy Tarreaube508f12016-03-10 11:47:01 +0100386 struct channel *req;
387
388 if (!smp->strm)
389 return 0;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100390
Willy Tarreaube508f12016-03-10 11:47:01 +0100391 req = &smp->strm->req;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100392 msg_len = 0;
Thierry FOURNIER0a9a2b82015-05-11 15:20:49 +0200393 bleft = req->buf->i;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100394 if (!bleft)
395 goto too_short;
396
Thierry FOURNIER0a9a2b82015-05-11 15:20:49 +0200397 data = (const unsigned char *)req->buf->p;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100398 if ((*data >= 0x14 && *data <= 0x17) || (*data == 0xFF)) {
399 /* SSLv3 header format */
Lukas Tribusc93242c2015-11-05 13:59:30 +0100400 if (bleft < 11)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100401 goto too_short;
402
Lukas Tribusc93242c2015-11-05 13:59:30 +0100403 version = (data[1] << 16) + data[2]; /* record layer version: major, minor */
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100404 msg_len = (data[3] << 8) + data[4]; /* record length */
405
406 /* format introduced with SSLv3 */
407 if (version < 0x00030000)
408 goto not_ssl;
409
Lukas Tribusc93242c2015-11-05 13:59:30 +0100410 /* message length between 6 and 2^14 + 2048 */
411 if (msg_len < 6 || msg_len > ((1<<14) + 2048))
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100412 goto not_ssl;
413
414 bleft -= 5; data += 5;
Lukas Tribusc93242c2015-11-05 13:59:30 +0100415
416 /* return the client hello client version, not the record layer version */
417 version = (data[4] << 16) + data[5]; /* client hello version: major, minor */
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100418 } else {
419 /* SSLv2 header format, only supported for hello (msg type 1) */
420 int rlen, plen, cilen, silen, chlen;
421
422 if (*data & 0x80) {
423 if (bleft < 3)
424 goto too_short;
425 /* short header format : 15 bits for length */
426 rlen = ((data[0] & 0x7F) << 8) | data[1];
427 plen = 0;
428 bleft -= 2; data += 2;
429 } else {
430 if (bleft < 4)
431 goto too_short;
432 /* long header format : 14 bits for length + pad length */
433 rlen = ((data[0] & 0x3F) << 8) | data[1];
434 plen = data[2];
Willy Tarreau74967f62016-08-30 14:39:46 +0200435 bleft -= 3; data += 3;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100436 }
437
438 if (*data != 0x01)
439 goto not_ssl;
440 bleft--; data++;
441
442 if (bleft < 8)
443 goto too_short;
444 version = (data[0] << 16) + data[1]; /* version: major, minor */
445 cilen = (data[2] << 8) + data[3]; /* cipher len, multiple of 3 */
446 silen = (data[4] << 8) + data[5]; /* session_id_len: 0 or 16 */
447 chlen = (data[6] << 8) + data[7]; /* 16<=challenge length<=32 */
448
449 bleft -= 8; data += 8;
450 if (cilen % 3 != 0)
451 goto not_ssl;
452 if (silen && silen != 16)
453 goto not_ssl;
454 if (chlen < 16 || chlen > 32)
455 goto not_ssl;
456 if (rlen != 9 + cilen + silen + chlen)
457 goto not_ssl;
458
459 /* focus on the remaining data length */
460 msg_len = cilen + silen + chlen + plen;
461 }
462 /* We could recursively check that the buffer ends exactly on an SSL
463 * fragment boundary and that a possible next segment is still SSL,
464 * but that's a bit pointless. However, we could still check that
465 * all the part of the request which fits in a buffer is already
466 * there.
467 */
Thierry FOURNIER0a9a2b82015-05-11 15:20:49 +0200468 if (msg_len > channel_recv_limit(req) + req->buf->data - req->buf->p)
469 msg_len = channel_recv_limit(req) + req->buf->data - req->buf->p;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100470
471 if (bleft < msg_len)
472 goto too_short;
473
474 /* OK that's enough. We have at least the whole message, and we have
475 * the protocol version.
476 */
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +0200477 smp->data.type = SMP_T_SINT;
Thierry FOURNIER136f9d32015-08-19 09:07:19 +0200478 smp->data.u.sint = version;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100479 smp->flags = SMP_F_VOLATILE;
480 return 1;
481
482 too_short:
483 smp->flags = SMP_F_MAY_CHANGE;
484 not_ssl:
485 return 0;
486}
487
488/* Try to extract the Server Name Indication that may be presented in a TLS
489 * client hello handshake message. The format of the message is the following
490 * (cf RFC5246 + RFC6066) :
491 * TLS frame :
492 * - uint8 type = 0x16 (Handshake)
493 * - uint16 version >= 0x0301 (TLSv1)
494 * - uint16 length (frame length)
495 * - TLS handshake :
496 * - uint8 msg_type = 0x01 (ClientHello)
497 * - uint24 length (handshake message length)
498 * - ClientHello :
499 * - uint16 client_version >= 0x0301 (TLSv1)
500 * - uint8 Random[32] (4 first ones are timestamp)
501 * - SessionID :
502 * - uint8 session_id_len (0..32) (SessionID len in bytes)
503 * - uint8 session_id[session_id_len]
504 * - CipherSuite :
505 * - uint16 cipher_len >= 2 (Cipher length in bytes)
506 * - uint16 ciphers[cipher_len/2]
507 * - CompressionMethod :
508 * - uint8 compression_len >= 1 (# of supported methods)
509 * - uint8 compression_methods[compression_len]
510 * - optional client_extension_len (in bytes)
511 * - optional sequence of ClientHelloExtensions (as many bytes as above):
512 * - uint16 extension_type = 0 for server_name
513 * - uint16 extension_len
514 * - opaque extension_data[extension_len]
515 * - uint16 server_name_list_len (# of bytes here)
516 * - opaque server_names[server_name_list_len bytes]
517 * - uint8 name_type = 0 for host_name
518 * - uint16 name_len
519 * - opaque hostname[name_len bytes]
520 */
521static int
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200522smp_fetch_ssl_hello_sni(const struct arg *args, struct sample *smp, const char *kw, void *private)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100523{
524 int hs_len, ext_len, bleft;
525 struct channel *chn;
526 unsigned char *data;
527
Willy Tarreaube508f12016-03-10 11:47:01 +0100528 if (!smp->strm)
529 goto not_ssl_hello;
530
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200531 chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100532 bleft = chn->buf->i;
533 data = (unsigned char *)chn->buf->p;
534
535 /* Check for SSL/TLS Handshake */
536 if (!bleft)
537 goto too_short;
538 if (*data != 0x16)
539 goto not_ssl_hello;
540
Lukas Tribus57d22972014-04-10 21:36:22 +0200541 /* Check for SSLv3 or later (SSL version >= 3.0) in the record layer*/
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100542 if (bleft < 3)
543 goto too_short;
Lukas Tribus57d22972014-04-10 21:36:22 +0200544 if (data[1] < 0x03)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100545 goto not_ssl_hello;
546
547 if (bleft < 5)
548 goto too_short;
549 hs_len = (data[3] << 8) + data[4];
550 if (hs_len < 1 + 3 + 2 + 32 + 1 + 2 + 2 + 1 + 1 + 2 + 2)
551 goto not_ssl_hello; /* too short to have an extension */
552
553 data += 5; /* enter TLS handshake */
554 bleft -= 5;
555
556 /* Check for a complete client hello starting at <data> */
557 if (bleft < 1)
558 goto too_short;
559 if (data[0] != 0x01) /* msg_type = Client Hello */
560 goto not_ssl_hello;
561
562 /* Check the Hello's length */
563 if (bleft < 4)
564 goto too_short;
565 hs_len = (data[1] << 16) + (data[2] << 8) + data[3];
566 if (hs_len < 2 + 32 + 1 + 2 + 2 + 1 + 1 + 2 + 2)
567 goto not_ssl_hello; /* too short to have an extension */
568
569 /* We want the full handshake here */
570 if (bleft < hs_len)
571 goto too_short;
572
573 data += 4;
574 /* Start of the ClientHello message */
575 if (data[0] < 0x03 || data[1] < 0x01) /* TLSv1 minimum */
576 goto not_ssl_hello;
577
578 ext_len = data[34]; /* session_id_len */
579 if (ext_len > 32 || ext_len > (hs_len - 35)) /* check for correct session_id len */
580 goto not_ssl_hello;
581
582 /* Jump to cipher suite */
583 hs_len -= 35 + ext_len;
584 data += 35 + ext_len;
585
586 if (hs_len < 4 || /* minimum one cipher */
587 (ext_len = (data[0] << 8) + data[1]) < 2 || /* minimum 2 bytes for a cipher */
588 ext_len > hs_len)
589 goto not_ssl_hello;
590
591 /* Jump to the compression methods */
592 hs_len -= 2 + ext_len;
593 data += 2 + ext_len;
594
595 if (hs_len < 2 || /* minimum one compression method */
596 data[0] < 1 || data[0] > hs_len) /* minimum 1 bytes for a method */
597 goto not_ssl_hello;
598
599 /* Jump to the extensions */
600 hs_len -= 1 + data[0];
601 data += 1 + data[0];
602
603 if (hs_len < 2 || /* minimum one extension list length */
604 (ext_len = (data[0] << 8) + data[1]) > hs_len - 2) /* list too long */
605 goto not_ssl_hello;
606
607 hs_len = ext_len; /* limit ourselves to the extension length */
608 data += 2;
609
610 while (hs_len >= 4) {
611 int ext_type, name_type, srv_len, name_len;
612
613 ext_type = (data[0] << 8) + data[1];
614 ext_len = (data[2] << 8) + data[3];
615
616 if (ext_len > hs_len - 4) /* Extension too long */
617 goto not_ssl_hello;
618
619 if (ext_type == 0) { /* Server name */
620 if (ext_len < 2) /* need one list length */
621 goto not_ssl_hello;
622
623 srv_len = (data[4] << 8) + data[5];
624 if (srv_len < 4 || srv_len > hs_len - 6)
625 goto not_ssl_hello; /* at least 4 bytes per server name */
626
627 name_type = data[6];
628 name_len = (data[7] << 8) + data[8];
629
630 if (name_type == 0) { /* hostname */
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +0200631 smp->data.type = SMP_T_STR;
Thierry FOURNIER136f9d32015-08-19 09:07:19 +0200632 smp->data.u.str.str = (char *)data + 9;
633 smp->data.u.str.len = name_len;
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100634 smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100635 return 1;
636 }
637 }
638
639 hs_len -= 4 + ext_len;
640 data += 4 + ext_len;
641 }
642 /* server name not found */
643 goto not_ssl_hello;
644
645 too_short:
646 smp->flags = SMP_F_MAY_CHANGE;
647
648 not_ssl_hello:
649
650 return 0;
651}
652
Willy Tarreaucadd8c92013-07-22 18:09:52 +0200653/* Fetch the request RDP cookie identified in <cname>:<clen>, or any cookie if
Willy Tarreaub169eba2013-12-16 15:14:43 +0100654 * <clen> is empty (cname is then ignored). It returns the data into sample <smp>
655 * of type SMP_T_CSTR. Note: this decoder only works with non-wrapping data.
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100656 */
657int
Willy Tarreau87b09662015-04-03 00:22:06 +0200658fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, int clen)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100659{
660 int bleft;
661 const unsigned char *data;
662
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100663 smp->flags = SMP_F_CONST;
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +0200664 smp->data.type = SMP_T_STR;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100665
Willy Tarreau22ec1ea2014-11-27 20:45:39 +0100666 bleft = s->req.buf->i;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100667 if (bleft <= 11)
668 goto too_short;
669
Willy Tarreau22ec1ea2014-11-27 20:45:39 +0100670 data = (const unsigned char *)s->req.buf->p + 11;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100671 bleft -= 11;
672
673 if (bleft <= 7)
674 goto too_short;
675
676 if (strncasecmp((const char *)data, "Cookie:", 7) != 0)
677 goto not_cookie;
678
679 data += 7;
680 bleft -= 7;
681
682 while (bleft > 0 && *data == ' ') {
683 data++;
684 bleft--;
685 }
686
Willy Tarreaucadd8c92013-07-22 18:09:52 +0200687 if (clen) {
688 if (bleft <= clen)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100689 goto too_short;
690
Willy Tarreaucadd8c92013-07-22 18:09:52 +0200691 if ((data[clen] != '=') ||
692 strncasecmp(cname, (const char *)data, clen) != 0)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100693 goto not_cookie;
694
Willy Tarreaucadd8c92013-07-22 18:09:52 +0200695 data += clen + 1;
696 bleft -= clen + 1;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100697 } else {
698 while (bleft > 0 && *data != '=') {
699 if (*data == '\r' || *data == '\n')
700 goto not_cookie;
701 data++;
702 bleft--;
703 }
704
705 if (bleft < 1)
706 goto too_short;
707
708 if (*data != '=')
709 goto not_cookie;
710
711 data++;
712 bleft--;
713 }
714
715 /* data points to cookie value */
Thierry FOURNIER136f9d32015-08-19 09:07:19 +0200716 smp->data.u.str.str = (char *)data;
717 smp->data.u.str.len = 0;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100718
719 while (bleft > 0 && *data != '\r') {
720 data++;
721 bleft--;
722 }
723
724 if (bleft < 2)
725 goto too_short;
726
727 if (data[0] != '\r' || data[1] != '\n')
728 goto not_cookie;
729
Thierry FOURNIER136f9d32015-08-19 09:07:19 +0200730 smp->data.u.str.len = (char *)data - smp->data.u.str.str;
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100731 smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100732 return 1;
733
734 too_short:
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100735 smp->flags = SMP_F_MAY_CHANGE | SMP_F_CONST;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100736 not_cookie:
737 return 0;
738}
739
Willy Tarreaucadd8c92013-07-22 18:09:52 +0200740/* Fetch the request RDP cookie identified in the args, or any cookie if no arg
741 * is passed. It is usable both for ACL and for samples. Note: this decoder
742 * only works with non-wrapping data. Accepts either 0 or 1 argument. Argument
Willy Tarreaub169eba2013-12-16 15:14:43 +0100743 * is a string (cookie name), other types will lead to undefined behaviour. The
744 * returned sample has type SMP_T_CSTR.
Willy Tarreaucadd8c92013-07-22 18:09:52 +0200745 */
746int
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200747smp_fetch_rdp_cookie(const struct arg *args, struct sample *smp, const char *kw, void *private)
Willy Tarreaucadd8c92013-07-22 18:09:52 +0200748{
Willy Tarreaube508f12016-03-10 11:47:01 +0100749 if (!smp->strm)
750 return 0;
751
Thierry FOURNIER0a9a2b82015-05-11 15:20:49 +0200752 return fetch_rdp_cookie_name(smp->strm, smp, args ? args->data.str.str : NULL, args ? args->data.str.len : 0);
Willy Tarreaucadd8c92013-07-22 18:09:52 +0200753}
754
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100755/* returns either 1 or 0 depending on whether an RDP cookie is found or not */
756static int
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200757smp_fetch_rdp_cookie_cnt(const struct arg *args, struct sample *smp, const char *kw, void *private)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100758{
759 int ret;
760
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200761 ret = smp_fetch_rdp_cookie(args, smp, kw, private);
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100762
763 if (smp->flags & SMP_F_MAY_CHANGE)
764 return 0;
765
766 smp->flags = SMP_F_VOLATILE;
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +0200767 smp->data.type = SMP_T_SINT;
Thierry FOURNIER136f9d32015-08-19 09:07:19 +0200768 smp->data.u.sint = ret;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100769 return 1;
770}
771
772/* extracts part of a payload with offset and length at a given position */
773static int
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200774smp_fetch_payload_lv(const struct arg *arg_p, struct sample *smp, const char *kw, void *private)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100775{
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200776 unsigned int len_offset = arg_p[0].data.sint;
777 unsigned int len_size = arg_p[1].data.sint;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100778 unsigned int buf_offset;
779 unsigned int buf_size = 0;
780 struct channel *chn;
781 int i;
782
783 /* Format is (len offset, len size, buf offset) or (len offset, len size) */
784 /* by default buf offset == len offset + len size */
785 /* buf offset could be absolute or relative to len offset + len size if prefixed by + or - */
786
Willy Tarreaube508f12016-03-10 11:47:01 +0100787 if (!smp->strm)
788 return 0;
789
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200790 chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100791 if (len_offset + len_size > chn->buf->i)
792 goto too_short;
793
794 for (i = 0; i < len_size; i++) {
795 buf_size = (buf_size << 8) + ((unsigned char *)chn->buf->p)[i + len_offset];
796 }
797
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200798 /* buf offset may be implicit, absolute or relative. If the LSB
799 * is set, then the offset is relative otherwise it is absolute.
800 */
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100801 buf_offset = len_offset + len_size;
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200802 if (arg_p[2].type == ARGT_SINT) {
803 if (arg_p[2].data.sint & 1)
804 buf_offset += arg_p[2].data.sint >> 1;
805 else
806 buf_offset = arg_p[2].data.sint >> 1;
807 }
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100808
Willy Tarreaud7bdcb82015-09-24 16:33:10 +0200809 if (!buf_size || buf_size > global.tune.bufsize || buf_offset + buf_size > global.tune.bufsize) {
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100810 /* will never match */
811 smp->flags = 0;
812 return 0;
813 }
814
815 if (buf_offset + buf_size > chn->buf->i)
816 goto too_short;
817
818 /* init chunk as read only */
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +0200819 smp->data.type = SMP_T_BIN;
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100820 smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
Thierry FOURNIER136f9d32015-08-19 09:07:19 +0200821 chunk_initlen(&smp->data.u.str, chn->buf->p + buf_offset, 0, buf_size);
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100822 return 1;
823
824 too_short:
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100825 smp->flags = SMP_F_MAY_CHANGE | SMP_F_CONST;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100826 return 0;
827}
828
829/* extracts some payload at a fixed position and length */
830static int
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200831smp_fetch_payload(const struct arg *arg_p, struct sample *smp, const char *kw, void *private)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100832{
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200833 unsigned int buf_offset = arg_p[0].data.sint;
834 unsigned int buf_size = arg_p[1].data.sint;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100835 struct channel *chn;
836
Willy Tarreaube508f12016-03-10 11:47:01 +0100837 if (!smp->strm)
838 return 0;
839
Thierry FOURNIER0786d052015-05-11 15:42:45 +0200840 chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? &smp->strm->res : &smp->strm->req;
Willy Tarreaud7bdcb82015-09-24 16:33:10 +0200841 if (!buf_size || buf_size > global.tune.bufsize || buf_offset + buf_size > global.tune.bufsize) {
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100842 /* will never match */
843 smp->flags = 0;
844 return 0;
845 }
846
847 if (buf_offset + buf_size > chn->buf->i)
848 goto too_short;
849
850 /* init chunk as read only */
Thierry FOURNIER8c542ca2015-08-19 09:00:18 +0200851 smp->data.type = SMP_T_BIN;
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100852 smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
Thierry FOURNIER136f9d32015-08-19 09:07:19 +0200853 chunk_initlen(&smp->data.u.str, chn->buf->p + buf_offset, 0, buf_size ? buf_size : (chn->buf->i - buf_offset));
Willy Tarreau3889fff2015-01-13 20:20:10 +0100854 if (!buf_size && channel_may_recv(chn) && !channel_input_closed(chn))
Willy Tarreau00f00842013-08-02 11:07:32 +0200855 smp->flags |= SMP_F_MAY_CHANGE;
856
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100857 return 1;
858
859 too_short:
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100860 smp->flags = SMP_F_MAY_CHANGE | SMP_F_CONST;
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100861 return 0;
862}
863
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100864/* This function is used to validate the arguments passed to a "payload_lv" fetch
865 * keyword. This keyword allows two positive integers and an optional signed one,
866 * with the second one being strictly positive and the third one being greater than
867 * the opposite of the two others if negative. It is assumed that the types are
868 * already the correct ones. Returns 0 on error, non-zero if OK. If <err_msg> is
869 * not NULL, it will be filled with a pointer to an error message in case of
870 * error, that the caller is responsible for freeing. The initial location must
871 * either be freeable or NULL.
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200872 *
873 * Note that offset2 is stored with SINT type, but its not directly usable as is.
874 * The value is contained in the 63 MSB and the LSB is used as a flag for marking
875 * the "relative" property of the value.
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100876 */
Thierry FOURNIER49f45af2014-12-08 19:50:43 +0100877int val_payload_lv(struct arg *arg, char **err_msg)
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100878{
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200879 int relative = 0;
880 const char *str;
881
882 if (arg[0].data.sint < 0) {
883 memprintf(err_msg, "payload offset1 must be positive");
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100884 return 0;
885 }
886
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200887 if (!arg[1].data.sint) {
888 memprintf(err_msg, "payload length must be > 0");
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100889 return 0;
890 }
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200891
892 if (arg[2].type == ARGT_STR && arg[2].data.str.len > 0) {
893 if (arg[2].data.str.str[0] == '+' || arg[2].data.str.str[0] == '-')
894 relative = 1;
895 str = arg[2].data.str.str;
896 arg[2].type = ARGT_SINT;
897 arg[2].data.sint = read_int64(&str, str + arg[2].data.str.len);
898 if (*str != '\0') {
899 memprintf(err_msg, "payload offset2 is not a number");
900 return 0;
901 }
902 if (arg[0].data.sint + arg[1].data.sint + arg[2].data.sint < 0) {
903 memprintf(err_msg, "payload offset2 too negative");
904 return 0;
905 }
906 if (relative)
907 arg[2].data.sint = ( arg[2].data.sint << 1 ) + 1;
908 }
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100909 return 1;
910}
911
912/************************************************************************/
913/* All supported sample and ACL keywords must be declared here. */
914/************************************************************************/
915
916/* Note: must not be declared <const> as its list will be overwritten.
917 * Note: fetches that may return multiple types must be declared as the lowest
918 * common denominator, the type that can be casted into all other ones. For
919 * instance IPv4/IPv6 must be declared IPv4.
920 */
Willy Tarreaudc13c112013-06-21 23:16:39 +0200921static struct sample_fetch_kw_list smp_kws = {ILH, {
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200922 { "payload", smp_fetch_payload, ARG2(2,SINT,SINT), NULL, SMP_T_BIN, SMP_USE_L6REQ|SMP_USE_L6RES },
923 { "payload_lv", smp_fetch_payload_lv, ARG3(2,SINT,SINT,STR), val_payload_lv, SMP_T_BIN, SMP_USE_L6REQ|SMP_USE_L6RES },
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100924 { "rdp_cookie", smp_fetch_rdp_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_L6REQ },
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +0200925 { "rdp_cookie_cnt", smp_fetch_rdp_cookie_cnt, ARG1(0,STR), NULL, SMP_T_SINT, SMP_USE_L6REQ },
926 { "rep_ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_SINT, SMP_USE_L6RES },
927 { "req_len", smp_fetch_len, 0, NULL, SMP_T_SINT, SMP_USE_L6REQ },
928 { "req_ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_SINT, SMP_USE_L6REQ },
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100929 { "req_ssl_sni", smp_fetch_ssl_hello_sni, 0, NULL, SMP_T_STR, SMP_USE_L6REQ },
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +0200930 { "req_ssl_ver", smp_fetch_req_ssl_ver, 0, NULL, SMP_T_SINT, SMP_USE_L6REQ },
Willy Tarreaufa957342013-01-14 16:07:52 +0100931
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +0200932 { "req.len", smp_fetch_len, 0, NULL, SMP_T_SINT, SMP_USE_L6REQ },
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200933 { "req.payload", smp_fetch_payload, ARG2(2,SINT,SINT), NULL, SMP_T_BIN, SMP_USE_L6REQ },
934 { "req.payload_lv", smp_fetch_payload_lv, ARG3(2,SINT,SINT,STR), val_payload_lv, SMP_T_BIN, SMP_USE_L6REQ },
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100935 { "req.rdp_cookie", smp_fetch_rdp_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_L6REQ },
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +0200936 { "req.rdp_cookie_cnt", smp_fetch_rdp_cookie_cnt, ARG1(0,STR), NULL, SMP_T_SINT, SMP_USE_L6REQ },
Nenad Merdanovic5fc7d7e2015-07-07 22:00:17 +0200937 { "req.ssl_ec_ext", smp_fetch_req_ssl_ec_ext, 0, NULL, SMP_T_BOOL, SMP_USE_L6REQ },
Pradeep Jindalbb2acf52015-09-29 10:12:57 +0530938 { "req.ssl_st_ext", smp_fetch_req_ssl_st_ext, 0, NULL, SMP_T_SINT, SMP_USE_L6REQ },
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +0200939 { "req.ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_SINT, SMP_USE_L6REQ },
Thierry FOURNIER7654c9f2013-12-17 00:20:33 +0100940 { "req.ssl_sni", smp_fetch_ssl_hello_sni, 0, NULL, SMP_T_STR, SMP_USE_L6REQ },
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +0200941 { "req.ssl_ver", smp_fetch_req_ssl_ver, 0, NULL, SMP_T_SINT, SMP_USE_L6REQ },
942 { "res.len", smp_fetch_len, 0, NULL, SMP_T_SINT, SMP_USE_L6RES },
Thierry FOURNIERbf65cd42015-07-20 17:45:02 +0200943 { "res.payload", smp_fetch_payload, ARG2(2,SINT,SINT), NULL, SMP_T_BIN, SMP_USE_L6RES },
944 { "res.payload_lv", smp_fetch_payload_lv, ARG3(2,SINT,SINT,STR), val_payload_lv, SMP_T_BIN, SMP_USE_L6RES },
Thierry FOURNIER07ee64e2015-07-06 23:43:03 +0200945 { "res.ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_SINT, SMP_USE_L6RES },
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100946 { "wait_end", smp_fetch_wait_end, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN },
947 { /* END */ },
948}};
949
950
951/* Note: must not be declared <const> as its list will be overwritten.
952 * Please take care of keeping this list alphabetically sorted.
953 */
Willy Tarreaudc13c112013-06-21 23:16:39 +0200954static struct acl_kw_list acl_kws = {ILH, {
Thierry FOURNIERc5a4e982014-03-05 16:07:08 +0100955 { "payload", "req.payload", PAT_MATCH_BIN },
956 { "payload_lv", "req.payload_lv", PAT_MATCH_BIN },
957 { "req_rdp_cookie", "req.rdp_cookie", PAT_MATCH_STR },
958 { "req_rdp_cookie_cnt", "req.rdp_cookie_cnt", PAT_MATCH_INT },
959 { "req_ssl_sni", "req.ssl_sni", PAT_MATCH_STR },
960 { "req_ssl_ver", "req.ssl_ver", PAT_MATCH_INT, pat_parse_dotted_ver },
961 { "req.ssl_ver", "req.ssl_ver", PAT_MATCH_INT, pat_parse_dotted_ver },
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100962 { /* END */ },
963}};
964
965
966__attribute__((constructor))
967static void __payload_init(void)
968{
969 sample_register_fetches(&smp_kws);
970 acl_register_keywords(&acl_kws);
971}
972
973/*
974 * Local variables:
975 * c-indent-level: 8
976 * c-basic-offset: 8
977 * End:
978 */