blob: 2ac996f6d2b1598b17fb98b51fdd9f68528b348c [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>
19#include <proto/payload.h>
20#include <proto/sample.h>
21
22
23/************************************************************************/
24/* All supported sample fetch functions must be declared here */
25/************************************************************************/
26
27/* wait for more data as long as possible, then return TRUE. This should be
28 * used with content inspection.
29 */
30static int
31smp_fetch_wait_end(struct proxy *px, struct session *s, void *l7, unsigned int opt,
32 const struct arg *args, struct sample *smp)
33{
34 if (!(opt & SMP_OPT_FINAL)) {
35 smp->flags |= SMP_F_MAY_CHANGE;
36 return 0;
37 }
38 smp->type = SMP_T_BOOL;
39 smp->data.uint = 1;
40 return 1;
41}
42
43/* return the number of bytes in the request buffer */
44static int
45smp_fetch_req_len(struct proxy *px, struct session *s, void *l7, unsigned int opt,
46 const struct arg *args, struct sample *smp)
47{
48 if (!s || !s->req)
49 return 0;
50
51 smp->type = SMP_T_UINT;
52 smp->data.uint = s->req->buf->i;
53 smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE;
54 return 1;
55}
56
57/* returns the type of SSL hello message (mainly used to detect an SSL hello) */
58static int
59smp_fetch_ssl_hello_type(struct proxy *px, struct session *s, void *l7, unsigned int opt,
60 const struct arg *args, struct sample *smp)
61{
62 int hs_len;
63 int hs_type, bleft;
64 struct channel *chn;
65 const unsigned char *data;
66
67 if (!s)
68 goto not_ssl_hello;
69
70 chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? s->rep : s->req;
71
72 bleft = chn->buf->i;
73 data = (const unsigned char *)chn->buf->p;
74
75 if (!bleft)
76 goto too_short;
77
78 if ((*data >= 0x14 && *data <= 0x17) || (*data == 0xFF)) {
79 /* SSLv3 header format */
80 if (bleft < 9)
81 goto too_short;
82
83 /* ssl version 3 */
84 if ((data[1] << 16) + data[2] < 0x00030000)
85 goto not_ssl_hello;
86
87 /* ssl message len must present handshake type and len */
88 if ((data[3] << 8) + data[4] < 4)
89 goto not_ssl_hello;
90
91 /* format introduced with SSLv3 */
92
93 hs_type = (int)data[5];
94 hs_len = ( data[6] << 16 ) + ( data[7] << 8 ) + data[8];
95
96 /* not a full handshake */
97 if (bleft < (9 + hs_len))
98 goto too_short;
99
100 }
101 else {
102 goto not_ssl_hello;
103 }
104
105 smp->type = SMP_T_UINT;
106 smp->data.uint = hs_type;
107 smp->flags = SMP_F_VOLATILE;
108
109 return 1;
110
111 too_short:
112 smp->flags = SMP_F_MAY_CHANGE;
113
114 not_ssl_hello:
115
116 return 0;
117}
118
119/* Return the version of the SSL protocol in the request. It supports both
120 * SSLv3 (TLSv1) header format for any message, and SSLv2 header format for
121 * the hello message. The SSLv3 format is described in RFC 2246 p49, and the
122 * SSLv2 format is described here, and completed p67 of RFC 2246 :
123 * http://wp.netscape.com/eng/security/SSL_2.html
124 *
125 * Note: this decoder only works with non-wrapping data.
126 */
127static int
128smp_fetch_req_ssl_ver(struct proxy *px, struct session *s, void *l7, unsigned int opt,
129 const struct arg *args, struct sample *smp)
130{
131 int version, bleft, msg_len;
132 const unsigned char *data;
133
134 if (!s || !s->req)
135 return 0;
136
137 msg_len = 0;
138 bleft = s->req->buf->i;
139 if (!bleft)
140 goto too_short;
141
142 data = (const unsigned char *)s->req->buf->p;
143 if ((*data >= 0x14 && *data <= 0x17) || (*data == 0xFF)) {
144 /* SSLv3 header format */
145 if (bleft < 5)
146 goto too_short;
147
148 version = (data[1] << 16) + data[2]; /* version: major, minor */
149 msg_len = (data[3] << 8) + data[4]; /* record length */
150
151 /* format introduced with SSLv3 */
152 if (version < 0x00030000)
153 goto not_ssl;
154
155 /* message length between 1 and 2^14 + 2048 */
156 if (msg_len < 1 || msg_len > ((1<<14) + 2048))
157 goto not_ssl;
158
159 bleft -= 5; data += 5;
160 } else {
161 /* SSLv2 header format, only supported for hello (msg type 1) */
162 int rlen, plen, cilen, silen, chlen;
163
164 if (*data & 0x80) {
165 if (bleft < 3)
166 goto too_short;
167 /* short header format : 15 bits for length */
168 rlen = ((data[0] & 0x7F) << 8) | data[1];
169 plen = 0;
170 bleft -= 2; data += 2;
171 } else {
172 if (bleft < 4)
173 goto too_short;
174 /* long header format : 14 bits for length + pad length */
175 rlen = ((data[0] & 0x3F) << 8) | data[1];
176 plen = data[2];
177 bleft -= 3; data += 2;
178 }
179
180 if (*data != 0x01)
181 goto not_ssl;
182 bleft--; data++;
183
184 if (bleft < 8)
185 goto too_short;
186 version = (data[0] << 16) + data[1]; /* version: major, minor */
187 cilen = (data[2] << 8) + data[3]; /* cipher len, multiple of 3 */
188 silen = (data[4] << 8) + data[5]; /* session_id_len: 0 or 16 */
189 chlen = (data[6] << 8) + data[7]; /* 16<=challenge length<=32 */
190
191 bleft -= 8; data += 8;
192 if (cilen % 3 != 0)
193 goto not_ssl;
194 if (silen && silen != 16)
195 goto not_ssl;
196 if (chlen < 16 || chlen > 32)
197 goto not_ssl;
198 if (rlen != 9 + cilen + silen + chlen)
199 goto not_ssl;
200
201 /* focus on the remaining data length */
202 msg_len = cilen + silen + chlen + plen;
203 }
204 /* We could recursively check that the buffer ends exactly on an SSL
205 * fragment boundary and that a possible next segment is still SSL,
206 * but that's a bit pointless. However, we could still check that
207 * all the part of the request which fits in a buffer is already
208 * there.
209 */
210 if (msg_len > buffer_max_len(s->req) + s->req->buf->data - s->req->buf->p)
211 msg_len = buffer_max_len(s->req) + s->req->buf->data - s->req->buf->p;
212
213 if (bleft < msg_len)
214 goto too_short;
215
216 /* OK that's enough. We have at least the whole message, and we have
217 * the protocol version.
218 */
219 smp->type = SMP_T_UINT;
220 smp->data.uint = version;
221 smp->flags = SMP_F_VOLATILE;
222 return 1;
223
224 too_short:
225 smp->flags = SMP_F_MAY_CHANGE;
226 not_ssl:
227 return 0;
228}
229
230/* Try to extract the Server Name Indication that may be presented in a TLS
231 * client hello handshake message. The format of the message is the following
232 * (cf RFC5246 + RFC6066) :
233 * TLS frame :
234 * - uint8 type = 0x16 (Handshake)
235 * - uint16 version >= 0x0301 (TLSv1)
236 * - uint16 length (frame length)
237 * - TLS handshake :
238 * - uint8 msg_type = 0x01 (ClientHello)
239 * - uint24 length (handshake message length)
240 * - ClientHello :
241 * - uint16 client_version >= 0x0301 (TLSv1)
242 * - uint8 Random[32] (4 first ones are timestamp)
243 * - SessionID :
244 * - uint8 session_id_len (0..32) (SessionID len in bytes)
245 * - uint8 session_id[session_id_len]
246 * - CipherSuite :
247 * - uint16 cipher_len >= 2 (Cipher length in bytes)
248 * - uint16 ciphers[cipher_len/2]
249 * - CompressionMethod :
250 * - uint8 compression_len >= 1 (# of supported methods)
251 * - uint8 compression_methods[compression_len]
252 * - optional client_extension_len (in bytes)
253 * - optional sequence of ClientHelloExtensions (as many bytes as above):
254 * - uint16 extension_type = 0 for server_name
255 * - uint16 extension_len
256 * - opaque extension_data[extension_len]
257 * - uint16 server_name_list_len (# of bytes here)
258 * - opaque server_names[server_name_list_len bytes]
259 * - uint8 name_type = 0 for host_name
260 * - uint16 name_len
261 * - opaque hostname[name_len bytes]
262 */
263static int
264smp_fetch_ssl_hello_sni(struct proxy *px, struct session *s, void *l7, unsigned int opt,
265 const struct arg *args, struct sample *smp)
266{
267 int hs_len, ext_len, bleft;
268 struct channel *chn;
269 unsigned char *data;
270
271 if (!s)
272 goto not_ssl_hello;
273
274 chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? s->rep : s->req;
275
276 bleft = chn->buf->i;
277 data = (unsigned char *)chn->buf->p;
278
279 /* Check for SSL/TLS Handshake */
280 if (!bleft)
281 goto too_short;
282 if (*data != 0x16)
283 goto not_ssl_hello;
284
285 /* Check for TLSv1 or later (SSL version >= 3.1) */
286 if (bleft < 3)
287 goto too_short;
288 if (data[1] < 0x03 || data[2] < 0x01)
289 goto not_ssl_hello;
290
291 if (bleft < 5)
292 goto too_short;
293 hs_len = (data[3] << 8) + data[4];
294 if (hs_len < 1 + 3 + 2 + 32 + 1 + 2 + 2 + 1 + 1 + 2 + 2)
295 goto not_ssl_hello; /* too short to have an extension */
296
297 data += 5; /* enter TLS handshake */
298 bleft -= 5;
299
300 /* Check for a complete client hello starting at <data> */
301 if (bleft < 1)
302 goto too_short;
303 if (data[0] != 0x01) /* msg_type = Client Hello */
304 goto not_ssl_hello;
305
306 /* Check the Hello's length */
307 if (bleft < 4)
308 goto too_short;
309 hs_len = (data[1] << 16) + (data[2] << 8) + data[3];
310 if (hs_len < 2 + 32 + 1 + 2 + 2 + 1 + 1 + 2 + 2)
311 goto not_ssl_hello; /* too short to have an extension */
312
313 /* We want the full handshake here */
314 if (bleft < hs_len)
315 goto too_short;
316
317 data += 4;
318 /* Start of the ClientHello message */
319 if (data[0] < 0x03 || data[1] < 0x01) /* TLSv1 minimum */
320 goto not_ssl_hello;
321
322 ext_len = data[34]; /* session_id_len */
323 if (ext_len > 32 || ext_len > (hs_len - 35)) /* check for correct session_id len */
324 goto not_ssl_hello;
325
326 /* Jump to cipher suite */
327 hs_len -= 35 + ext_len;
328 data += 35 + ext_len;
329
330 if (hs_len < 4 || /* minimum one cipher */
331 (ext_len = (data[0] << 8) + data[1]) < 2 || /* minimum 2 bytes for a cipher */
332 ext_len > hs_len)
333 goto not_ssl_hello;
334
335 /* Jump to the compression methods */
336 hs_len -= 2 + ext_len;
337 data += 2 + ext_len;
338
339 if (hs_len < 2 || /* minimum one compression method */
340 data[0] < 1 || data[0] > hs_len) /* minimum 1 bytes for a method */
341 goto not_ssl_hello;
342
343 /* Jump to the extensions */
344 hs_len -= 1 + data[0];
345 data += 1 + data[0];
346
347 if (hs_len < 2 || /* minimum one extension list length */
348 (ext_len = (data[0] << 8) + data[1]) > hs_len - 2) /* list too long */
349 goto not_ssl_hello;
350
351 hs_len = ext_len; /* limit ourselves to the extension length */
352 data += 2;
353
354 while (hs_len >= 4) {
355 int ext_type, name_type, srv_len, name_len;
356
357 ext_type = (data[0] << 8) + data[1];
358 ext_len = (data[2] << 8) + data[3];
359
360 if (ext_len > hs_len - 4) /* Extension too long */
361 goto not_ssl_hello;
362
363 if (ext_type == 0) { /* Server name */
364 if (ext_len < 2) /* need one list length */
365 goto not_ssl_hello;
366
367 srv_len = (data[4] << 8) + data[5];
368 if (srv_len < 4 || srv_len > hs_len - 6)
369 goto not_ssl_hello; /* at least 4 bytes per server name */
370
371 name_type = data[6];
372 name_len = (data[7] << 8) + data[8];
373
374 if (name_type == 0) { /* hostname */
375 smp->type = SMP_T_CSTR;
376 smp->data.str.str = (char *)data + 9;
377 smp->data.str.len = name_len;
378 smp->flags = SMP_F_VOLATILE;
379 return 1;
380 }
381 }
382
383 hs_len -= 4 + ext_len;
384 data += 4 + ext_len;
385 }
386 /* server name not found */
387 goto not_ssl_hello;
388
389 too_short:
390 smp->flags = SMP_F_MAY_CHANGE;
391
392 not_ssl_hello:
393
394 return 0;
395}
396
397/* Fetch the request RDP cookie identified in the args, or any cookie if no arg
398 * is passed. It is usable both for ACL and for samples. Note: this decoder
399 * only works with non-wrapping data. Accepts either 0 or 1 argument. Argument
400 * is a string (cookie name), other types will lead to undefined behaviour.
401 */
402int
403smp_fetch_rdp_cookie(struct proxy *px, struct session *s, void *l7, unsigned int opt,
404 const struct arg *args, struct sample *smp)
405{
406 int bleft;
407 const unsigned char *data;
408
409 if (!s || !s->req)
410 return 0;
411
412 smp->flags = 0;
413 smp->type = SMP_T_CSTR;
414
415 bleft = s->req->buf->i;
416 if (bleft <= 11)
417 goto too_short;
418
419 data = (const unsigned char *)s->req->buf->p + 11;
420 bleft -= 11;
421
422 if (bleft <= 7)
423 goto too_short;
424
425 if (strncasecmp((const char *)data, "Cookie:", 7) != 0)
426 goto not_cookie;
427
428 data += 7;
429 bleft -= 7;
430
431 while (bleft > 0 && *data == ' ') {
432 data++;
433 bleft--;
434 }
435
436 if (args) {
437
438 if (bleft <= args->data.str.len)
439 goto too_short;
440
441 if ((data[args->data.str.len] != '=') ||
442 strncasecmp(args->data.str.str, (const char *)data, args->data.str.len) != 0)
443 goto not_cookie;
444
445 data += args->data.str.len + 1;
446 bleft -= args->data.str.len + 1;
447 } else {
448 while (bleft > 0 && *data != '=') {
449 if (*data == '\r' || *data == '\n')
450 goto not_cookie;
451 data++;
452 bleft--;
453 }
454
455 if (bleft < 1)
456 goto too_short;
457
458 if (*data != '=')
459 goto not_cookie;
460
461 data++;
462 bleft--;
463 }
464
465 /* data points to cookie value */
466 smp->data.str.str = (char *)data;
467 smp->data.str.len = 0;
468
469 while (bleft > 0 && *data != '\r') {
470 data++;
471 bleft--;
472 }
473
474 if (bleft < 2)
475 goto too_short;
476
477 if (data[0] != '\r' || data[1] != '\n')
478 goto not_cookie;
479
480 smp->data.str.len = (char *)data - smp->data.str.str;
481 smp->flags = SMP_F_VOLATILE;
482 return 1;
483
484 too_short:
485 smp->flags = SMP_F_MAY_CHANGE;
486 not_cookie:
487 return 0;
488}
489
490/* returns either 1 or 0 depending on whether an RDP cookie is found or not */
491static int
492smp_fetch_rdp_cookie_cnt(struct proxy *px, struct session *s, void *l7, unsigned int opt,
493 const struct arg *args, struct sample *smp)
494{
495 int ret;
496
497 ret = smp_fetch_rdp_cookie(px, s, l7, opt, args, smp);
498
499 if (smp->flags & SMP_F_MAY_CHANGE)
500 return 0;
501
502 smp->flags = SMP_F_VOLATILE;
503 smp->type = SMP_T_UINT;
504 smp->data.uint = ret;
505 return 1;
506}
507
508/* extracts part of a payload with offset and length at a given position */
509static int
510smp_fetch_payload_lv(struct proxy *px, struct session *s, void *l7, unsigned int opt,
511 const struct arg *arg_p, struct sample *smp)
512{
513 unsigned int len_offset = arg_p[0].data.uint;
514 unsigned int len_size = arg_p[1].data.uint;
515 unsigned int buf_offset;
516 unsigned int buf_size = 0;
517 struct channel *chn;
518 int i;
519
520 /* Format is (len offset, len size, buf offset) or (len offset, len size) */
521 /* by default buf offset == len offset + len size */
522 /* buf offset could be absolute or relative to len offset + len size if prefixed by + or - */
523
524 if (!s)
525 return 0;
526
527 chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? s->rep : s->req;
528
529 if (!chn)
530 return 0;
531
532 if (len_offset + len_size > chn->buf->i)
533 goto too_short;
534
535 for (i = 0; i < len_size; i++) {
536 buf_size = (buf_size << 8) + ((unsigned char *)chn->buf->p)[i + len_offset];
537 }
538
539 /* buf offset may be implicit, absolute or relative */
540 buf_offset = len_offset + len_size;
541 if (arg_p[2].type == ARGT_UINT)
542 buf_offset = arg_p[2].data.uint;
543 else if (arg_p[2].type == ARGT_SINT)
544 buf_offset += arg_p[2].data.sint;
545
546 if (!buf_size || buf_size > chn->buf->size || buf_offset + buf_size > chn->buf->size) {
547 /* will never match */
548 smp->flags = 0;
549 return 0;
550 }
551
552 if (buf_offset + buf_size > chn->buf->i)
553 goto too_short;
554
555 /* init chunk as read only */
556 smp->type = SMP_T_CBIN;
557 chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size);
558 smp->flags = SMP_F_VOLATILE;
559 return 1;
560
561 too_short:
562 smp->flags = SMP_F_MAY_CHANGE;
563 return 0;
564}
565
566/* extracts some payload at a fixed position and length */
567static int
568smp_fetch_payload(struct proxy *px, struct session *s, void *l7, unsigned int opt,
569 const struct arg *arg_p, struct sample *smp)
570{
571 unsigned int buf_offset = arg_p[0].data.uint;
572 unsigned int buf_size = arg_p[1].data.uint;
573 struct channel *chn;
574
575 if (!s)
576 return 0;
577
578 chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? s->rep : s->req;
579
580 if (!chn)
581 return 0;
582
583 if (!buf_size || buf_size > chn->buf->size || buf_offset + buf_size > chn->buf->size) {
584 /* will never match */
585 smp->flags = 0;
586 return 0;
587 }
588
589 if (buf_offset + buf_size > chn->buf->i)
590 goto too_short;
591
592 /* init chunk as read only */
593 smp->type = SMP_T_CBIN;
594 chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size);
595 smp->flags = SMP_F_VOLATILE;
596 return 1;
597
598 too_short:
599 smp->flags = SMP_F_MAY_CHANGE;
600 return 0;
601}
602
603/* This function is used to validate the arguments passed to a "payload" fetch
604 * keyword. This keyword expects two positive integers, with the second one
605 * being strictly positive. It is assumed that the types are already the correct
606 * ones. Returns 0 on error, non-zero if OK. If <err_msg> is not NULL, it will be
607 * filled with a pointer to an error message in case of error, that the caller
608 * is responsible for freeing. The initial location must either be freeable or
609 * NULL.
610 */
611static int val_payload(struct arg *arg, char **err_msg)
612{
613 if (!arg[1].data.uint) {
614 memprintf(err_msg, "payload length must be > 0");
615 return 0;
616 }
617 return 1;
618}
619
620/* This function is used to validate the arguments passed to a "payload_lv" fetch
621 * keyword. This keyword allows two positive integers and an optional signed one,
622 * with the second one being strictly positive and the third one being greater than
623 * the opposite of the two others if negative. It is assumed that the types are
624 * already the correct ones. Returns 0 on error, non-zero if OK. If <err_msg> is
625 * not NULL, it will be filled with a pointer to an error message in case of
626 * error, that the caller is responsible for freeing. The initial location must
627 * either be freeable or NULL.
628 */
629static int val_payload_lv(struct arg *arg, char **err_msg)
630{
631 if (!arg[1].data.uint) {
632 memprintf(err_msg, "payload length must be > 0");
633 return 0;
634 }
635
636 if (arg[2].type == ARGT_SINT &&
637 (int)(arg[0].data.uint + arg[1].data.uint + arg[2].data.sint) < 0) {
638 memprintf(err_msg, "payload offset too negative");
639 return 0;
640 }
641 return 1;
642}
643
644/************************************************************************/
645/* All supported sample and ACL keywords must be declared here. */
646/************************************************************************/
647
648/* Note: must not be declared <const> as its list will be overwritten.
649 * Note: fetches that may return multiple types must be declared as the lowest
650 * common denominator, the type that can be casted into all other ones. For
651 * instance IPv4/IPv6 must be declared IPv4.
652 */
653static struct sample_fetch_kw_list smp_kws = {{ },{
654 { "payload", smp_fetch_payload, ARG2(2,UINT,UINT), val_payload, SMP_T_CBIN, SMP_USE_L6REQ|SMP_USE_L6RES },
655 { "payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_CBIN, SMP_USE_L6REQ|SMP_USE_L6RES },
656 { "rdp_cookie", smp_fetch_rdp_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_L6REQ },
657 { "rdp_cookie_cnt", smp_fetch_rdp_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_L6REQ },
658 { "rep_ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6RES },
659 { "req_len", smp_fetch_req_len, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
660 { "req_ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
661 { "req_ssl_sni", smp_fetch_ssl_hello_sni, 0, NULL, SMP_T_CSTR, SMP_USE_L6REQ },
662 { "req_ssl_ver", smp_fetch_req_ssl_ver, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
Willy Tarreaufa957342013-01-14 16:07:52 +0100663
664 { "req.len", smp_fetch_req_len, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
665 { "req.payload", smp_fetch_payload, ARG2(2,UINT,UINT), val_payload, SMP_T_CBIN, SMP_USE_L6REQ },
666 { "req.payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_CBIN, SMP_USE_L6REQ },
667 { "req.rdp_cookie", smp_fetch_rdp_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_L6REQ },
668 { "req.rdp_cookie_cnt", smp_fetch_rdp_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_L6REQ },
669 { "req.ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
670 { "req.ssl_sni", smp_fetch_ssl_hello_sni, 0, NULL, SMP_T_CSTR, SMP_USE_L6REQ },
671 { "req.ssl_ver", smp_fetch_req_ssl_ver, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
672 { "res.payload", smp_fetch_payload, ARG2(2,UINT,UINT), val_payload, SMP_T_CBIN, SMP_USE_L6RES },
673 { "res.payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_CBIN, SMP_USE_L6RES },
674 { "res.ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6RES },
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100675 { "wait_end", smp_fetch_wait_end, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN },
676 { /* END */ },
677}};
678
679
680/* Note: must not be declared <const> as its list will be overwritten.
681 * Please take care of keeping this list alphabetically sorted.
682 */
683static struct acl_kw_list acl_kws = {{ },{
Willy Tarreaufa957342013-01-14 16:07:52 +0100684 { "payload", "req.payload", acl_parse_str, acl_match_str, ACL_USE_L6REQ_VOLATILE },
685 { "payload_lv", "req.payload_lv", acl_parse_str, acl_match_str, ACL_USE_L6REQ_VOLATILE },
686 { "rep_ssl_hello_type", "res.ssl_hello_type", acl_parse_int, acl_match_int, ACL_USE_L6RTR_VOLATILE },
687 { "req_len", "req.len", acl_parse_int, acl_match_int, ACL_USE_L6REQ_VOLATILE },
688 { "req_rdp_cookie", "req.rdp_cookie", acl_parse_str, acl_match_str, ACL_USE_L6REQ_VOLATILE },
689 { "req_rdp_cookie_cnt", "req.rdp_cookie_cnt", acl_parse_int, acl_match_int, ACL_USE_L6REQ_VOLATILE },
690 { "req_ssl_hello_type", "req.ssl_hello_type", acl_parse_int, acl_match_int, ACL_USE_L6REQ_VOLATILE },
691 { "req_ssl_sni", "req.ssl_sni", acl_parse_str, acl_match_str, ACL_USE_L6REQ_VOLATILE },
692 { "req_ssl_ver", "req.ssl_ver", acl_parse_dotted_ver, acl_match_int, ACL_USE_L6REQ_VOLATILE },
693 { "wait_end", NULL, acl_parse_nothing, acl_match_nothing, ACL_USE_NOTHING },
Willy Tarreaud4c33c82013-01-07 21:59:07 +0100694 { /* END */ },
695}};
696
697
698__attribute__((constructor))
699static void __payload_init(void)
700{
701 sample_register_fetches(&smp_kws);
702 acl_register_keywords(&acl_kws);
703}
704
705/*
706 * Local variables:
707 * c-indent-level: 8
708 * c-basic-offset: 8
709 * End:
710 */