[MEDIUM] IPv6 support for stick-tables
Since IPv6 is a different type than IPv4, the pattern fetch functions
src6 and dst6 were added. IPv6 stick-tables can also fetch IPv4 addresses
with src and dst. In this case, the IPv4 addresses are mapped to their
IPv6 counterpart, according to RFC 4291.
diff --git a/include/types/pattern.h b/include/types/pattern.h
index a3d5c36..9b4e340 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -29,6 +29,7 @@
/* pattern in and out types */
enum {
PATTERN_TYPE_IP = 0, /* ipv4 type */
+ PATTERN_TYPE_IPV6, /* ipv6 type */
PATTERN_TYPE_INTEGER, /* unsigned 32bits integer type */
PATTERN_TYPE_STRING, /* char string type */
PATTERN_TYPE_DATA, /* buffer type */
@@ -41,6 +42,7 @@
/* pattern arg types */
enum {
PATTERN_ARG_TYPE_IP = 0, /* ipv4 type */
+ PATTERN_ARG_TYPE_IPV6, /* ipv6 type */
PATTERN_ARG_TYPE_INTEGER, /* unsigned 32bits integer type */
PATTERN_ARG_TYPE_SINTEGER, /* signed 32bits integer type */
PATTERN_ARG_TYPE_STRING /* string type */
@@ -53,6 +55,7 @@
union pattern_arg_data {
struct in_addr ip; /* used for ipv4 type */
+ struct in6_addr ipv6; /* used for ipv6 type */
uint32_t integer; /* used for unsigned 32bits integer type */
int sinteger; /* used for signed 32bits integer type */
struct chunk str;
@@ -66,6 +69,7 @@
/* pattern result data */
union pattern_data {
struct in_addr ip; /* used for ipv4 type */
+ struct in6_addr ipv6; /* used for ipv6 type */
uint32_t integer; /* used for unsigned 32bits integer type */
struct chunk str; /* used for char string type or buffers*/
};
diff --git a/include/types/stick_table.h b/include/types/stick_table.h
index e519f49..cccf9fb 100644
--- a/include/types/stick_table.h
+++ b/include/types/stick_table.h
@@ -35,6 +35,7 @@
/* stick table key types */
enum {
STKTABLE_TYPE_IP = 0, /* table key is ipv4 */
+ STKTABLE_TYPE_IPV6, /* table key is ipv6 */
STKTABLE_TYPE_INTEGER, /* table key is unsigned 32bit integer */
STKTABLE_TYPE_STRING, /* table key is a null terminated string */
STKTABLE_TYPE_BINARY, /* table key is a buffer of data */
@@ -172,7 +173,8 @@
/* stick table key data */
union stktable_key_data {
- struct in_addr ip; /* used to store an ip key */
+ struct in_addr ip; /* used to store an ipv4 key */
+ struct in6_addr ipv6; /* used to store an ipv6 key */
uint32_t integer; /* used to store an integer key */
char buf[BUFSIZE]; /* used to store a null terminated string key or a buffer of data */
};