summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/includes/hicn/ops.h24
-rw-r--r--lib/includes/hicn/protocol/tcp.h6
-rw-r--r--lib/src/compat.c72
-rw-r--r--lib/src/ops.c2
-rw-r--r--lib/src/protocol/ah.c2
-rw-r--r--lib/src/protocol/icmp.c2
-rw-r--r--lib/src/protocol/ipv4.c12
-rw-r--r--lib/src/protocol/ipv6.c12
-rw-r--r--lib/src/protocol/tcp.c14
9 files changed, 107 insertions, 39 deletions
diff --git a/lib/includes/hicn/ops.h b/lib/includes/hicn/ops.h
index 47795efd5..e8feff92d 100644
--- a/lib/includes/hicn/ops.h
+++ b/lib/includes/hicn/ops.h
@@ -106,6 +106,22 @@ typedef struct hicn_ops_s
const hicn_name_suffix_t * suffix);
/**
+ * @brief Set flag to mark current packet as interest
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest packet
+ * @return hICN error code
+ */
+ int (*mark_packet_as_interest) (hicn_type_t type, hicn_protocol_t * h);
+
+ /**
+ * @brief Set flag to mark current packet as data
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest packet
+ * @return hICN error code
+ */
+ int (*mark_packet_as_data) (hicn_type_t type, hicn_protocol_t * h);
+
+ /**
* @brief Clear the necessary Interest fields in order to hash it
* @param [in] type - hICN packet type
* @param [in,out] h - Buffer holding the Interest packet
@@ -438,6 +454,8 @@ typedef struct hicn_ops_s
ATTR_INIT(set_interest_name, protocol ## _set_interest_name), \
ATTR_INIT(get_interest_name_suffix, protocol ## _get_interest_name_suffix), \
ATTR_INIT(set_interest_name_suffix, protocol ## _set_interest_name_suffix), \
+ ATTR_INIT(mark_packet_as_interest, protocol ## _mark_packet_as_interest), \
+ ATTR_INIT(mark_packet_as_data, protocol ## _mark_packet_as_data), \
ATTR_INIT(reset_interest_for_hash, protocol ## _reset_interest_for_hash), \
ATTR_INIT(get_data_locator, protocol ## _get_data_locator), \
ATTR_INIT(set_data_locator, protocol ## _set_data_locator), \
@@ -537,6 +555,12 @@ PAYLOAD (hicn_type_t type, const hicn_protocol_t * h)
#define DECLARE_set_interest_name_suffix(protocol, error) \
int protocol ## _set_interest_name_suffix(hicn_type_t type, hicn_protocol_t * h, const hicn_name_suffix_t * suffix) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_mark_packet_as_interest(protocol, error) \
+ int protocol ## _mark_packet_as_interest(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }
+
+#define DECLARE_mark_packet_as_data(protocol, error) \
+ int protocol ## _mark_packet_as_data(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }
+
#define DECLARE_reset_interest_for_hash(protocol, error) \
int protocol ## _reset_interest_for_hash(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }
diff --git a/lib/includes/hicn/protocol/tcp.h b/lib/includes/hicn/protocol/tcp.h
index ded9a06b2..3a15a93b3 100644
--- a/lib/includes/hicn/protocol/tcp.h
+++ b/lib/includes/hicn/protocol/tcp.h
@@ -143,15 +143,15 @@ static_assert (EXPECTED_TCP_HDRLEN == TCP_HDRLEN,
enum
{
-#define _(f) HICN_TCP_FLAG_BIT_##f,
+#define _(f) TCP_FLAG_BIT_##f,
foreach_tcp_flag
#undef _
- HICN_TCP_N_FLAG_BITS,
+ TCP_N_FLAG_BITS,
};
enum
{
-#define _(f) HICN_TCP_FLAG_##f = 1 << HICN_TCP_FLAG_BIT_##f,
+#define _(f) TCP_FLAG_##f = 1 << TCP_FLAG_BIT_##f,
foreach_tcp_flag
#undef _
};
diff --git a/lib/src/compat.c b/lib/src/compat.c
index 615175e3b..5473aaca8 100644
--- a/lib/src/compat.c
+++ b/lib/src/compat.c
@@ -543,10 +543,10 @@ hicn_packet_get_payload_type (const hicn_header_t * h,
switch (HICN_IP_VERSION (h))
{
case 6:
- *payload_type = ((h->v6.tcp.flags & HICN_TCP_FLAG_URG) == HICN_TCP_FLAG_URG);
+ *payload_type = ((h->v6.tcp.flags & TCP_FLAG_URG) == TCP_FLAG_URG);
break;
case 4:
- *payload_type = ((h->v4.tcp.flags & HICN_TCP_FLAG_URG) == HICN_TCP_FLAG_URG);
+ *payload_type = ((h->v4.tcp.flags & TCP_FLAG_URG) == TCP_FLAG_URG);
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -573,15 +573,15 @@ hicn_packet_set_payload_type (hicn_header_t * h,
{
case 6:
if (payload_type)
- h->v6.tcp.flags = h->v6.tcp.flags | HICN_TCP_FLAG_URG;
+ h->v6.tcp.flags = h->v6.tcp.flags | TCP_FLAG_URG;
else
- h->v6.tcp.flags = h->v6.tcp.flags & ~HICN_TCP_FLAG_URG;
+ h->v6.tcp.flags = h->v6.tcp.flags & ~TCP_FLAG_URG;
break;
case 4:
if (payload_type)
- h->v4.tcp.flags = h->v4.tcp.flags | HICN_TCP_FLAG_URG;
+ h->v4.tcp.flags = h->v4.tcp.flags | TCP_FLAG_URG;
else
- h->v4.tcp.flags = h->v4.tcp.flags & ~HICN_TCP_FLAG_URG;
+ h->v4.tcp.flags = h->v4.tcp.flags & ~TCP_FLAG_URG;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -596,10 +596,10 @@ hicn_packet_set_syn (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags | HICN_TCP_FLAG_SYN;
+ h->v6.tcp.flags = h->v6.tcp.flags | TCP_FLAG_SYN;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags | HICN_TCP_FLAG_SYN;
+ h->v4.tcp.flags = h->v4.tcp.flags | TCP_FLAG_SYN;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -613,10 +613,10 @@ hicn_packet_reset_syn (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags & ~HICN_TCP_FLAG_SYN;
+ h->v6.tcp.flags = h->v6.tcp.flags & ~TCP_FLAG_SYN;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags & ~HICN_TCP_FLAG_SYN;
+ h->v4.tcp.flags = h->v4.tcp.flags & ~TCP_FLAG_SYN;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -630,10 +630,10 @@ hicn_packet_test_syn (const hicn_header_t * h, bool * flag)
switch (HICN_IP_VERSION (h))
{
case 6:
- *flag = h->v6.tcp.flags & HICN_TCP_FLAG_SYN;
+ *flag = h->v6.tcp.flags & TCP_FLAG_SYN;
break;
case 4:
- *flag = h->v4.tcp.flags & HICN_TCP_FLAG_SYN;
+ *flag = h->v4.tcp.flags & TCP_FLAG_SYN;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -647,10 +647,10 @@ hicn_packet_set_ack (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags | HICN_TCP_FLAG_ACK;
+ h->v6.tcp.flags = h->v6.tcp.flags | TCP_FLAG_ACK;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags | HICN_TCP_FLAG_ACK;
+ h->v4.tcp.flags = h->v4.tcp.flags | TCP_FLAG_ACK;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -664,10 +664,10 @@ hicn_packet_reset_ack (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags & ~HICN_TCP_FLAG_ACK;
+ h->v6.tcp.flags = h->v6.tcp.flags & ~TCP_FLAG_ACK;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags & ~HICN_TCP_FLAG_ACK;
+ h->v4.tcp.flags = h->v4.tcp.flags & ~TCP_FLAG_ACK;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -681,10 +681,10 @@ hicn_packet_test_ack (const hicn_header_t * h, bool * flag)
switch (HICN_IP_VERSION (h))
{
case 6:
- *flag = h->v6.tcp.flags & HICN_TCP_FLAG_ACK;
+ *flag = h->v6.tcp.flags & TCP_FLAG_ACK;
break;
case 4:
- *flag = h->v4.tcp.flags & HICN_TCP_FLAG_ACK;
+ *flag = h->v4.tcp.flags & TCP_FLAG_ACK;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -698,10 +698,10 @@ hicn_packet_set_rst (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags | HICN_TCP_FLAG_RST;
+ h->v6.tcp.flags = h->v6.tcp.flags | TCP_FLAG_RST;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags | HICN_TCP_FLAG_RST;
+ h->v4.tcp.flags = h->v4.tcp.flags | TCP_FLAG_RST;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -715,10 +715,10 @@ hicn_packet_reset_rst (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags & ~HICN_TCP_FLAG_RST;
+ h->v6.tcp.flags = h->v6.tcp.flags & ~TCP_FLAG_RST;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags & ~HICN_TCP_FLAG_RST;
+ h->v4.tcp.flags = h->v4.tcp.flags & ~TCP_FLAG_RST;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -732,10 +732,10 @@ hicn_packet_test_rst (const hicn_header_t * h, bool * flag)
switch (HICN_IP_VERSION (h))
{
case 6:
- *flag = h->v6.tcp.flags & HICN_TCP_FLAG_RST;
+ *flag = h->v6.tcp.flags & TCP_FLAG_RST;
break;
case 4:
- *flag = h->v4.tcp.flags & HICN_TCP_FLAG_RST;
+ *flag = h->v4.tcp.flags & TCP_FLAG_RST;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -749,10 +749,10 @@ hicn_packet_set_fin (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags | HICN_TCP_FLAG_FIN;
+ h->v6.tcp.flags = h->v6.tcp.flags | TCP_FLAG_FIN;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags | HICN_TCP_FLAG_FIN;
+ h->v4.tcp.flags = h->v4.tcp.flags | TCP_FLAG_FIN;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -766,10 +766,10 @@ hicn_packet_reset_fin (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags & ~HICN_TCP_FLAG_FIN;
+ h->v6.tcp.flags = h->v6.tcp.flags & ~TCP_FLAG_FIN;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags & ~HICN_TCP_FLAG_FIN;
+ h->v4.tcp.flags = h->v4.tcp.flags & ~TCP_FLAG_FIN;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -783,10 +783,10 @@ hicn_packet_test_fin (const hicn_header_t * h, bool * flag)
switch (HICN_IP_VERSION (h))
{
case 6:
- *flag = h->v6.tcp.flags & HICN_TCP_FLAG_FIN;
+ *flag = h->v6.tcp.flags & TCP_FLAG_FIN;
break;
case 4:
- *flag = h->v4.tcp.flags & HICN_TCP_FLAG_FIN;
+ *flag = h->v4.tcp.flags & TCP_FLAG_FIN;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -800,10 +800,10 @@ hicn_packet_set_ece (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags | HICN_TCP_FLAG_ECE;
+ h->v6.tcp.flags = h->v6.tcp.flags | TCP_FLAG_ECE;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags | HICN_TCP_FLAG_ECE;
+ h->v4.tcp.flags = h->v4.tcp.flags | TCP_FLAG_ECE;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -817,10 +817,10 @@ hicn_packet_reset_ece (hicn_header_t * h)
switch (HICN_IP_VERSION (h))
{
case 6:
- h->v6.tcp.flags = h->v6.tcp.flags & ~HICN_TCP_FLAG_ECE;
+ h->v6.tcp.flags = h->v6.tcp.flags & ~TCP_FLAG_ECE;
break;
case 4:
- h->v4.tcp.flags = h->v4.tcp.flags & ~HICN_TCP_FLAG_ECE;
+ h->v4.tcp.flags = h->v4.tcp.flags & ~TCP_FLAG_ECE;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -834,10 +834,10 @@ hicn_packet_test_ece (const hicn_header_t * h, bool * flag)
switch (HICN_IP_VERSION (h))
{
case 6:
- *flag = h->v6.tcp.flags & HICN_TCP_FLAG_ECE;
+ *flag = h->v6.tcp.flags & TCP_FLAG_ECE;
break;
case 4:
- *flag = h->v4.tcp.flags & HICN_TCP_FLAG_ECE;
+ *flag = h->v4.tcp.flags & TCP_FLAG_ECE;
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
diff --git a/lib/src/ops.c b/lib/src/ops.c
index 9bb78be65..d49138398 100644
--- a/lib/src/ops.c
+++ b/lib/src/ops.c
@@ -40,6 +40,8 @@ DECLARE_get_interest_name (none, NONE);
DECLARE_set_interest_name (none, NONE);
DECLARE_get_interest_name_suffix (none, NONE);
DECLARE_set_interest_name_suffix (none, NONE);
+DECLARE_mark_packet_as_interest (none, NONE);
+DECLARE_mark_packet_as_data (none, NONE);
DECLARE_reset_interest_for_hash (none, NONE);
DECLARE_get_data_locator (none, NONE);
DECLARE_set_data_locator (none, NONE);
diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c
index c2f3f552a..da08d1ee8 100644
--- a/lib/src/protocol/ah.c
+++ b/lib/src/protocol/ah.c
@@ -31,6 +31,8 @@ DECLARE_get_interest_name (ah, UNEXPECTED);
DECLARE_set_interest_name (ah, UNEXPECTED);
DECLARE_get_interest_name_suffix (ah, UNEXPECTED);
DECLARE_set_interest_name_suffix (ah, UNEXPECTED);
+DECLARE_mark_packet_as_interest (ah, UNEXPECTED)
+DECLARE_mark_packet_as_data (ah, UNEXPECTED)
DECLARE_get_data_locator (ah, UNEXPECTED);
DECLARE_set_data_locator (ah, UNEXPECTED);
DECLARE_get_data_name (ah, UNEXPECTED);
diff --git a/lib/src/protocol/icmp.c b/lib/src/protocol/icmp.c
index 85605a2c3..b24c0f11e 100644
--- a/lib/src/protocol/icmp.c
+++ b/lib/src/protocol/icmp.c
@@ -25,6 +25,8 @@ DECLARE_get_interest_name (icmp, UNEXPECTED)
DECLARE_set_interest_name (icmp, UNEXPECTED)
DECLARE_get_interest_name_suffix (icmp, UNEXPECTED)
DECLARE_set_interest_name_suffix (icmp, UNEXPECTED)
+DECLARE_mark_packet_as_interest (icmp, UNEXPECTED)
+DECLARE_mark_packet_as_data (icmp, UNEXPECTED)
DECLARE_get_data_locator (icmp, UNEXPECTED)
DECLARE_set_data_locator (icmp, UNEXPECTED)
DECLARE_get_data_name (icmp, UNEXPECTED)
diff --git a/lib/src/protocol/ipv4.c b/lib/src/protocol/ipv4.c
index d8d958350..781907231 100644
--- a/lib/src/protocol/ipv4.c
+++ b/lib/src/protocol/ipv4.c
@@ -109,6 +109,18 @@ ipv4_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t * h,
}
int
+ipv4_mark_packet_as_interest (hicn_type_t type, hicn_protocol_t * h)
+{
+ return CHILD_OPS (mark_packet_as_interest, type, h);
+}
+
+int
+ipv4_mark_packet_as_data (hicn_type_t type, hicn_protocol_t * h)
+{
+ return CHILD_OPS (mark_packet_as_data, type, h);
+}
+
+int
ipv4_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
{
/* Sets everything to 0 up to IP destination address */
diff --git a/lib/src/protocol/ipv6.c b/lib/src/protocol/ipv6.c
index 622355294..f23b01cd8 100644
--- a/lib/src/protocol/ipv6.c
+++ b/lib/src/protocol/ipv6.c
@@ -99,6 +99,18 @@ ipv6_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t * h,
}
int
+ipv6_mark_packet_as_interest (hicn_type_t type, hicn_protocol_t * h)
+{
+ return CHILD_OPS (mark_packet_as_interest, type, h);
+}
+
+int
+ipv6_mark_packet_as_data (hicn_type_t type, hicn_protocol_t * h)
+{
+ return CHILD_OPS (mark_packet_as_data, type, h);
+}
+
+int
ipv6_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
{
/* Sets everything to 0 up to IP destination address */
diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c
index 0e3155020..14e07b091 100644
--- a/lib/src/protocol/tcp.c
+++ b/lib/src/protocol/tcp.c
@@ -83,6 +83,20 @@ tcp_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t * h,
}
int
+tcp_mark_packet_as_interest (hicn_type_t type, hicn_protocol_t * h)
+{
+ h->tcp.flags &= ~TCP_FLAG_ECE;
+ return HICN_LIB_ERROR_NONE;
+}
+
+int
+tcp_mark_packet_as_data (hicn_type_t type, hicn_protocol_t * h)
+{
+ h->tcp.flags |= TCP_FLAG_ECE;
+ return HICN_LIB_ERROR_NONE;
+}
+
+int
tcp_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
{
memset (&(h->tcp), 0, 4);