diff --git a/include/proto/pattern.h b/include/proto/pattern.h index f3250eccf..c595ed69f 100644 --- a/include/proto/pattern.h +++ b/include/proto/pattern.h @@ -25,10 +25,10 @@ #include #include -struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err_size); -struct sample *pattern_process(struct proxy *px, struct session *l4, - void *l7, unsigned int dir, struct pattern_expr *expr, +struct sample_expr *sample_parse_expr(char **str, int *idx, char *err, int err_size); +struct sample *sample_process(struct proxy *px, struct session *l4, + void *l7, unsigned int dir, struct sample_expr *expr, struct sample *p); -void pattern_register_fetches(struct pattern_fetch_kw_list *psl); -void pattern_register_convs(struct pattern_conv_kw_list *psl); +void sample_register_fetches(struct sample_fetch_kw_list *psl); +void sample_register_convs(struct sample_conv_kw_list *psl); #endif diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h index 7756623ba..f7d650a15 100644 --- a/include/proto/stick_table.h +++ b/include/proto/stick_table.h @@ -48,8 +48,8 @@ struct stksess *stktable_lookup_key(struct stktable *t, struct stktable_key *key struct stksess *stktable_update_key(struct stktable *table, struct stktable_key *key); struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, struct session *l4, void *l7, unsigned int opt, - struct pattern_expr *expr); -int stktable_compatible_pattern(struct pattern_expr *expr, unsigned long table_type); + struct sample_expr *expr); +int stktable_compatible_sample(struct sample_expr *expr, unsigned long table_type); int stktable_get_data_type(char *name); struct proxy *find_stktable(const char *name); diff --git a/include/types/pattern.h b/include/types/pattern.h index c5b19ada1..314bdda7f 100644 --- a/include/types/pattern.h +++ b/include/types/pattern.h @@ -106,27 +106,27 @@ struct sample { union smp_ctx ctx; }; -/* pattern conversion */ -struct pattern_conv { +/* Descriptor for a sample conversion */ +struct sample_conv { const char *kw; /* configuration keyword */ int (*process)(const struct arg *arg_p, struct sample *smp); /* process function */ unsigned int arg_mask; /* arguments (ARG*()) */ int (*val_args)(struct arg *arg_p, char **err_msg); /* argument validation function */ - unsigned int in_type; /* input needed pattern type */ - unsigned int out_type; /* output pattern type */ + unsigned int in_type; /* expected input sample type */ + unsigned int out_type; /* output sample type */ }; -/* pattern conversion expression */ -struct pattern_conv_expr { - struct list list; /* member of a pattern expression */ - struct pattern_conv *conv; /* pattern conversion */ - struct arg *arg_p; /* pointer on args */ +/* sample conversion expression */ +struct sample_conv_expr { + struct list list; /* member of a sample_expr */ + struct sample_conv *conv; /* sample conversion used */ + struct arg *arg_p; /* optional arguments */ }; -/* pattern fetch */ -struct pattern_fetch { +/* Descriptor for a sample fetch method */ +struct sample_fetch { const char *kw; /* configuration keyword */ int (*process)(struct proxy *px, struct session *l4, @@ -137,28 +137,28 @@ struct pattern_fetch { unsigned int arg_mask; /* arguments (ARG*()) */ int (*val_args)(struct arg *arg_p, char **err_msg); /* argument validation function */ - unsigned long out_type; /* output pattern type */ + unsigned long out_type; /* output sample type */ unsigned int cap; /* fetch capabilities (SMP_CAP_*) */ }; -/* pattern expression */ -struct pattern_expr { - struct list list; /* member of list of pattern, currently not used */ - struct pattern_fetch *fetch; /* pattern fetch */ - struct arg *arg_p; /* pointer on args */ +/* sample expression */ +struct sample_expr { + struct list list; /* member of list of sample, currently not used */ + struct sample_fetch *fetch; /* sample fetch method */ + struct arg *arg_p; /* optional pointer to arguments to fetch function */ struct list conv_exprs; /* list of conversion expression to apply */ }; -/* pattern fetch keywords list */ -struct pattern_fetch_kw_list { - struct list list; /* head of pattern fetch keyword list */ - struct pattern_fetch kw[VAR_ARRAY]; /* array of pattern fetches */ +/* sample fetch keywords list */ +struct sample_fetch_kw_list { + struct list list; /* head of sample fetch keyword list */ + struct sample_fetch kw[VAR_ARRAY]; /* array of sample fetch descriptors */ }; -/* pattern conversion keywords list */ -struct pattern_conv_kw_list { - struct list list; /* head of pattern conversion keyword list */ - struct pattern_conv kw[VAR_ARRAY]; /* array of pattern ions */ +/* sample conversion keywords list */ +struct sample_conv_kw_list { + struct list list; /* head of sample conversion keyword list */ + struct sample_conv kw[VAR_ARRAY]; /* array of sample conversion descriptors */ }; #endif /* _TYPES_PATTERN_H */ diff --git a/include/types/proxy.h b/include/types/proxy.h index aa6cec82c..e18bb7a2c 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -371,7 +371,7 @@ struct persist_rule { struct sticking_rule { struct list list; /* list linked to from the proxy */ struct acl_cond *cond; /* acl condition to meet */ - struct pattern_expr *expr; /* fetch expr to fetch key */ + struct sample_expr *expr; /* fetch expr to fetch key */ int flags; /* STK_* */ union { struct stktable *t; /* target table */ diff --git a/src/cfgparse.c b/src/cfgparse.c index 8b5eae312..1fd5fe1eb 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2968,7 +2968,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) } else if (!strcmp(args[0], "stick")) { struct sticking_rule *rule; - struct pattern_expr *expr; + struct sample_expr *expr; int myidx = 0; char *errmsg = NULL; const char *name = NULL; @@ -3015,7 +3015,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) goto out; } - expr = pattern_parse_expr(args, &myidx, trash, sizeof(trash)); + expr = sample_parse_expr(args, &myidx, trash, sizeof(trash)); if (!expr) { Alert("parsing [%s:%d] : '%s': %s\n", file, linenum, args[0], trash); err_code |= ERR_ALERT | ERR_FATAL; @@ -5930,8 +5930,8 @@ int check_config_validity() curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id); cfgerr++; } - else if (!stktable_compatible_pattern(mrule->expr, target->table.type)) { - Alert("Proxy '%s': type of pattern not usable with type of stick-table '%s'.\n", + else if (!stktable_compatible_sample(mrule->expr, target->table.type)) { + Alert("Proxy '%s': type of fetch not usable with type of stick-table '%s'.\n", curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id); cfgerr++; } @@ -5963,8 +5963,8 @@ int check_config_validity() curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id); cfgerr++; } - else if (!stktable_compatible_pattern(mrule->expr, target->table.type)) { - Alert("Proxy '%s': type of pattern not usable with type of stick-table '%s'.\n", + else if (!stktable_compatible_sample(mrule->expr, target->table.type)) { + Alert("Proxy '%s': type of fetch not usable with type of stick-table '%s'.\n", curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id); cfgerr++; } diff --git a/src/haproxy.c b/src/haproxy.c index decfede86..776f0dd4f 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -758,7 +758,7 @@ static void deinit_tcp_rules(struct list *rules) } } -static void deinit_pattern_arg(struct arg *p) +static void deinit_sample_arg(struct arg *p) { struct arg *p_back = p; @@ -786,10 +786,10 @@ static void deinit_stick_rules(struct list *rules) LIST_DEL(&rule->list); deinit_acl_cond(rule->cond); if (rule->expr) { - struct pattern_conv_expr *conv_expr, *conv_exprb; + struct sample_conv_expr *conv_expr, *conv_exprb; list_for_each_entry_safe(conv_expr, conv_exprb, &rule->expr->conv_exprs, list) - deinit_pattern_arg(conv_expr->arg_p); - deinit_pattern_arg(rule->expr->arg_p); + deinit_sample_arg(conv_expr->arg_p); + deinit_sample_arg(rule->expr->arg_p); free(rule->expr); } free(rule); diff --git a/src/pattern.c b/src/pattern.c index 66ebc62de..5ecc0d13d 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -18,58 +18,58 @@ #include #include -/* static sample used in pattern_process() when

