MINOR: sample: allow IP address to cast to binary

IP addresses are a perfect example of fixed size data which we could
cast to binary, still it was not allowed by lack of cast function,
eventhough the opposite was allowed in ACLs. Make that possible both
in sample expressions and in stick tables.
diff --git a/src/stick_table.c b/src/stick_table.c
index a6ee77f..1226591 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -518,6 +518,23 @@
 	return (void *)kdata->buf;
 }
 
+static void *k_ip2bin(struct sample *smp, union stktable_key_data *kdata, size_t *len)
+{
+	if (smp->type == SMP_T_IPV4) {
+		if (*len > 4)
+			*len = 4;
+		memcpy(kdata->buf, &smp->data.ipv4, *len);
+	}
+	else if (smp->type == SMP_T_IPV6) {
+		if (*len > 16)
+			*len = 16;
+		memcpy(kdata->buf, &smp->data.ipv6, *len);
+	}
+	else
+		*len = 0;
+	return (void *)kdata->buf;
+}
+
 static void *k_bin2str(struct sample *smp, union stktable_key_data *kdata, size_t *len)
 {
 	unsigned char c;
@@ -591,8 +608,8 @@
 /*             UINT */ { k_int2ip, NULL,        k_int2int, k_int2str,  NULL      },
 /*             SINT */ { k_int2ip, NULL,        k_int2int, k_int2str,  NULL      },
 /*             ADDR */ { k_ip2ip,  k_ip2ipv6,   k_ip2int,  k_ip2str,   NULL      },
-/*             IPV4 */ { k_ip2ip,  k_ip2ipv6,   k_ip2int,  k_ip2str,   NULL      },
-/*             IPV6 */ { k_ip2ip,  k_ip2ipv6,   k_ip2int,  k_ip2str,   NULL      },
+/*             IPV4 */ { k_ip2ip,  k_ip2ipv6,   k_ip2int,  k_ip2str,   k_ip2bin  },
+/*             IPV6 */ { k_ip2ip,  k_ip2ipv6,   k_ip2int,  k_ip2str,   k_ip2bin  },
 /*              STR */ { k_str2ip, k_str2ipv6,  k_str2int, k_str2str,  k_str2str },
 /*              BIN */ { NULL,     NULL,        NULL,      k_bin2str,  k_str2str },
 };