MEDIUM: sample: Remove types SMP_T_CSTR and SMP_T_CBIN, replace it by SMP_F_CONST flags

The operations applied on types SMP_T_CSTR and SMP_T_STR are the same,
but the check code and the declarations are double, because it must
declare action for SMP_T_C* and SMP_T_*. The declared actions and checks
are the same. this complexify the code. Only the "conv" functions can
change from "C*" to "*"

Now, if a function needs to modify input string, it can call the new
function smp_dup(). This one duplicate data in a trash buffer.
This commit is contained in:
Thierry FOURNIER 2013-12-17 00:20:33 +01:00 committed by Willy Tarreau
parent b050463375
commit 7654c9ff44
11 changed files with 199 additions and 161 deletions

View File

@ -43,6 +43,7 @@ struct sample_fetch *find_sample_fetch(const char *kw, int len);
int smp_resolve_args(struct proxy *p); int smp_resolve_args(struct proxy *p);
int smp_expr_output_type(struct sample_expr *expr); int smp_expr_output_type(struct sample_expr *expr);
int c_none(struct sample *smp); int c_none(struct sample *smp);
int smp_dup(struct sample *smp);
/* /*
* This function just apply a cast on sample. It returns 0 if the cast is not * This function just apply a cast on sample. It returns 0 if the cast is not

View File

@ -40,8 +40,6 @@ enum {
SMP_T_IPV6, /* ipv6 type */ SMP_T_IPV6, /* ipv6 type */
SMP_T_STR, /* char string type */ SMP_T_STR, /* char string type */
SMP_T_BIN, /* buffer type */ SMP_T_BIN, /* buffer type */
SMP_T_CSTR, /* constant char string type, data need dup before conversion */
SMP_T_CBIN, /* constant buffer type, data need dup before conversion */
SMP_TYPES /* number of types, must always be last */ SMP_TYPES /* number of types, must always be last */
}; };
@ -203,6 +201,7 @@ enum {
SMP_F_VOL_TXN = 1 << 5, /* result sensitive to new transaction (eg: HTTP version) */ SMP_F_VOL_TXN = 1 << 5, /* result sensitive to new transaction (eg: HTTP version) */
SMP_F_VOL_SESS = 1 << 6, /* result sensitive to new session (eg: src IP) */ SMP_F_VOL_SESS = 1 << 6, /* result sensitive to new session (eg: src IP) */
SMP_F_VOLATILE = (1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6), /* any volatility condition */ SMP_F_VOLATILE = (1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6), /* any volatility condition */
SMP_F_CONST = 1 << 7, /* This sample use constant memory. May diplicate it before changes */
}; };
/* needed below */ /* needed below */

View File