is NULL */ +/* static sample used in sample_process() when

is NULL */ static struct sample temp_smp; -/* trash chunk used for pattern conversions */ +/* trash chunk used for sample conversions */ static struct chunk trash_chunk; -/* trash buffers used or pattern conversions */ -static char pattern_trash_buf1[BUFSIZE]; -static char pattern_trash_buf2[BUFSIZE]; +/* trash buffers used or sample conversions */ +static char sample_trash_buf1[BUFSIZE]; +static char sample_trash_buf2[BUFSIZE]; -/* pattern_trash_buf point on used buffer*/ -static char *pattern_trash_buf = pattern_trash_buf1; +/* sample_trash_buf point on used buffer*/ +static char *sample_trash_buf = sample_trash_buf1; -/* list head of all known pattern fetch keywords */ -static struct pattern_fetch_kw_list pattern_fetches = { - .list = LIST_HEAD_INIT(pattern_fetches.list) +/* list head of all known sample fetch keywords */ +static struct sample_fetch_kw_list sample_fetches = { + .list = LIST_HEAD_INIT(sample_fetches.list) }; -/* list head of all known pattern format conversion keywords */ -static struct pattern_conv_kw_list pattern_convs = { - .list = LIST_HEAD_INIT(pattern_convs.list) +/* list head of all known sample format conversion keywords */ +static struct sample_conv_kw_list sample_convs = { + .list = LIST_HEAD_INIT(sample_convs.list) }; /* - * Registers the pattern fetch keyword list as a list of valid keywords for next + * Registers the sample fetch keyword list as a list of valid keywords for next * parsing sessions. */ -void pattern_register_fetches(struct pattern_fetch_kw_list *pfkl) +void sample_register_fetches(struct sample_fetch_kw_list *pfkl) { - LIST_ADDQ(&pattern_fetches.list, &pfkl->list); + LIST_ADDQ(&sample_fetches.list, &pfkl->list); } /* - * Registers the pattern format coverstion keyword list as a list of valid keywords for next + * Registers the sample format coverstion keyword list as a list of valid keywords for next * parsing sessions. */ -void pattern_register_convs(struct pattern_conv_kw_list *pckl) +void sample_register_convs(struct sample_conv_kw_list *pckl) { - LIST_ADDQ(&pattern_convs.list, &pckl->list); + LIST_ADDQ(&sample_convs.list, &pckl->list); } /* - * Returns the pointer on pattern fetch keyword structure identified by + * Returns the pointer on sample fetch keyword structure identified by * string of in buffer . * */ -struct pattern_fetch *find_pattern_fetch(const char *kw, int len) +struct sample_fetch *find_sample_fetch(const char *kw, int len) { int index; - struct pattern_fetch_kw_list *kwl; + struct sample_fetch_kw_list *kwl; - list_for_each_entry(kwl, &pattern_fetches.list, list) { + list_for_each_entry(kwl, &sample_fetches.list, list) { for (index = 0; kwl->kw[index].kw != NULL; index++) { if (strncmp(kwl->kw[index].kw, kw, len) == 0 && kwl->kw[index].kw[len] == '\0') @@ -80,16 +80,16 @@ struct pattern_fetch *find_pattern_fetch(const char *kw, int len) } /* - * Returns the pointer on pattern format conversion keyword structure identified by + * Returns the pointer on sample format conversion keyword structure identified by * string of in buffer . * */ -struct pattern_conv *find_pattern_conv(const char *kw, int len) +struct sample_conv *find_sample_conv(const char *kw, int len) { int index; - struct pattern_conv_kw_list *kwl; + struct sample_conv_kw_list *kwl; - list_for_each_entry(kwl, &pattern_convs.list, list) { + list_for_each_entry(kwl, &sample_convs.list, list) { for (index = 0; kwl->kw[index].kw != NULL; index++) { if (strncmp(kwl->kw[index].kw, kw, len) == 0 && kwl->kw[index].kw[len] == '\0') @@ -101,23 +101,23 @@ struct pattern_conv *find_pattern_conv(const char *kw, int len) /* -* Returns a static trash struct chunk to use in pattern casts or format conversions +* Returns a static trash struct chunk to use in sample casts or format conversions * Swiths the 2 available trash buffers to protect data during convert */ static struct chunk *get_trash_chunk(void) { - if (pattern_trash_buf == pattern_trash_buf1) - pattern_trash_buf = pattern_trash_buf2; + if (sample_trash_buf == sample_trash_buf1) + sample_trash_buf = sample_trash_buf2; else - pattern_trash_buf = pattern_trash_buf1; + sample_trash_buf = sample_trash_buf1; - chunk_init(&trash_chunk, pattern_trash_buf, BUFSIZE); + chunk_init(&trash_chunk, sample_trash_buf, BUFSIZE); return &trash_chunk; } /******************************************************************/ -/* Pattern casts functions */ +/* Sample casts functions */ /* Note: these functions do *NOT* set the output type on the */ /* sample, the caller is responsible for doing this on return. */ /******************************************************************/ @@ -236,13 +236,13 @@ static int c_str2int(struct sample *smp) } /*****************************************************************/ -/* Pattern casts matrix: */ -/* pattern_casts[from type][to type] */ -/* NULL pointer used for impossible pattern casts */ +/* Sample casts matrix: */ +/* sample_casts[from type][to type] */ +/* NULL pointer used for impossible sample casts */ /*****************************************************************/ -typedef int (*pattern_cast_fct)(struct sample *smp); -static pattern_cast_fct pattern_casts[SMP_TYPES][SMP_TYPES] = { +typedef int (*sample_cast_fct)(struct sample *smp); +static sample_cast_fct sample_casts[SMP_TYPES][SMP_TYPES] = { /* to: BOOL UINT SINT IPV4 IPV6 STR BIN CSTR CBIN */ /* from: BOOL */ { c_none, c_none, c_none, NULL, NULL, NULL, NULL, NULL, NULL }, /* UINT */ { c_none, c_none, c_none, c_int2ip, NULL, c_int2str, NULL, c_int2str, NULL }, @@ -256,17 +256,17 @@ static pattern_cast_fct pattern_casts[SMP_TYPES][SMP_TYPES] = { }; /* - * Parse a pattern expression configuration: + * Parse a sample expression configuration: * fetch keyword followed by format conversion keywords. - * Returns a pointer on allocated pattern expression structure. + * Returns a pointer on allocated sample expression structure. */ -struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err_size) +struct sample_expr *sample_parse_expr(char **str, int *idx, char *err, int err_size) { const char *endw; const char *end; - struct pattern_expr *expr; - struct pattern_fetch *fetch; - struct pattern_conv *conv; + struct sample_expr *expr; + struct sample_fetch *fetch; + struct sample_conv *conv; unsigned long prev_type; char *p; @@ -291,7 +291,7 @@ struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err goto out_error; } - fetch = find_pattern_fetch(str[*idx], endw - str[*idx]); + fetch = find_sample_fetch(str[*idx], endw - str[*idx]); if (!fetch) { p = my_strndup(str[*idx], endw - str[*idx]); if (p) { @@ -311,7 +311,7 @@ struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err } prev_type = fetch->out_type; - expr = calloc(1, sizeof(struct pattern_expr)); + expr = calloc(1, sizeof(struct sample_expr)); if (!expr) goto out_error; @@ -361,7 +361,7 @@ struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err } for (*idx += 1; *(str[*idx]); (*idx)++) { - struct pattern_conv_expr *conv_expr; + struct sample_conv_expr *conv_expr; end = str[*idx] + strlen(str[*idx]); endw = strchr(str[*idx], '('); @@ -377,7 +377,7 @@ struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err goto out_error; } - conv = find_pattern_conv(str[*idx], endw - str[*idx]); + conv = find_sample_conv(str[*idx], endw - str[*idx]); if (!conv) break; @@ -392,7 +392,7 @@ struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err } /* If impossible type conversion */ - if (!pattern_casts[prev_type][conv->in_type]) { + if (!sample_casts[prev_type][conv->in_type]) { p = my_strndup(str[*idx], endw - str[*idx]); if (p) { snprintf(err, err_size, "conv method '%s' cannot be applied.", p); @@ -402,7 +402,7 @@ struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err } prev_type = conv->out_type; - conv_expr = calloc(1, sizeof(struct pattern_conv_expr)); + conv_expr = calloc(1, sizeof(struct sample_conv_expr)); if (!conv_expr) goto out_error; @@ -457,27 +457,27 @@ struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err return expr; out_error: - /* TODO: prune_pattern_expr(expr); */ + /* TODO: prune_sample_expr(expr); */ return NULL; } /* - * Process a fetch + format conversion of defined by the pattern expression + * Process a fetch + format conversion of defined by the sample expression * on request or response considering the parameter. - * Returns a pointer on a typed pattern structure containing the result or NULL if - * pattern is not found or when format conversion failed. + * Returns a pointer on a typed sample structure containing the result or NULL if + * sample is not found or when format conversion failed. * If

is not null, function returns results in structure pointed by

. - * If

is null, functions returns a pointer on a static pattern structure. + * If

is null, functions returns a pointer on a static sample structure. * * Note: the fetch functions are required to properly set the return type. The * conversion functions must do so too. However the cast functions do not need * to since they're made to cast mutiple types according to what is required. */ -struct sample *pattern_process(struct proxy *px, struct session *l4, void *l7, - unsigned int opt, - struct pattern_expr *expr, struct sample *p) +struct sample *sample_process(struct proxy *px, struct session *l4, void *l7, + unsigned int opt, + struct sample_expr *expr, struct sample *p) { - struct pattern_conv_expr *conv_expr; + struct sample_conv_expr *conv_expr; if (p == NULL) p = &temp_smp; @@ -487,7 +487,7 @@ struct sample *pattern_process(struct proxy *px, struct session *l4, void *l7, return NULL; if (p->flags & SMP_F_MAY_CHANGE) - return NULL; /* we can only use stable patterns */ + return NULL; /* we can only use stable samples */ list_for_each_entry(conv_expr, &expr->conv_exprs, list) { /* we want to ensure that p->type can be casted into @@ -496,11 +496,11 @@ struct sample *pattern_process(struct proxy *px, struct session *l4, void *l7, * - c_none => nothing to do (let's optimize it) * - other => apply cast and prepare to fail */ - if (!pattern_casts[p->type][conv_expr->conv->in_type]) + if (!sample_casts[p->type][conv_expr->conv->in_type]) return NULL; - if (pattern_casts[p->type][conv_expr->conv->in_type] != c_none && - !pattern_casts[p->type][conv_expr->conv->in_type](p)) + if (sample_casts[p->type][conv_expr->conv->in_type] != c_none && + !sample_casts[p->type][conv_expr->conv->in_type](p)) return NULL; /* OK cast succeeded */ @@ -514,11 +514,11 @@ struct sample *pattern_process(struct proxy *px, struct session *l4, void *l7, } /*****************************************************************/ -/* Pattern format convert functions */ +/* Sample format convert functions */ /* These functions set the data type on return. */ /*****************************************************************/ -static int pattern_conv_str2lower(const struct arg *arg_p, struct sample *smp) +static int sample_conv_str2lower(const struct arg *arg_p, struct sample *smp) { int i; @@ -533,7 +533,7 @@ static int pattern_conv_str2lower(const struct arg *arg_p, struct sample *smp) return 1; } -static int pattern_conv_str2upper(const struct arg *arg_p, struct sample *smp) +static int sample_conv_str2upper(const struct arg *arg_p, struct sample *smp) { int i; @@ -549,7 +549,7 @@ static int pattern_conv_str2upper(const struct arg *arg_p, struct sample *smp) } /* takes the netmask in arg_p */ -static int pattern_conv_ipmask(const struct arg *arg_p, struct sample *smp) +static int sample_conv_ipmask(const struct arg *arg_p, struct sample *smp) { smp->data.ipv4.s_addr &= arg_p->data.ipv4.s_addr; smp->type = SMP_T_IPV4; @@ -557,16 +557,16 @@ static int pattern_conv_ipmask(const struct arg *arg_p, struct sample *smp) } /* Note: must not be declared as its list will be overwritten */ -static struct pattern_conv_kw_list pattern_conv_kws = {{ },{ - { "upper", pattern_conv_str2upper, 0, NULL, SMP_T_STR, SMP_T_STR }, - { "lower", pattern_conv_str2lower, 0, NULL, SMP_T_STR, SMP_T_STR }, - { "ipmask", pattern_conv_ipmask, ARG1(1,MSK4), NULL, SMP_T_IPV4, SMP_T_IPV4 }, +static struct sample_conv_kw_list sample_conv_kws = {{ },{ + { "upper", sample_conv_str2upper, 0, NULL, SMP_T_STR, SMP_T_STR }, + { "lower", sample_conv_str2lower, 0, NULL, SMP_T_STR, SMP_T_STR }, + { "ipmask", sample_conv_ipmask, ARG1(1,MSK4), NULL, SMP_T_IPV4, SMP_T_IPV4 }, { NULL, NULL, 0, 0, 0 }, }}; __attribute__((constructor)) -static void __pattern_init(void) +static void __sample_init(void) { - /* register pattern format convert keywords */ - pattern_register_convs(&pattern_conv_kws); + /* register sample format convert keywords */ + sample_register_convs(&sample_conv_kws); } diff --git a/src/proto_http.c b/src/proto_http.c index 60526f850..1cc3cc765 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -8304,7 +8304,7 @@ acl_fetch_cookie_cnt(struct proxy *px, struct session *l4, void *l7, unsigned in } /************************************************************************/ -/* The code below is dedicated to pattern fetching and matching */ +/* The code below is dedicated to sample fetches */ /************************************************************************/ /* @@ -8533,7 +8533,7 @@ static struct acl_kw_list acl_kws = {{ },{ /* All supported pattern keywords must be declared here. */ /************************************************************************/ /* Note: must not be declared as its list will be overwritten */ -static struct pattern_fetch_kw_list pattern_fetch_keywords = {{ },{ +static struct sample_fetch_kw_list sample_fetch_keywords = {{ },{ { "hdr", smp_fetch_hdr, ARG2(1,STR,SINT), val_hdr, SMP_T_CSTR, SMP_CAP_REQ }, { "url_param", smp_fetch_url_param, ARG1(1,STR), NULL, SMP_T_CSTR, SMP_CAP_REQ }, { "cookie", smp_fetch_cookie_value, ARG1(1,STR), NULL, SMP_T_CSTR, SMP_CAP_REQ|SMP_CAP_RES }, @@ -8546,7 +8546,7 @@ __attribute__((constructor)) static void __http_protocol_init(void) { acl_register_keywords(&acl_kws); - pattern_register_fetches(&pattern_fetch_keywords); + sample_register_fetches(&sample_fetch_keywords); } diff --git a/src/proto_tcp.c b/src/proto_tcp.c index dc7812d21..2cb4b27fe 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -1258,7 +1258,7 @@ static int tcp_parse_tcp_req(char **args, int section_type, struct proxy *curpx, /************************************************************************/ /* Fetch the request RDP cookie identified in the args, or any cookie if no arg - * is passed. It is usable both for ACL and for patterns. Note: this decoder + * is passed. It is usable both for ACL and for samples. Note: this decoder * only works with non-wrapping data. Accepts either 0 or 1 argument. Argument * is a string (cookie name), other types will lead to undefined behaviour. */ @@ -1397,8 +1397,8 @@ smp_fetch_src(struct proxy *px, struct session *l4, void *l7, unsigned int opt, /* extract the connection's source ipv6 address */ static int -pattern_fetch_src6(struct proxy *px, struct session *l4, void *l7, unsigned int opt, - const struct arg *arg_p, struct sample *smp) +smp_fetch_src6(struct proxy *px, struct session *l4, void *l7, unsigned int opt, + const struct arg *arg_p, struct sample *smp) { if (l4->si[0].addr.from.ss_family != AF_INET6) return 0; @@ -1447,8 +1447,8 @@ smp_fetch_dst(struct proxy *px, struct session *l4, void *l7, unsigned int opt, /* extract the connection's destination ipv6 address */ static int -pattern_fetch_dst6(struct proxy *px, struct session *l4, void *l7, unsigned int opt, - const struct arg *arg_p, struct sample *smp) +smp_fetch_dst6(struct proxy *px, struct session *l4, void *l7, unsigned int opt, + const struct arg *arg_p, struct sample *smp) { stream_sock_get_to_addr(&l4->si[0]); @@ -1638,11 +1638,11 @@ static struct acl_kw_list acl_kws = {{ },{ * common denominator, the type that can be casted into all other ones. For * instance v4/v6 must be declared v4. */ -static struct pattern_fetch_kw_list pattern_fetch_keywords = {{ },{ +static struct sample_fetch_kw_list sample_fetch_keywords = {{ },{ { "src", smp_fetch_src, 0, NULL, SMP_T_IPV4, SMP_CAP_REQ|SMP_CAP_RES }, - { "src6", pattern_fetch_src6, 0, NULL, SMP_T_IPV6, SMP_CAP_REQ|SMP_CAP_RES }, + { "src6", smp_fetch_src6, 0, NULL, SMP_T_IPV6, SMP_CAP_REQ|SMP_CAP_RES }, { "dst", smp_fetch_dst, 0, NULL, SMP_T_IPV4, SMP_CAP_REQ|SMP_CAP_RES }, - { "dst6", pattern_fetch_dst6, 0, NULL, SMP_T_IPV6, SMP_CAP_REQ|SMP_CAP_RES }, + { "dst6", smp_fetch_dst6, 0, NULL, SMP_T_IPV6, SMP_CAP_REQ|SMP_CAP_RES }, { "dst_port", smp_fetch_dport, 0, NULL, SMP_T_UINT, SMP_CAP_REQ|SMP_CAP_RES }, { "payload", smp_fetch_payload, ARG2(2,UINT,UINT), val_payload, SMP_T_CBIN, SMP_CAP_REQ|SMP_CAP_RES }, { "payload_lv", smp_fetch_payload_lv, ARG3(2,UINT,UINT,SINT), val_payload_lv, SMP_T_CBIN, SMP_CAP_REQ|SMP_CAP_RES }, @@ -1656,7 +1656,7 @@ static void __tcp_protocol_init(void) { protocol_register(&proto_tcpv4); protocol_register(&proto_tcpv6); - pattern_register_fetches(&pattern_fetch_keywords); + sample_register_fetches(&sample_fetch_keywords); cfg_register_keywords(&cfg_kws); acl_register_keywords(&acl_kws); } diff --git a/src/session.c b/src/session.c index 9d1c9357c..8ea2a3cee 100644 --- a/src/session.c +++ b/src/session.c @@ -3386,7 +3386,7 @@ int parse_track_counters(char **args, int *arg, struct track_ctr_prm *prm, struct proxy *defpx, char *err, int errlen) { - int pattern_type = 0; + int sample_type = 0; char *kw = args[*arg - 1]; /* parse the arguments of "track-sc[12]" before the condition in the @@ -3396,7 +3396,7 @@ int parse_track_counters(char **args, int *arg, while (args[*arg]) { if (strcmp(args[*arg], "src") == 0) { prm->type = STKTABLE_TYPE_IP; - pattern_type = 1; + sample_type = 1; } else if (strcmp(args[*arg], "table") == 0) { if (!args[*arg + 1]) { @@ -3416,7 +3416,7 @@ int parse_track_counters(char **args, int *arg, (*arg)++; } - if (!pattern_type) { + if (!sample_type) { snprintf(err, errlen, "%s key not specified in %s '%s' (found %s, only 'src' is supported).", kw, proxy_type_str(curpx), curpx->id, quote_arg(args[*arg])); diff --git a/src/stick_table.c b/src/stick_table.c index 1cb240b6a..d2ce3e3df 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -30,7 +30,7 @@ #include #include -/* structure used to return a table key built from a pattern */ +/* structure used to return a table key built from a sample */ struct stktable_key static_table_key; /* @@ -445,7 +445,7 @@ int stktable_parse_type(char **args, int *myidx, unsigned long *type, size_t *ke } /*****************************************************************/ -/* typed pattern to typed table key functions */ +/* typed sample to typed table key functions */ /*****************************************************************/ static void *k_int2int(struct sample *smp, union stktable_key_data *kdata, size_t *len) @@ -558,9 +558,9 @@ static void *k_str2int(struct sample *smp, union stktable_key_data *kdata, size_ } /*****************************************************************/ -/* typed pattern to typed table key matrix: */ -/* pattern_to_key[from pattern type][to table key type] */ -/* NULL pointer used for impossible pattern casts */ +/* typed sample to typed table key matrix: */ +/* sample_to_key[from sample type][to table key type] */ +/* NULL pointer used for impossible sample casts */ /*****************************************************************/ /* @@ -569,8 +569,8 @@ static void *k_str2int(struct sample *smp, union stktable_key_data *kdata, size_ * relevant and could cause confusion in configuration. */ -typedef void *(*pattern_to_key_fct)(struct sample *smp, union stktable_key_data *kdata, size_t *len); -static pattern_to_key_fct pattern_to_key[SMP_TYPES][STKTABLE_TYPES] = { +typedef void *(*sample_to_key_fct)(struct sample *smp, union stktable_key_data *kdata, size_t *len); +static sample_to_key_fct sample_to_key[SMP_TYPES][STKTABLE_TYPES] = { /* table type: IP IPV6 INTEGER STRING BINARY */ /* patt. type: BOOL */ { NULL, NULL, k_int2int, k_int2str, NULL }, /* UINT */ { k_int2ip, NULL, k_int2int, k_int2str, NULL }, @@ -585,26 +585,26 @@ static pattern_to_key_fct pattern_to_key[SMP_TYPES][STKTABLE_TYPES] = { /* - * Process a fetch + format conversion as defined by the pattern expression + * Process a fetch + format conversion as defined by the sample expression * on request or response considering the parameter. Returns either NULL if * no key could be extracted, or a pointer to the converted result stored in * static_table_key in format . */ struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, struct session *l4, void *l7, unsigned int opt, - struct pattern_expr *expr) + struct sample_expr *expr) { struct sample *smp; - smp = pattern_process(px, l4, l7, opt, expr, NULL); + smp = sample_process(px, l4, l7, opt, expr, NULL); if (!smp) return NULL; - if (!pattern_to_key[smp->type][t->type]) + if (!sample_to_key[smp->type][t->type]) return NULL; static_table_key.key_len = t->key_size; - static_table_key.key = pattern_to_key[smp->type][t->type](smp, &static_table_key.data, &static_table_key.key_len); + static_table_key.key = sample_to_key[smp->type][t->type](smp, &static_table_key.data, &static_table_key.key_len); if (!static_table_key.key) return NULL; @@ -642,22 +642,22 @@ struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, st } /* - * Returns 1 if pattern expression result can be converted to table key of + * Returns 1 if sample expression result can be converted to table key of * type , otherwise zero. Used in configuration check. */ -int stktable_compatible_pattern(struct pattern_expr *expr, unsigned long table_type) +int stktable_compatible_sample(struct sample_expr *expr, unsigned long table_type) { if (table_type >= STKTABLE_TYPES) return 0; if (LIST_ISEMPTY(&expr->conv_exprs)) { - if (!pattern_to_key[expr->fetch->out_type][table_type]) + if (!sample_to_key[expr->fetch->out_type][table_type]) return 0; } else { - struct pattern_conv_expr *conv_expr; + struct sample_conv_expr *conv_expr; conv_expr = LIST_PREV(&expr->conv_exprs, typeof(conv_expr), list); - if (!pattern_to_key[conv_expr->conv->out_type][table_type]) + if (!sample_to_key[conv_expr->conv->out_type][table_type]) return 0; } return 1;