aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/includes/hicn/policy.h5
-rw-r--r--lib/includes/hicn/protocol/ipv6.h37
-rw-r--r--lib/src/policy.c12
3 files changed, 41 insertions, 13 deletions
diff --git a/lib/includes/hicn/policy.h b/lib/includes/hicn/policy.h
index 1fe0dd766..5a9a44467 100644
--- a/lib/includes/hicn/policy.h
+++ b/lib/includes/hicn/policy.h
@@ -49,6 +49,8 @@ foreach_policy_tag
POLICY_TAG_N
} policy_tag_t;
+#define IS_VALID_POLICY_TAG(x) (x != POLICY_TAG_N)
+
#define MAXSZ_POLICY_TAG_ 11
#define MAXSZ_POLICY_TAG MAXSZ_POLICY_TAG_ + 1
@@ -134,6 +136,9 @@ foreach_policy_state
extern const char * policy_state_str[];
+#define policy_state_str(x) policy_state_str[x]
+
+policy_state_t policy_state_from_str(const char * str);
/* POLICY TAG STATE */
diff --git a/lib/includes/hicn/protocol/ipv6.h b/lib/includes/hicn/protocol/ipv6.h
index 5a83abcae..0b5525aba 100644
--- a/lib/includes/hicn/protocol/ipv6.h
+++ b/lib/includes/hicn/protocol/ipv6.h
@@ -23,21 +23,32 @@
*/
#define EXPECTED_IPV6_HDRLEN 40
+// typedef struct
+// {
+// union
+// {
+// struct
+// {
+// u32 version_class_flow; /* version, traffic class and 20 bits of flow-ID */
+// u16 len; /* payload length */
+// u8 nxt; /* next header */
+// u8 hlim; /* hop limit */
+// };
+// u8 vfc; /* 4 bits version, top 4 bits class */
+// };
+// ip6_address_t saddr; /* source address */
+// ip6_address_t daddr; /* destination address */
+// } _ipv6_header_t;
+
+// TODO: temporary fix
typedef struct
{
- union
- {
- struct
- {
- u32 version_class_flow; /* version, traffic class and 20 bits of flow-ID */
- u16 len; /* payload length */
- u8 nxt; /* next header */
- u8 hlim; /* hop limit */
- };
- u8 vfc; /* 4 bits version, top 4 bits class */
- };
- ip6_address_t saddr; /* source address */
- ip6_address_t daddr; /* destination address */
+ u32 version_class_flow; /* version, traffic class and 20 bits of flow-ID */
+ u16 len; /* payload length */
+ u8 nxt; /* next header */
+ u8 hlim; /* hop limit */
+ ip6_address_t saddr; /* source address */
+ ip6_address_t daddr; /* destination address */
} _ipv6_header_t;
#define IPV6_HDRLEN sizeof(_ipv6_header_t)
diff --git a/lib/src/policy.c b/lib/src/policy.c
index 694f0ea5e..8f317bc11 100644
--- a/lib/src/policy.c
+++ b/lib/src/policy.c
@@ -39,6 +39,18 @@ const char * policy_state_str[] = {
#undef _
};
+policy_state_t
+policy_state_from_str(const char * str)
+{
+#define _(x) \
+ if (strcasecmp(str, #x) == 0) \
+ return POLICY_STATE_ ## x; \
+ else
+ foreach_policy_state
+#undef _
+ return POLICY_STATE_N;
+}
+
int
policy_tag_state_snprintf(char * s, size_t size, const policy_tag_state_t * tag_state)
{