aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-06-06 11:03:13 +0200
committerMauro Sardara <msardara@cisco.com>2019-06-06 12:32:46 +0000
commit8400addd9e21b9ba5a7e210f2cd27842dbf8cd38 (patch)
tree79f4ff9a75af0bfe99f5ee6f07cf9eccae3fd584 /hicn-plugin/src
parent8129b8ce13febec6730fa48abbe6d3fcae3bc27f (diff)
[HICN-212] Fixed bug on ipv6 test in udp faces. Uniformed test with a single function.
Change-Id: I79cd1c0233c841d5eb111ba6247f46c7510a09bb Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src')
-rw-r--r--hicn-plugin/src/faces/udp/face_udp_node.c6
-rw-r--r--hicn-plugin/src/faces/udp/iface_udp_node.c12
-rw-r--r--hicn-plugin/src/hicn.h6
-rw-r--r--hicn-plugin/src/parser.h6
4 files changed, 18 insertions, 12 deletions
diff --git a/hicn-plugin/src/faces/udp/face_udp_node.c b/hicn-plugin/src/faces/udp/face_udp_node.c
index 184fea679..5d304693d 100644
--- a/hicn-plugin/src/faces/udp/face_udp_node.c
+++ b/hicn-plugin/src/faces/udp/face_udp_node.c
@@ -137,7 +137,7 @@ typedef enum
hicnb0 = hicn_get_buffer(b0); \
\
inner_ip_hdr = (u8 *)(udp_hdr + 1); \
- u8 is_v6 = ((inner_ip_hdr[0] & 2) >> 1); \
+ u8 is_v6 = hicn_is_v6((hicn_header_t *)inner_ip_hdr); \
u8 is_icmp = is_v6*(inner_ip_hdr[7] == IPPROTO_ICMPV6) + \
(1 - is_v6)*(inner_ip_hdr[10] == IPPROTO_ICMPV4); \
\
@@ -235,12 +235,12 @@ typedef enum
hicnb1 = hicn_get_buffer(b1); \
\
inner_ip_hdr0 = (u8 *)(udp_hdr0 + 1); \
- u8 is_v6_0 = ((inner_ip_hdr0[0] & 2) >> 1); \
+ u8 is_v6_0 = hicn_is_v6((hicn_header_t *)inner_ip_hdr0); \
u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[7] == IPPROTO_ICMPV6) + \
(1 - is_v6_0)*(inner_ip_hdr0[10] == IPPROTO_ICMPV4); \
\
inner_ip_hdr1 = (u8 *)(udp_hdr1 + 1); \
- u8 is_v6_1 = ((inner_ip_hdr1[0] & 2) >> 1); \
+ u8 is_v6_1 = hicn_is_v6((hicn_header_t *)inner_ip_hdr1); \
u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[7] == IPPROTO_ICMPV6) + \
(1 - is_v6_1)*(inner_ip_hdr1[10] == IPPROTO_ICMPV4); \
\
diff --git a/hicn-plugin/src/faces/udp/iface_udp_node.c b/hicn-plugin/src/faces/udp/iface_udp_node.c
index 4dc267f85..738aad829 100644
--- a/hicn-plugin/src/faces/udp/iface_udp_node.c
+++ b/hicn-plugin/src/faces/udp/iface_udp_node.c
@@ -39,11 +39,13 @@ hicn_iface_udp_init (vlib_main_t * vm)
{
data_fwd_face_udp4_vlib_edge = vlib_node_add_next (vm,
hicn_data_fwd_node.index,
- hicn_iface_udp4_output_node.index);
+ hicn_iface_udp4_output_node.
+ index);
data_fwd_face_udp6_vlib_edge = vlib_node_add_next (vm,
hicn_data_fwd_node.index,
- hicn_iface_udp6_output_node.index);
+ hicn_iface_udp6_output_node.
+ index);
u32 temp_index4 = vlib_node_add_next (vm,
hicn_interest_hitcs_node.index,
@@ -170,7 +172,7 @@ typedef enum
stats.pkts_interest_count += 1; \
\
inner_ip_hdr = (u8 *)(udp_hdr + 1); \
- u8 is_v6 = ((inner_ip_hdr[0] & 2) >> 1); \
+ u8 is_v6 = hicn_is_v6((hicn_header_t *)inner_ip_hdr); \
u8 is_icmp = is_v6*(inner_ip_hdr[7] == IPPROTO_ICMPV6) + \
(1 - is_v6)*(inner_ip_hdr[10] == IPPROTO_ICMPV4); \
\
@@ -263,8 +265,8 @@ typedef enum
\
inner_ip_hdr0 = (u8 *)(udp_hdr0 + 1); \
inner_ip_hdr1 = (u8 *)(udp_hdr1 + 1); \
- u8 is_v6_0 = ((inner_ip_hdr0[0] & 2) >> 1); \
- u8 is_v6_1 = ((inner_ip_hdr1[0] & 2) >> 1); \
+ u8 is_v6_0 = hicn_is_v6((hicn_header_t *)inner_ip_hdr0); \
+ u8 is_v6_1 = hicn_is_v6((hicn_header_t *)inner_ip_hdr1); \
u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[7] == IPPROTO_ICMPV6) + \
(1 - is_v6_0)*(inner_ip_hdr0[10] == IPPROTO_ICMPV4); \
u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[7] == IPPROTO_ICMPV6) + \
diff --git a/hicn-plugin/src/hicn.h b/hicn-plugin/src/hicn.h
index c0de65de4..87628ba53 100644
--- a/hicn-plugin/src/hicn.h
+++ b/hicn-plugin/src/hicn.h
@@ -81,6 +81,12 @@ hicn_get_buffer (vlib_buffer_t * b0)
return (hicn_buffer_t *) & (b0->opaque2[0]);
}
+always_inline u8
+hicn_is_v6 (hicn_header_t * pkt_hdr)
+{
+ return ((pkt_hdr->v4.ip.version_ihl >> 4) != 4);
+}
+
#endif /* __HICN_H__ */
diff --git a/hicn-plugin/src/parser.h b/hicn-plugin/src/parser.h
index cbc5696ba..0d72780ae 100644
--- a/hicn-plugin/src/parser.h
+++ b/hicn-plugin/src/parser.h
@@ -42,8 +42,7 @@ hicn_interest_parse_pkt (vlib_buffer_t * pkt, hicn_name_t * name,
hicn_header_t *pkt_hdr = vlib_buffer_get_current (pkt);
*pkt_hdrp = pkt_hdr;
u8 *ip_pkt = vlib_buffer_get_current (pkt);
- u8 version = (pkt_hdr->v4.ip.version_ihl & 0xf0) >> 4;
- *isv6 = ((version & 2) >> 1);
+ *isv6 = hicn_is_v6 (pkt_hdr);
u8 ip_proto = (*isv6) * IPPROTO_IPV6;
u8 next_proto_offset = 6 + (1 - *isv6) * 3;
//in the ipv6 header the next header field is at byte 6
@@ -72,8 +71,7 @@ hicn_data_parse_pkt (vlib_buffer_t * pkt, hicn_name_t * name,
*pkt_hdrp = pkt_hdr;
*pkt_hdrp = pkt_hdr;
u8 *ip_pkt = vlib_buffer_get_current (pkt);
- u8 version = (pkt_hdr->v4.ip.version_ihl & 0xf0) >> 4;
- *isv6 = ((version & 2) >> 1);
+ *isv6 = hicn_is_v6 (pkt_hdr);
u8 ip_proto = (*isv6) * IPPROTO_IPV6;
/*
* in the ipv6 header the next header field is at byte 6 in the ipv4