@ -628,7 +628,8 @@ smp_fetch_res_comp_algo(struct proxy *px, struct session *l4, void *l7, unsigned
if (!l4->comp_algo) if (!l4->comp_algo)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags = SMP_F_CONST;
smp->data.str.str = l4->comp_algo->name; smp->data.str.str = l4->comp_algo->name;
smp->data.str.len = l4->comp_algo->name_len; smp->data.str.len = l4->comp_algo->name_len;
return 1; return 1;

View File

@ -4845,7 +4845,8 @@ static int stats_map_lookup(struct stream_interface *si)
chunk_reset(&trash); chunk_reset(&trash);
/* execute pattern matching */ /* execute pattern matching */
sample.type = SMP_T_CSTR; sample.type = SMP_T_STR;
sample.flags |= SMP_F_CONST;
sample.data.str.len = appctx->ctx.map.chunk.len; sample.data.str.len = appctx->ctx.map.chunk.len;
sample.data.str.str = appctx->ctx.map.chunk.str; sample.data.str.str = appctx->ctx.map.chunk.str;
pat = NULL; pat = NULL;
@ -4935,8 +4936,8 @@ static int stats_map_lookup(struct stream_interface *si)
else { else {
memcpy(&sample.data, &smp->data, sizeof(sample.data)); memcpy(&sample.data, &smp->data, sizeof(sample.data));
sample.type = smp->type; sample.type = smp->type;
if (sample_casts[sample.type][SMP_T_CSTR] && if (sample_casts[sample.type][SMP_T_STR] &&
sample_casts[sample.type][SMP_T_CSTR](&sample)) sample_casts[sample.type][SMP_T_STR](&sample))
chunk_appendf(&trash, "return=\"%s\", type=\"%s\"\n", chunk_appendf(&trash, "return=\"%s\", type=\"%s\"\n",
sample.data.str.str, smp_to_type[smp->type]); sample.data.str.str, smp_to_type[smp->type]);
else else

View File

@ -61,15 +61,16 @@ int map_parse_ip6(const char *text, struct sample_storage *smp)
/* Parse a string and store a pointer to it into the sample. The original /* Parse a string and store a pointer to it into the sample. The original
* string must be left in memory because we return a direct memory reference. * string must be left in memory because we return a direct memory reference.
* The output type is CSTR. * The output type is SMP_T_STR. There is no risk that the data will be
* overwritten because sample_conv_map() makes a const sample with this
* output.
*/ */
int map_parse_str(const char *text, struct sample_storage *smp) int map_parse_str(const char *text, struct sample_storage *smp)
{ {
/* The loose of the "const" is balanced by the SMP_T_CSTR type */
smp->data.str.str = (char *)text; smp->data.str.str = (char *)text;
smp->data.str.len = strlen(text); smp->data.str.len = strlen(text);
smp->data.str.size = smp->data.str.len + 1; smp->data.str.size = smp->data.str.len + 1;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
return 1; return 1;
} }
@ -472,6 +473,7 @@ static int sample_conv_map(const struct arg *arg_p, struct sample *smp)
/* copy new data */ /* copy new data */
smp->type = sample->type; smp->type = sample->type;
smp->flags |= SMP_F_CONST;
memcpy(&smp->data, &sample->data, sizeof(smp->data)); memcpy(&smp->data, &sample->data, sizeof(smp->data));
return 1; return 1;
} }

View File

@ -94,15 +94,15 @@ int pat_match_types[PAT_MATCH_NUM] = {
[PAT_MATCH_BOOL] = SMP_T_UINT, [PAT_MATCH_BOOL] = SMP_T_UINT,
[PAT_MATCH_INT] = SMP_T_UINT, [PAT_MATCH_INT] = SMP_T_UINT,
[PAT_MATCH_IP] = SMP_T_ADDR, [PAT_MATCH_IP] = SMP_T_ADDR,
[PAT_MATCH_BIN] = SMP_T_CBIN, [PAT_MATCH_BIN] = SMP_T_BIN,
[PAT_MATCH_LEN] = SMP_T_CSTR, [PAT_MATCH_LEN] = SMP_T_STR,
[PAT_MATCH_STR] = SMP_T_CSTR, [PAT_MATCH_STR] = SMP_T_STR,
[PAT_MATCH_BEG] = SMP_T_CSTR, [PAT_MATCH_BEG] = SMP_T_STR,
[PAT_MATCH_SUB] = SMP_T_CSTR, [PAT_MATCH_SUB] = SMP_T_STR,
[PAT_MATCH_DIR] = SMP_T_CSTR, [PAT_MATCH_DIR] = SMP_T_STR,
[PAT_MATCH_DOM] = SMP_T_CSTR, [PAT_MATCH_DOM] = SMP_T_STR,
[PAT_MATCH_END] = SMP_T_CSTR, [PAT_MATCH_END] = SMP_T_STR,
[PAT_MATCH_REG] = SMP_T_CSTR, [PAT_MATCH_REG] = SMP_T_STR,
}; };
/* /*
@ -202,8 +202,8 @@ int pat_parse_nothing(const char *text, struct pattern *pattern, char **err)
/* Parse a string. It is allocated and duplicated. */ /* Parse a string. It is allocated and duplicated. */
int pat_parse_str(const char *text, struct pattern *pattern, char **err) int pat_parse_str(const char *text, struct pattern *pattern, char **err)
{ {
pattern->type = SMP_T_CSTR; pattern->type = SMP_T_STR;
pattern->expect_type = SMP_T_CSTR; pattern->expect_type = SMP_T_STR;
pattern->ptr.str = (char *)text; pattern->ptr.str = (char *)text;
pattern->len = strlen(text); pattern->len = strlen(text);
return 1; return 1;
@ -214,8 +214,8 @@ int pat_parse_bin(const char *text, struct pattern *pattern, char **err)
{ {
struct chunk *trash; struct chunk *trash;
pattern->type = SMP_T_CBIN; pattern->type = SMP_T_BIN;
pattern->expect_type = SMP_T_CBIN; pattern->expect_type = SMP_T_BIN;
trash = get_trash_chunk(); trash = get_trash_chunk();
pattern->len = trash->size; pattern->len = trash->size;
pattern->ptr.str = trash->str; pattern->ptr.str = trash->str;
@ -238,7 +238,7 @@ int pat_parse_reg(const char *text, struct pattern *pattern, char **err)
pattern->ptr.reg->regstr = (char *)text; pattern->ptr.reg->regstr = (char *)text;
pattern->freeptrbuf = NULL; pattern->freeptrbuf = NULL;
pattern->expect_type = SMP_T_CSTR; pattern->expect_type = SMP_T_STR;
return 1; return 1;
} }
@ -328,7 +328,7 @@ int pat_parse_len(const char *text, struct pattern *pattern, char **err)
int ret; int ret;
ret = pat_parse_int(text, pattern, err); ret = pat_parse_int(text, pattern, err);
pattern->expect_type = SMP_T_CSTR; pattern->expect_type = SMP_T_STR;
return ret; return ret;
} }
@ -933,7 +933,7 @@ int pat_idx_tree_str(struct pattern_expr *expr, struct pattern *pat, char **err)
struct pattern_tree *node; struct pattern_tree *node;
/* Only string can be indexed */ /* Only string can be indexed */
if (pat->type != SMP_T_CSTR && pat->type != SMP_T_STR) { if (pat->type != SMP_T_STR) {
memprintf(err, "internal error: string expected, but the type is '%s'", memprintf(err, "internal error: string expected, but the type is '%s'",
smp_to_type[pat->type]); smp_to_type[pat->type]);
return 0; return 0;
@ -1149,7 +1149,6 @@ int pattern_lookup(const char *key, struct pattern_expr *expr,
if (!eb_is_empty(&expr->pattern_tree) && pattern.type != SMP_T_IPV6) { if (!eb_is_empty(&expr->pattern_tree) && pattern.type != SMP_T_IPV6) {
/* Check the pattern type */ /* Check the pattern type */
if (pattern.type != SMP_T_STR && if (pattern.type != SMP_T_STR &&
pattern.type != SMP_T_CSTR &&
pattern.type != SMP_T_IPV4) { pattern.type != SMP_T_IPV4) {
memprintf(err, "Unexpected pattern type."); memprintf(err, "Unexpected pattern type.");
return 0; return 0;

View File

@ -375,10 +375,10 @@ smp_fetch_ssl_hello_sni(struct proxy *px, struct session *s, void *l7, unsigned
name_len = (data[7] << 8) + data[8]; name_len = (data[7] << 8) + data[8];
if (name_type == 0) { /* hostname */ if (name_type == 0) { /* hostname */
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->data.str.str = (char *)data + 9; smp->data.str.str = (char *)data + 9;
smp->data.str.len = name_len; smp->data.str.len = name_len;
smp->flags = SMP_F_VOLATILE; smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
return 1; return 1;
} }
} }
@ -410,8 +410,8 @@ fetch_rdp_cookie_name(struct session *s, struct sample *smp, const char *cname,
if (!s || !s->req) if (!s || !s->req)
return 0; return 0;
smp->flags = 0; smp->flags = SMP_F_CONST;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
bleft = s->req->buf->i; bleft = s->req->buf->i;
if (bleft <= 11) if (bleft <= 11)
@ -478,11 +478,11 @@ fetch_rdp_cookie_name(struct session *s, struct sample *smp, const char *cname,
goto not_cookie; goto not_cookie;
smp->data.str.len = (char *)data - smp->data.str.str; smp->data.str.len = (char *)data - smp->data.str.str;
smp->flags = SMP_F_VOLATILE; smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
return 1; return 1;
too_short: too_short:
smp->flags = SMP_F_MAY_CHANGE; smp->flags = SMP_F_MAY_CHANGE | SMP_F_CONST;
not_cookie: not_cookie:
return 0; return 0;
} }
@ -566,13 +566,13 @@ smp_fetch_payload_lv(struct proxy *px, struct session *s, void *l7, unsigned int
goto too_short; goto too_short;
/* init chunk as read only */ /* init chunk as read only */
smp->type = SMP_T_CBIN; smp->type = SMP_T_BIN;
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size); chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size);
smp->flags = SMP_F_VOLATILE;
return 1; return 1;
too_short: too_short:
smp->flags = SMP_F_MAY_CHANGE; smp->flags = SMP_F_MAY_CHANGE | SMP_F_CONST;
return 0; return 0;
} }
@ -603,16 +603,16 @@ smp_fetch_payload(struct proxy *px, struct session *s, void *l7, unsigned int op
goto too_short; goto too_short;
/* init chunk as read only */ /* init chunk as read only */
smp->type = SMP_T_CBIN; smp->type = SMP_T_BIN;
smp->flags = SMP_F_VOLATILE | SMP_F_CONST;
chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size ? buf_size : (chn->buf->i - buf_offset)); chunk_initlen(&smp->data.str, chn->buf->p + buf_offset, 0, buf_size ? buf_size : (chn->buf->i - buf_offset));
smp->flags = SMP_F_VOLATILE;
if (!buf_size && !channel_full(chn) && !channel_input_closed(chn)) if (!buf_size && !channel_full(chn) && !channel_input_closed(chn))
smp->flags |= SMP_F_MAY_CHANGE; smp->flags |= SMP_F_MAY_CHANGE;
return 1; return 1;
too_short: too_short:
smp->flags = SMP_F_MAY_CHANGE; smp->flags = SMP_F_MAY_CHANGE | SMP_F_CONST;
return 0; return 0;
} }
@ -650,27 +650,27 @@ static int val_payload_lv(struct arg *arg, char **err_msg)
* instance IPv4/IPv6 must be declared IPv4. * instance IPv4/IPv6 must be declared IPv4.
*/ */
static struct sample_fetch_kw_list smp_kws = {ILH, { static struct sample_fetch_kw_list smp_kws = {ILH, {
{ "payload", smp_fetch_payload, ARG2(2,UINT,UINT), NULL, SMP_T_CBIN, SMP_USE_L6REQ|SMP_USE_L6RES }, { "payload", smp_fetch_payload, ARG2(2,UINT,UINT), NULL, SMP_T_BIN, SMP_USE_L6REQ|SMP_USE_L6RES },
{ "payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_CBIN, SMP_USE_L6REQ|SMP_USE_L6RES }, { "payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_BIN, SMP_USE_L6REQ|SMP_USE_L6RES },
{ "rdp_cookie", smp_fetch_rdp_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_L6REQ }, { "rdp_cookie", smp_fetch_rdp_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_L6REQ },
{ "rdp_cookie_cnt", smp_fetch_rdp_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_L6REQ }, { "rdp_cookie_cnt", smp_fetch_rdp_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_L6REQ },
{ "rep_ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6RES }, { "rep_ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6RES },
{ "req_len", smp_fetch_len, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ }, { "req_len", smp_fetch_len, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
{ "req_ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ }, { "req_ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
{ "req_ssl_sni", smp_fetch_ssl_hello_sni, 0, NULL, SMP_T_CSTR, SMP_USE_L6REQ }, { "req_ssl_sni", smp_fetch_ssl_hello_sni, 0, NULL, SMP_T_STR, SMP_USE_L6REQ },
{ "req_ssl_ver", smp_fetch_req_ssl_ver, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ }, { "req_ssl_ver", smp_fetch_req_ssl_ver, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
{ "req.len", smp_fetch_len, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ }, { "req.len", smp_fetch_len, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
{ "req.payload", smp_fetch_payload, ARG2(2,UINT,UINT), NULL, SMP_T_CBIN, SMP_USE_L6REQ }, { "req.payload", smp_fetch_payload, ARG2(2,UINT,UINT), NULL, SMP_T_BIN, SMP_USE_L6REQ },
{ "req.payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_CBIN, SMP_USE_L6REQ }, { "req.payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_BIN, SMP_USE_L6REQ },
{ "req.rdp_cookie", smp_fetch_rdp_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_L6REQ }, { "req.rdp_cookie", smp_fetch_rdp_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_L6REQ },
{ "req.rdp_cookie_cnt", smp_fetch_rdp_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_L6REQ }, { "req.rdp_cookie_cnt", smp_fetch_rdp_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_L6REQ },
{ "req.ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ }, { "req.ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
{ "req.ssl_sni", smp_fetch_ssl_hello_sni, 0, NULL, SMP_T_CSTR, SMP_USE_L6REQ }, { "req.ssl_sni", smp_fetch_ssl_hello_sni, 0, NULL, SMP_T_STR, SMP_USE_L6REQ },
{ "req.ssl_ver", smp_fetch_req_ssl_ver, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ }, { "req.ssl_ver", smp_fetch_req_ssl_ver, 0, NULL, SMP_T_UINT, SMP_USE_L6REQ },
{ "res.len", smp_fetch_len, 0, NULL, SMP_T_UINT, SMP_USE_L6RES }, { "res.len", smp_fetch_len, 0, NULL, SMP_T_UINT, SMP_USE_L6RES },
{ "res.payload", smp_fetch_payload, ARG2(2,UINT,UINT), NULL, SMP_T_CBIN, SMP_USE_L6RES }, { "res.payload", smp_fetch_payload, ARG2(2,UINT,UINT), NULL, SMP_T_BIN, SMP_USE_L6RES },
{ "res.payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_CBIN, SMP_USE_L6RES }, { "res.payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_BIN, SMP_USE_L6RES },
{ "res.ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6RES }, { "res.ssl_hello_type", smp_fetch_ssl_hello_type, 0, NULL, SMP_T_UINT, SMP_USE_L6RES },
{ "wait_end", smp_fetch_wait_end, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN }, { "wait_end", smp_fetch_wait_end, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN },
{ /* END */ }, { /* END */ },

View File

@ -8990,7 +8990,7 @@ static int pat_parse_meth(const char *text, struct pattern *pattern, char **err)
return 0; return 0;
} }
pattern->ptr.str = trash->str; pattern->ptr.str = trash->str;
pattern->expect_type = SMP_T_CSTR; pattern->expect_type = SMP_T_STR;
pattern->len = len; pattern->len = len;
} }
else else
@ -9016,17 +9016,19 @@ smp_fetch_meth(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
CHECK_HTTP_MESSAGE_FIRST_PERM(); CHECK_HTTP_MESSAGE_FIRST_PERM();
meth = txn->meth; meth = txn->meth;
smp->flags = 0;
smp->type = SMP_T_UINT; smp->type = SMP_T_UINT;
smp->data.uint = meth; smp->data.uint = meth;
if (meth == HTTP_METH_OTHER) { if (meth == HTTP_METH_OTHER) {
if (txn->rsp.msg_state != HTTP_MSG_RPBEFORE) if (txn->rsp.msg_state != HTTP_MSG_RPBEFORE)
/* ensure the indexes are not affected */ /* ensure the indexes are not affected */
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
smp->data.str.len = txn->req.sl.rq.m_l; smp->data.str.len = txn->req.sl.rq.m_l;
smp->data.str.str = txn->req.chn->buf->p; smp->data.str.str = txn->req.chn->buf->p;
} }
smp->flags = SMP_F_VOL_1ST; smp->flags |= SMP_F_VOL_1ST;
return 1; return 1;
} }
@ -9075,11 +9077,11 @@ smp_fetch_rqver(struct proxy *px, struct session *l4, void *l7, unsigned int opt
if (len <= 0) if (len <= 0)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->data.str.str = ptr; smp->data.str.str = ptr;
smp->data.str.len = len; smp->data.str.len = len;
smp->flags = SMP_F_VOL_1ST; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
return 1; return 1;
} }
@ -9103,11 +9105,11 @@ smp_fetch_stver(struct proxy *px, struct session *l4, void *l7, unsigned int opt
if (len <= 0) if (len <= 0)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->data.str.str = ptr; smp->data.str.str = ptr;
smp->data.str.len = len; smp->data.str.len = len;
smp->flags = SMP_F_VOL_1ST; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
return 1; return 1;
} }
@ -9143,10 +9145,10 @@ smp_fetch_url(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
CHECK_HTTP_MESSAGE_FIRST(); CHECK_HTTP_MESSAGE_FIRST();
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->data.str.len = txn->req.sl.rq.u_l; smp->data.str.len = txn->req.sl.rq.u_l;
smp->data.str.str = txn->req.chn->buf->p + txn->req.sl.rq.u; smp->data.str.str = txn->req.chn->buf->p + txn->req.sl.rq.u;
smp->flags = SMP_F_VOL_1ST; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
return 1; return 1;
} }
@ -9238,8 +9240,8 @@ smp_fetch_fhdr(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
/* prepare to report multiple occurrences for ACL fetches */ /* prepare to report multiple occurrences for ACL fetches */
smp->flags |= SMP_F_NOT_LAST; smp->flags |= SMP_F_NOT_LAST;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_VOL_HDR; smp->flags |= SMP_F_VOL_HDR | SMP_F_CONST;
if (http_get_fhdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.str.str, &smp->data.str.len)) if (http_get_fhdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.str.str, &smp->data.str.len))
return 1; return 1;
@ -9326,8 +9328,8 @@ smp_fetch_hdr(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
/* prepare to report multiple occurrences for ACL fetches */ /* prepare to report multiple occurrences for ACL fetches */
smp->flags |= SMP_F_NOT_LAST; smp->flags |= SMP_F_NOT_LAST;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_VOL_HDR; smp->flags |= SMP_F_VOL_HDR | SMP_F_CONST;
if (http_get_hdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.str.str, &smp->data.str.len)) if (http_get_hdr(msg, name_str, name_len, idx, occ, ctx, &smp->data.str.str, &smp->data.str.len))
return 1; return 1;
@ -9434,14 +9436,14 @@ smp_fetch_path(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
return 0; return 0;
/* OK, we got the '/' ! */ /* OK, we got the '/' ! */
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->data.str.str = ptr; smp->data.str.str = ptr;
while (ptr < end && *ptr != '?') while (ptr < end && *ptr != '?')
ptr++; ptr++;
smp->data.str.len = ptr - smp->data.str.str; smp->data.str.len = ptr - smp->data.str.str;
smp->flags = SMP_F_VOL_1ST; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
return 1; return 1;
} }
@ -9652,7 +9654,8 @@ smp_fetch_http_auth_grp(struct proxy *px, struct session *l4, void *l7, unsigned
/* pat_match_auth() will need the user list */ /* pat_match_auth() will need the user list */
smp->ctx.a[0] = args->data.usr; smp->ctx.a[0] = args->data.usr;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags = SMP_F_CONST;
smp->data.str.str = l4->txn.auth.user; smp->data.str.str = l4->txn.auth.user;
smp->data.str.len = strlen(l4->txn.auth.user); smp->data.str.len = strlen(l4->txn.auth.user);
@ -9773,7 +9776,8 @@ smp_fetch_capture_header_req(struct proxy *px, struct session *l4, void *l7, uns
if (idx > (fe->nb_req_cap - 1) || txn->req.cap == NULL || txn->req.cap[idx] == NULL) if (idx > (fe->nb_req_cap - 1) || txn->req.cap == NULL || txn->req.cap[idx] == NULL)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
smp->data.str.str = txn->req.cap[idx]; smp->data.str.str = txn->req.cap[idx];
smp->data.str.len = strlen(txn->req.cap[idx]); smp->data.str.len = strlen(txn->req.cap[idx]);
@ -9799,7 +9803,8 @@ smp_fetch_capture_header_res(struct proxy *px, struct session *l4, void *l7, uns
if (idx > (fe->nb_rsp_cap - 1) || txn->rsp.cap == NULL || txn->rsp.cap[idx] == NULL) if (idx > (fe->nb_rsp_cap - 1) || txn->rsp.cap == NULL || txn->rsp.cap[idx] == NULL)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
smp->data.str.str = txn->rsp.cap[idx]; smp->data.str.str = txn->rsp.cap[idx];
smp->data.str.len = strlen(txn->rsp.cap[idx]); smp->data.str.len = strlen(txn->rsp.cap[idx]);
@ -9827,7 +9832,8 @@ smp_fetch_capture_req_method(struct proxy *px, struct session *l4, void *l7, uns
temp->str = txn->uri; temp->str = txn->uri;
temp->len = ptr - txn->uri; temp->len = ptr - txn->uri;
smp->data.str = *temp; smp->data.str = *temp;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags = SMP_F_CONST;
return 1; return 1;
@ -9864,7 +9870,8 @@ smp_fetch_capture_req_uri(struct proxy *px, struct session *l4, void *l7, unsign
smp->data.str = *temp; smp->data.str = *temp;
smp->data.str.len = ptr - temp->str; smp->data.str.len = ptr - temp->str;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags = SMP_F_CONST;
return 1; return 1;
} }
@ -9948,7 +9955,8 @@ smp_fetch_cookie(struct proxy *px, struct session *l4, void *l7, unsigned int op
smp->ctx.a[1] = smp->ctx.a[0] + ctx->vlen; smp->ctx.a[1] = smp->ctx.a[0] + ctx->vlen;
} }
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
smp->ctx.a[0] = extract_cookie_value(smp->ctx.a[0], smp->ctx.a[1], smp->ctx.a[0] = extract_cookie_value(smp->ctx.a[0], smp->ctx.a[1],
args->data.str.str, args->data.str.len, args->data.str.str, args->data.str.len,
(opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ, (opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ,
@ -10024,7 +10032,8 @@ smp_fetch_cookie_cnt(struct proxy *px, struct session *l4, void *l7, unsigned in
val_end = val_beg + ctx.vlen; val_end = val_beg + ctx.vlen;
} }
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
while ((val_beg = extract_cookie_value(val_beg, val_end, while ((val_beg = extract_cookie_value(val_beg, val_end,
args->data.str.str, args->data.str.len, args->data.str.str, args->data.str.len,
(opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ, (opt & SMP_OPT_DIR) == SMP_OPT_DIR_REQ,
@ -10171,8 +10180,8 @@ smp_fetch_url_param(struct proxy *px, struct session *l4, void *l7, unsigned int
delim)) delim))
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags = SMP_F_VOL_1ST; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST;
return 1; return 1;
} }
@ -10424,23 +10433,23 @@ static struct acl_kw_list acl_kws = {ILH, {
/************************************************************************/ /************************************************************************/
/* Note: must not be declared <const> as its list will be overwritten */ /* Note: must not be declared <const> as its list will be overwritten */
static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
{ "base", smp_fetch_base, 0, NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "base", smp_fetch_base, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "base32", smp_fetch_base32, 0, NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "base32", smp_fetch_base32, 0, NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "base32+src", smp_fetch_base32_src, 0, NULL, SMP_T_BIN, SMP_USE_HRQHV }, { "base32+src", smp_fetch_base32_src, 0, NULL, SMP_T_BIN, SMP_USE_HRQHV },
{ "capture.req.uri", smp_fetch_capture_req_uri, 0, NULL, SMP_T_CSTR, SMP_USE_HRQHP }, { "capture.req.uri", smp_fetch_capture_req_uri, 0, NULL, SMP_T_STR, SMP_USE_HRQHP },
{ "capture.req.method", smp_fetch_capture_req_method, 0, NULL, SMP_T_CSTR, SMP_USE_HRQHP }, { "capture.req.method", smp_fetch_capture_req_method, 0, NULL, SMP_T_STR, SMP_USE_HRQHP },
/* capture are allocated and are permanent in the session */ /* capture are allocated and are permanent in the session */
{ "capture.req.hdr", smp_fetch_capture_header_req, ARG1(1, UINT), NULL, SMP_T_CSTR, SMP_USE_HRQHP }, { "capture.req.hdr", smp_fetch_capture_header_req, ARG1(1, UINT), NULL, SMP_T_STR, SMP_USE_HRQHP },
{ "capture.res.hdr", smp_fetch_capture_header_res, ARG1(1, UINT), NULL, SMP_T_CSTR, SMP_USE_HRSHP }, { "capture.res.hdr", smp_fetch_capture_header_res, ARG1(1, UINT), NULL, SMP_T_STR, SMP_USE_HRSHP },
/* cookie is valid in both directions (eg: for "stick ...") but cook* /* cookie is valid in both directions (eg: for "stick ...") but cook*
* are only here to match the ACL's name, are request-only and are used * are only here to match the ACL's name, are request-only and are used
* for ACL compatibility only. * for ACL compatibility only.
*/ */
{ "cook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "cook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "cookie", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_HRQHV|SMP_USE_HRSHV }, { "cookie", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRQHV|SMP_USE_HRSHV },
{ "cook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "cook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "cook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "cook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV },
@ -10448,73 +10457,73 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
* only here to match the ACL's name, are request-only and are used for * only here to match the ACL's name, are request-only and are used for
* ACL compatibility only. * ACL compatibility only.
*/ */
{ "hdr", smp_fetch_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_CSTR, SMP_USE_HRQHV|SMP_USE_HRSHV }, { "hdr", smp_fetch_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_STR, SMP_USE_HRQHV|SMP_USE_HRSHV },
{ "hdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "hdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "hdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRQHV }, { "hdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRQHV },
{ "hdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_UINT, SMP_USE_HRQHV }, { "hdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_UINT, SMP_USE_HRQHV },
{ "http_auth", smp_fetch_http_auth, ARG1(1,USR), NULL, SMP_T_BOOL, SMP_USE_HRQHV }, { "http_auth", smp_fetch_http_auth, ARG1(1,USR), NULL, SMP_T_BOOL, SMP_USE_HRQHV },
{ "http_auth_group", smp_fetch_http_auth_grp, ARG1(1,USR), NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "http_auth_group", smp_fetch_http_auth_grp, ARG1(1,USR), NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "http_first_req", smp_fetch_http_first_req, 0, NULL, SMP_T_BOOL, SMP_USE_HRQHP }, { "http_first_req", smp_fetch_http_first_req, 0, NULL, SMP_T_BOOL, SMP_USE_HRQHP },
{ "method", smp_fetch_meth, 0, NULL, SMP_T_UINT, SMP_USE_HRQHP }, { "method", smp_fetch_meth, 0, NULL, SMP_T_UINT, SMP_USE_HRQHP },
{ "path", smp_fetch_path, 0, NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "path", smp_fetch_path, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
/* HTTP protocol on the request path */ /* HTTP protocol on the request path */
{ "req.proto_http", smp_fetch_proto_http, 0, NULL, SMP_T_BOOL, SMP_USE_HRQHP }, { "req.proto_http", smp_fetch_proto_http, 0, NULL, SMP_T_BOOL, SMP_USE_HRQHP },
{ "req_proto_http", smp_fetch_proto_http, 0, NULL, SMP_T_BOOL, SMP_USE_HRQHP }, { "req_proto_http", smp_fetch_proto_http, 0, NULL, SMP_T_BOOL, SMP_USE_HRQHP },
/* HTTP version on the request path */ /* HTTP version on the request path */
{ "req.ver", smp_fetch_rqver, 0, NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "req.ver", smp_fetch_rqver, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "req_ver", smp_fetch_rqver, 0, NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "req_ver", smp_fetch_rqver, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
/* HTTP version on the response path */ /* HTTP version on the response path */
{ "res.ver", smp_fetch_stver, 0, NULL, SMP_T_CSTR, SMP_USE_HRSHV }, { "res.ver", smp_fetch_stver, 0, NULL, SMP_T_STR, SMP_USE_HRSHV },
{ "resp_ver", smp_fetch_stver, 0, NULL, SMP_T_CSTR, SMP_USE_HRSHV }, { "resp_ver", smp_fetch_stver, 0, NULL, SMP_T_STR, SMP_USE_HRSHV },
/* explicit req.{cook,hdr} are used to force the fetch direction to be request-only */ /* explicit req.{cook,hdr} are used to force the fetch direction to be request-only */
{ "req.cook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "req.cook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "req.cook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "req.cook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "req.cook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "req.cook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "req.fhdr", smp_fetch_fhdr, ARG2(0,STR,SINT), val_hdr, SMP_T_CSTR, SMP_USE_HRQHV }, { "req.fhdr", smp_fetch_fhdr, ARG2(0,STR,SINT), val_hdr, SMP_T_STR, SMP_USE_HRQHV },
{ "req.fhdr_cnt", smp_fetch_fhdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "req.fhdr_cnt", smp_fetch_fhdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "req.hdr", smp_fetch_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_CSTR, SMP_USE_HRQHV }, { "req.hdr", smp_fetch_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_STR, SMP_USE_HRQHV },
{ "req.hdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "req.hdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "req.hdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRQHV }, { "req.hdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRQHV },
{ "req.hdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_UINT, SMP_USE_HRQHV }, { "req.hdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_UINT, SMP_USE_HRQHV },
/* explicit req.{cook,hdr} are used to force the fetch direction to be response-only */ /* explicit req.{cook,hdr} are used to force the fetch direction to be response-only */
{ "res.cook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_HRSHV }, { "res.cook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRSHV },
{ "res.cook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV }, { "res.cook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV },
{ "res.cook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV }, { "res.cook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV },
{ "res.fhdr", smp_fetch_fhdr, ARG2(0,STR,SINT), val_hdr, SMP_T_CSTR, SMP_USE_HRSHV }, { "res.fhdr", smp_fetch_fhdr, ARG2(0,STR,SINT), val_hdr, SMP_T_STR, SMP_USE_HRSHV },
{ "res.fhdr_cnt", smp_fetch_fhdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV }, { "res.fhdr_cnt", smp_fetch_fhdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV },
{ "res.hdr", smp_fetch_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_CSTR, SMP_USE_HRSHV }, { "res.hdr", smp_fetch_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_STR, SMP_USE_HRSHV },
{ "res.hdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV }, { "res.hdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV },
{ "res.hdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRSHV }, { "res.hdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRSHV },
{ "res.hdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_UINT, SMP_USE_HRSHV }, { "res.hdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_UINT, SMP_USE_HRSHV },
/* scook is valid only on the response and is used for ACL compatibility */ /* scook is valid only on the response and is used for ACL compatibility */
{ "scook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_HRSHV }, { "scook", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRSHV },
{ "scook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV }, { "scook_cnt", smp_fetch_cookie_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV },
{ "scook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV }, { "scook_val", smp_fetch_cookie_val, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV },
{ "set-cookie", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_CSTR, SMP_USE_HRSHV }, /* deprecated */ { "set-cookie", smp_fetch_cookie, ARG1(0,STR), NULL, SMP_T_STR, SMP_USE_HRSHV }, /* deprecated */
/* shdr is valid only on the response and is used for ACL compatibility */ /* shdr is valid only on the response and is used for ACL compatibility */
{ "shdr", smp_fetch_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_CSTR, SMP_USE_HRSHV }, { "shdr", smp_fetch_hdr, ARG2(0,STR,SINT), val_hdr, SMP_T_STR, SMP_USE_HRSHV },
{ "shdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV }, { "shdr_cnt", smp_fetch_hdr_cnt, ARG1(0,STR), NULL, SMP_T_UINT, SMP_USE_HRSHV },
{ "shdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRSHV }, { "shdr_ip", smp_fetch_hdr_ip, ARG2(0,STR,SINT), val_hdr, SMP_T_IPV4, SMP_USE_HRSHV },
{ "shdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_UINT, SMP_USE_HRSHV }, { "shdr_val", smp_fetch_hdr_val, ARG2(0,STR,SINT), val_hdr, SMP_T_UINT, SMP_USE_HRSHV },
{ "status", smp_fetch_stcode, 0, NULL, SMP_T_UINT, SMP_USE_HRSHP }, { "status", smp_fetch_stcode, 0, NULL, SMP_T_UINT, SMP_USE_HRSHP },
{ "url", smp_fetch_url, 0, NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "url", smp_fetch_url, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "url32", smp_fetch_url32, 0, NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "url32", smp_fetch_url32, 0, NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "url32+src", smp_fetch_url32_src, 0, NULL, SMP_T_BIN, SMP_USE_HRQHV }, { "url32+src", smp_fetch_url32_src, 0, NULL, SMP_T_BIN, SMP_USE_HRQHV },
{ "url_ip", smp_fetch_url_ip, 0, NULL, SMP_T_IPV4, SMP_USE_HRQHV }, { "url_ip", smp_fetch_url_ip, 0, NULL, SMP_T_IPV4, SMP_USE_HRQHV },
{ "url_port", smp_fetch_url_port, 0, NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "url_port", smp_fetch_url_port, 0, NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "url_param", smp_fetch_url_param, ARG2(1,STR,STR), NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "url_param", smp_fetch_url_param, ARG2(1,STR,STR), NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "urlp" , smp_fetch_url_param, ARG2(1,STR,STR), NULL, SMP_T_CSTR, SMP_USE_HRQHV }, { "urlp" , smp_fetch_url_param, ARG2(1,STR,STR), NULL, SMP_T_STR, SMP_USE_HRQHV },
{ "urlp_val", smp_fetch_url_param_val, ARG2(1,STR,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV }, { "urlp_val", smp_fetch_url_param_val, ARG2(1,STR,STR), NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ /* END */ }, { /* END */ },
}}; }};

View File

@ -38,8 +38,6 @@ const char *smp_to_type[SMP_TYPES] = {
[SMP_T_IPV6] = "ipv6", [SMP_T_IPV6] = "ipv6",
[SMP_T_STR] = "str", [SMP_T_STR] = "str",
[SMP_T_BIN] = "bin", [SMP_T_BIN] = "bin",
[SMP_T_CSTR] = "cstr",
[SMP_T_CBIN] = "cbin",
}; };
/* static sample used in sample_process() when <p> is NULL */ /* static sample used in sample_process() when <p> is NULL */
@ -425,6 +423,7 @@ static int c_ip2str(struct sample *smp)
trash->len = strlen(trash->str); trash->len = strlen(trash->str);
smp->data.str = *trash; smp->data.str = *trash;
smp->type = SMP_T_STR; smp->type = SMP_T_STR;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
@ -446,6 +445,7 @@ static int c_ipv62str(struct sample *smp)
trash->len = strlen(trash->str); trash->len = strlen(trash->str);
smp->data.str = *trash; smp->data.str = *trash;
smp->type = SMP_T_STR; smp->type = SMP_T_STR;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
@ -469,9 +469,11 @@ static int c_str2addr(struct sample *smp)
if (!buf2ip6(smp->data.str.str, smp->data.str.len, &smp->data.ipv6)) if (!buf2ip6(smp->data.str.str, smp->data.str.len, &smp->data.ipv6))
return 0; return 0;
smp->type = SMP_T_IPV6; smp->type = SMP_T_IPV6;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
smp->type = SMP_T_IPV4; smp->type = SMP_T_IPV4;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
@ -480,6 +482,7 @@ static int c_str2ip(struct sample *smp)
if (!buf2ip(smp->data.str.str, smp->data.str.len, &smp->data.ipv4)) if (!buf2ip(smp->data.str.str, smp->data.str.len, &smp->data.ipv4))
return 0; return 0;
smp->type = SMP_T_IPV4; smp->type = SMP_T_IPV4;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
@ -488,6 +491,7 @@ static int c_str2ipv6(struct sample *smp)
if (!buf2ip6(smp->data.str.str, smp->data.str.len, &smp->data.ipv6)) if (!buf2ip6(smp->data.str.str, smp->data.str.len, &smp->data.ipv6))
return 0; return 0;
smp->type = SMP_T_IPV6; smp->type = SMP_T_IPV6;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
@ -511,6 +515,7 @@ static int c_bin2str(struct sample *smp)
trash->str[ptr] = 0; trash->str[ptr] = 0;
smp->data.str = *trash; smp->data.str = *trash;
smp->type = SMP_T_STR; smp->type = SMP_T_STR;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
@ -529,36 +534,48 @@ static int c_int2str(struct sample *smp)
trash->len = strlen(pos); trash->len = strlen(pos);
smp->data.str = *trash; smp->data.str = *trash;
smp->type = SMP_T_STR; smp->type = SMP_T_STR;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
static inline void _c_datadup(struct sample *smp) /* This function duplicates data and removes the flag "const". */
int smp_dup(struct sample *smp)
{ {
struct chunk *trash = get_trash_chunk(); struct chunk *trash;
/* If the const flag is not set, we don't need to duplicate the
* pattern as it can be modified in place.
*/
if (!(smp->flags & SMP_F_CONST))
return 1;
switch (smp->type) {
case SMP_T_BOOL:
case SMP_T_UINT:
case SMP_T_SINT:
case SMP_T_ADDR:
case SMP_T_IPV4:
case SMP_T_IPV6:
/* These type are not const. */
break;
case SMP_T_STR:
case SMP_T_BIN:
/* Duplicate data. */
trash = get_trash_chunk();
trash->len = smp->data.str.len < trash->size ? smp->data.str.len : trash->size; trash->len = smp->data.str.len < trash->size ? smp->data.str.len : trash->size;
memcpy(trash->str, smp->data.str.str, trash->len); memcpy(trash->str, smp->data.str.str, trash->len);
smp->data.str = *trash; smp->data.str = *trash;
} break;
default:
/* Other cases are unexpected. */
return 0;
}
static int c_datadup(struct sample *smp) /* remove const flag */
{ smp->flags &= ~SMP_F_CONST;
_c_datadup(smp);
if (smp->type == SMP_T_CSTR)
smp->type = SMP_T_STR;
else
smp->type = SMP_T_BIN;
return 1; return 1;
} }
static int c_bindup(struct sample *smp)
{
_c_datadup(smp);
smp->type = SMP_T_BIN;
return 1;
}
int c_none(struct sample *smp) int c_none(struct sample *smp)
{ {
return 1; return 1;
@ -586,6 +603,7 @@ static int c_str2int(struct sample *smp)
smp->data.uint = ret; smp->data.uint = ret;
smp->type = SMP_T_UINT; smp->type = SMP_T_UINT;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
@ -596,17 +614,15 @@ static int c_str2int(struct sample *smp)
/*****************************************************************/ /*****************************************************************/
sample_cast_fct sample_casts[SMP_TYPES][SMP_TYPES] = { sample_cast_fct sample_casts[SMP_TYPES][SMP_TYPES] = {
/* to: BOOL UINT SINT ADDR IPV4 IPV6 STR BIN CSTR CBIN */ /* to: BOOL UINT SINT ADDR IPV4 IPV6 STR BIN */
/* from: BOOL */ { c_none, c_none, c_none, NULL, NULL, NULL, c_int2str, NULL, c_int2str, NULL, }, /* from: BOOL */ { c_none, c_none, c_none, NULL, NULL, NULL, c_int2str, NULL, },
/* UINT */ { c_none, c_none, c_none, c_int2ip, c_int2ip, NULL, c_int2str, NULL, c_int2str, NULL, }, /* UINT */ { c_none, c_none, c_none, c_int2ip, c_int2ip, NULL, c_int2str, NULL, },
/* SINT */ { c_none, c_none, c_none, c_int2ip, c_int2ip, NULL, c_int2str, NULL, c_int2str, NULL, }, /* SINT */ { c_none, c_none, c_none, c_int2ip, c_int2ip, NULL, c_int2str, NULL, },
/* ADDR */ { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, /* ADDR */ { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, },
/* IPV4 */ { NULL, c_ip2int, c_ip2int, c_none, c_none, c_ip2ipv6, c_ip2str, NULL, c_ip2str, NULL, }, /* IPV4 */ { NULL, c_ip2int, c_ip2int, c_none, c_none, c_ip2ipv6, c_ip2str, NULL, },
/* IPV6 */ { NULL, NULL, NULL, c_none, NULL, c_none, c_ipv62str, NULL, c_ipv62str, NULL, }, /* IPV6 */ { NULL, NULL, NULL, c_none, NULL, c_none, c_ipv62str, NULL, },
/* STR */ { c_str2int, c_str2int, c_str2int, c_str2addr, c_str2ip, c_str2ipv6, c_none, c_none, c_none, c_none, }, /* STR */ { c_str2int, c_str2int, c_str2int, c_str2addr, c_str2ip, c_str2ipv6, c_none, c_none, },
/* BIN */ { NULL, NULL, NULL, NULL, NULL, NULL, c_bin2str, c_none, c_bin2str, c_none, }, /* BIN */ { NULL, NULL, NULL, NULL, NULL, NULL, c_bin2str, c_none, },
/* CSTR */ { c_str2int, c_str2int, c_str2int, c_str2addr, c_str2ip, c_str2ipv6, c_datadup, c_bindup, c_none, c_none, },
/* CBIN */ { NULL, NULL, NULL, NULL, NULL, NULL, c_bin2str, c_datadup, c_bin2str, c_none, },
}; };
/* /*
@ -1094,13 +1110,13 @@ struct sample *sample_fetch_string(struct proxy *px, struct session *l4, void *l
if (!smp) if (!smp)
return NULL; return NULL;
if (!sample_casts[smp->type][SMP_T_CSTR]) if (!sample_casts[smp->type][SMP_T_STR])
return NULL; return NULL;
if (!sample_casts[smp->type][SMP_T_CSTR](smp)) if (!sample_casts[smp->type][SMP_T_STR](smp))
return NULL; return NULL;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
return smp; return smp;
} }
@ -1123,6 +1139,7 @@ static int sample_conv_bin2hex(const struct arg *arg_p, struct sample *smp)
} }
smp->data.str = *trash; smp->data.str = *trash;
smp->type = SMP_T_STR; smp->type = SMP_T_STR;
smp->flags &= ~SMP_F_CONST;
return 1; return 1;
} }
@ -1130,6 +1147,9 @@ static int sample_conv_str2lower(const struct arg *arg_p, struct sample *smp)
{ {
int i; int i;
if (!smp_dup(smp))
return 0;
if (!smp->data.str.size) if (!smp->data.str.size)
return 0; return 0;
@ -1137,7 +1157,6 @@ static int sample_conv_str2lower(const struct arg *arg_p, struct sample *smp)
if ((smp->data.str.str[i] >= 'A') && (smp->data.str.str[i] <= 'Z')) if ((smp->data.str.str[i] >= 'A') && (smp->data.str.str[i] <= 'Z'))
smp->data.str.str[i] += 'a' - 'A'; smp->data.str.str[i] += 'a' - 'A';
} }
smp->type = SMP_T_STR;
return 1; return 1;
} }
@ -1145,6 +1164,9 @@ static int sample_conv_str2upper(const struct arg *arg_p, struct sample *smp)
{ {
int i; int i;
if (!smp_dup(smp))
return 0;
if (!smp->data.str.size) if (!smp->data.str.size)
return 0; return 0;
@ -1152,7 +1174,6 @@ static int sample_conv_str2upper(const struct arg *arg_p, struct sample *smp)
if ((smp->data.str.str[i] >= 'a') && (smp->data.str.str[i] <= 'z')) if ((smp->data.str.str[i] >= 'a') && (smp->data.str.str[i] <= 'z'))
smp->data.str.str[i] += 'A' - 'a'; smp->data.str.str[i] += 'A' - 'a';
} }
smp->type = SMP_T_STR;
return 1; return 1;
} }
@ -1202,7 +1223,8 @@ smp_fetch_env(struct proxy *px, struct session *s, void *l7, unsigned int opt,
if (!env) if (!env)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags = SMP_F_CONST;
smp->data.str.str = env; smp->data.str.str = env;
smp->data.str.len = strlen(env); smp->data.str.len = strlen(env);
return 1; return 1;
@ -1252,7 +1274,7 @@ smp_fetch_rand(struct proxy *px, struct session *s, void *l7, unsigned int opt,
static struct sample_fetch_kw_list smp_kws = {ILH, { static struct sample_fetch_kw_list smp_kws = {ILH, {
{ "always_false", smp_fetch_false, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN }, { "always_false", smp_fetch_false, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN },
{ "always_true", smp_fetch_true, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN }, { "always_true", smp_fetch_true, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN },
{ "env", smp_fetch_env, ARG1(1,STR), NULL, SMP_T_CSTR, SMP_USE_INTRN }, { "env", smp_fetch_env, ARG1(1,STR), NULL, SMP_T_STR, SMP_USE_INTRN },
{ "date", smp_fetch_date, ARG1(0,SINT), NULL, SMP_T_UINT, SMP_USE_INTRN }, { "date", smp_fetch_date, ARG1(0,SINT), NULL, SMP_T_UINT, SMP_USE_INTRN },
{ "rand", smp_fetch_rand, ARG1(0,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN }, { "rand", smp_fetch_rand, ARG1(0,UINT), NULL, SMP_T_UINT, SMP_USE_INTRN },
{ /* END */ }, { /* END */ },

View File

@ -2192,7 +2192,8 @@ smp_fetch_ssl_c_sig_alg(struct proxy *px, struct session *l4, void *l7, unsigned
return 0; return 0;
} }
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
smp->data.str.len = strlen(smp->data.str.str); smp->data.str.len = strlen(smp->data.str.str);
X509_free(crt); X509_free(crt);
@ -2233,7 +2234,8 @@ smp_fetch_ssl_c_key_alg(struct proxy *px, struct session *l4, void *l7, unsigned
return 0; return 0;
} }
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
smp->data.str.len = strlen(smp->data.str.str); smp->data.str.len = strlen(smp->data.str.str);
X509_free(crt); X509_free(crt);
@ -2442,7 +2444,8 @@ smp_fetch_ssl_f_sig_alg(struct proxy *px, struct session *l4, void *l7, unsigned
if (!smp->data.str.str) if (!smp->data.str.str)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
smp->data.str.len = strlen(smp->data.str.str); smp->data.str.len = strlen(smp->data.str.str);
return 1; return 1;
@ -2479,7 +2482,8 @@ smp_fetch_ssl_f_key_alg(struct proxy *px, struct session *l4, void *l7, unsigned
if (!smp->data.str.str) if (!smp->data.str.str)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
smp->data.str.len = strlen(smp->data.str.str); smp->data.str.len = strlen(smp->data.str.str);
return 1; return 1;
@ -2610,7 +2614,8 @@ smp_fetch_ssl_fc_cipher(struct proxy *px, struct session *l4, void *l7, unsigned
if (!smp->data.str.str) if (!smp->data.str.str)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags |= SMP_F_CONST;
smp->data.str.len = strlen(smp->data.str.str); smp->data.str.len = strlen(smp->data.str.str);
return 1; return 1;
@ -2670,8 +2675,8 @@ smp_fetch_ssl_fc_npn(struct proxy *px, struct session *l4, void *l7, unsigned in
{ {
struct connection *conn; struct connection *conn;
smp->flags = 0; smp->flags = SMP_F_CONST;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
if (!l4) if (!l4)
return 0; return 0;
@ -2698,8 +2703,8 @@ smp_fetch_ssl_fc_alpn(struct proxy *px, struct session *l4, void *l7, unsigned i
{ {
struct connection *conn; struct connection *conn;
smp->flags = 0; smp->flags = SMP_F_CONST;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
if (!l4) if (!l4)
return 0; return 0;
@ -2738,7 +2743,8 @@ smp_fetch_ssl_fc_protocol(struct proxy *px, struct session *l4, void *l7, unsign
if (!smp->data.str.str) if (!smp->data.str.str)
return 0; return 0;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
smp->flags = SMP_F_CONST;
smp->data.str.len = strlen(smp->data.str.str); smp->data.str.len = strlen(smp->data.str.str);
return 1; return 1;
@ -2752,8 +2758,8 @@ smp_fetch_ssl_fc_session_id(struct proxy *px, struct session *l4, void *l7, unsi
SSL_SESSION *sess; SSL_SESSION *sess;
struct connection *conn; struct connection *conn;
smp->flags = 0; smp->flags = SMP_F_CONST;
smp->type = SMP_T_CBIN; smp->type = SMP_T_BIN;
if (!l4) if (!l4)
return 0; return 0;
@ -2783,8 +2789,8 @@ smp_fetch_ssl_fc_sni(struct proxy *px, struct session *l4, void *l7, unsigned in
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
struct connection *conn; struct connection *conn;
smp->flags = 0; smp->flags = SMP_F_CONST;
smp->type = SMP_T_CSTR; smp->type = SMP_T_STR;
if (!l4) if (!l4)
return 0; return 0;
@ -3520,19 +3526,19 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
{ "ssl_f_version", smp_fetch_ssl_f_version, 0, NULL, SMP_T_UINT, SMP_USE_L5CLI }, { "ssl_f_version", smp_fetch_ssl_f_version, 0, NULL, SMP_T_UINT, SMP_USE_L5CLI },
{ "ssl_fc", smp_fetch_ssl_fc, 0, NULL, SMP_T_BOOL, SMP_USE_L5CLI }, { "ssl_fc", smp_fetch_ssl_fc, 0, NULL, SMP_T_BOOL, SMP_USE_L5CLI },
{ "ssl_fc_alg_keysize", smp_fetch_ssl_fc_alg_keysize, 0, NULL, SMP_T_UINT, SMP_USE_L5CLI }, { "ssl_fc_alg_keysize", smp_fetch_ssl_fc_alg_keysize, 0, NULL, SMP_T_UINT, SMP_USE_L5CLI },
{ "ssl_fc_cipher", smp_fetch_ssl_fc_cipher, 0, NULL, SMP_T_CSTR, SMP_USE_L5CLI }, { "ssl_fc_cipher", smp_fetch_ssl_fc_cipher, 0, NULL, SMP_T_STR, SMP_USE_L5CLI },
{ "ssl_fc_has_crt", smp_fetch_ssl_fc_has_crt, 0, NULL, SMP_T_BOOL, SMP_USE_L5CLI }, { "ssl_fc_has_crt", smp_fetch_ssl_fc_has_crt, 0, NULL, SMP_T_BOOL, SMP_USE_L5CLI },
{ "ssl_fc_has_sni", smp_fetch_ssl_fc_has_sni, 0, NULL, SMP_T_BOOL, SMP_USE_L5CLI }, { "ssl_fc_has_sni", smp_fetch_ssl_fc_has_sni, 0, NULL, SMP_T_BOOL, SMP_USE_L5CLI },
#ifdef OPENSSL_NPN_NEGOTIATED #ifdef OPENSSL_NPN_NEGOTIATED
{ "ssl_fc_npn", smp_fetch_ssl_fc_npn, 0, NULL, SMP_T_CSTR, SMP_USE_L5CLI }, { "ssl_fc_npn", smp_fetch_ssl_fc_npn, 0, NULL, SMP_T_STR, SMP_USE_L5CLI },
#endif #endif
#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation #ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
{ "ssl_fc_alpn", smp_fetch_ssl_fc_alpn, 0, NULL, SMP_T_CSTR, SMP_USE_L5CLI }, { "ssl_fc_alpn", smp_fetch_ssl_fc_alpn, 0, NULL, SMP_T_STR, SMP_USE_L5CLI },
#endif #endif
{ "ssl_fc_protocol", smp_fetch_ssl_fc_protocol, 0, NULL, SMP_T_CSTR, SMP_USE_L5CLI }, { "ssl_fc_protocol", smp_fetch_ssl_fc_protocol, 0, NULL, SMP_T_STR, SMP_USE_L5CLI },
{ "ssl_fc_use_keysize", smp_fetch_ssl_fc_use_keysize, 0, NULL, SMP_T_UINT, SMP_USE_L5CLI }, { "ssl_fc_use_keysize", smp_fetch_ssl_fc_use_keysize, 0, NULL, SMP_T_UINT, SMP_USE_L5CLI },
{ "ssl_fc_session_id", smp_fetch_ssl_fc_session_id, 0, NULL, SMP_T_CBIN, SMP_USE_L5CLI }, { "ssl_fc_session_id", smp_fetch_ssl_fc_session_id, 0, NULL, SMP_T_BIN, SMP_USE_L5CLI },
{ "ssl_fc_sni", smp_fetch_ssl_fc_sni, 0, NULL, SMP_T_CSTR, SMP_USE_L5CLI }, { "ssl_fc_sni", smp_fetch_ssl_fc_sni, 0, NULL, SMP_T_STR, SMP_USE_L5CLI },
{ NULL, NULL, 0, 0, 0 }, { NULL, NULL, 0, 0, 0 },
}}; }};

View File

@ -594,8 +594,6 @@ static sample_to_key_fct sample_to_key[SMP_TYPES][STKTABLE_TYPES] = {
/* IPV6 */ { k_ip2ip, k_ip2ipv6, k_ip2int, k_ip2str, NULL }, /* IPV6 */ { k_ip2ip, k_ip2ipv6, k_ip2int, k_ip2str, NULL },
/* STR */ { k_str2ip, k_str2ipv6, k_str2int, k_str2str, k_str2str }, /* STR */ { k_str2ip, k_str2ipv6, k_str2int, k_str2str, k_str2str },
/* BIN */ { NULL, NULL, NULL, k_bin2str, k_str2str }, /* BIN */ { NULL, NULL, NULL, k_bin2str, k_str2str },
/* CSTR */ { k_str2ip, k_str2ipv6, k_str2int, k_str2str, k_str2str },
/* CBIN */ { NULL, NULL, NULL, k_bin2str, k_str2str },
}; };