MEDIUM: pattern: get rid of arg_i in all functions making use of arguments
arg_i was almost unused, and since we migrated to use struct arg everywhere,
the rare cases where arg_i was needed could be replaced by switching to
arg->type = ARGT_STOP.
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 59d0d55..a0e315d 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1275,7 +1275,7 @@
/* extract the connection's source ipv4 address */
static int
pattern_fetch_src(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, int arg_i, union pattern_data *data)
+ const struct arg *arg_p, union pattern_data *data)
{
if (l4->si[0].addr.from.ss_family != AF_INET )
return 0;
@@ -1287,7 +1287,7 @@
/* extract the connection's source ipv6 address */
static int
pattern_fetch_src6(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, int arg_i, union pattern_data *data)
+ const struct arg *arg_p, union pattern_data *data)
{
if (l4->si[0].addr.from.ss_family != AF_INET6)
return 0;
@@ -1337,7 +1337,7 @@
/* extract the connection's destination ipv4 address */
static int
pattern_fetch_dst(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, int arg_i, union pattern_data *data)
+ const struct arg *arg_p, union pattern_data *data)
{
stream_sock_get_to_addr(&l4->si[0]);
@@ -1351,7 +1351,7 @@
/* extract the connection's destination ipv6 address */
static int
pattern_fetch_dst6(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, int arg_i, union pattern_data *data)
+ const struct arg *arg_p, union pattern_data *data)
{
stream_sock_get_to_addr(&l4->si[0]);
@@ -1378,7 +1378,7 @@
static int
pattern_fetch_dport(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg, int i, union pattern_data *data)
+ const struct arg *arg, union pattern_data *data)
{
stream_sock_get_to_addr(&l4->si[0]);
@@ -1389,7 +1389,7 @@
}
static int
-pattern_arg_fetch_payloadlv(const char *arg, struct arg **arg_p, int *arg_i)
+pattern_arg_fetch_payloadlv(const char *arg, struct arg **arg_p)
{
int member = 0;
int len_offset = 0;
@@ -1445,21 +1445,21 @@
buf_offset = len_offset + len_size - buf_offset;
}
- *arg_i = 3;
- *arg_p = calloc(1, *arg_i*sizeof(struct arg));
+ *arg_p = calloc(4, sizeof(struct arg));
(*arg_p)[0].type = ARGT_UINT;
(*arg_p)[0].data.uint = len_offset;
(*arg_p)[1].type = ARGT_UINT;
(*arg_p)[1].data.uint = len_size;
(*arg_p)[2].type = ARGT_UINT;
(*arg_p)[2].data.uint = buf_offset;
+ (*arg_p)[3].type = ARGT_STOP;
return 1;
}
static int
pattern_fetch_payloadlv(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, int arg_i, union pattern_data *data)
+ const struct arg *arg_p, union pattern_data *data)
{
int len_offset = arg_p[0].data.uint;
int len_size = arg_p[1].data.uint;
@@ -1500,7 +1500,7 @@
}
static int
-pattern_arg_fetch_payload (const char *arg, struct arg **arg_p, int *arg_i)
+pattern_arg_fetch_payload (const char *arg, struct arg **arg_p)
{
int member = 0;
int buf_offset = 0;
@@ -1527,19 +1527,19 @@
if (!buf_size)
return 0;
- *arg_i = 2;
- *arg_p = calloc(1, *arg_i*sizeof(struct arg));
+ *arg_p = calloc(3, sizeof(struct arg));
(*arg_p)[0].type = ARGT_UINT;
(*arg_p)[0].data.uint = buf_offset;
(*arg_p)[1].type = ARGT_UINT;
(*arg_p)[1].data.uint = buf_size;
+ (*arg_p)[2].type = ARGT_STOP;
return 1;
}
static int
pattern_fetch_payload(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, int arg_i, union pattern_data *data)
+ const struct arg *arg_p, union pattern_data *data)
{
int buf_offset = arg_p[0].data.uint;
int buf_size = arg_p[1].data.uint;
@@ -1564,7 +1564,7 @@
static int
pattern_fetch_rdp_cookie(struct proxy *px, struct session *l4, void *l7, int dir,
- const struct arg *arg_p, int arg_i, union pattern_data *data)
+ const struct arg *arg_p, union pattern_data *data)
{
int ret;
struct acl_expr expr;