aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/protocol')
-rw-r--r--lib/src/protocol/ah.c6
-rw-r--r--lib/src/protocol/icmp.c6
-rw-r--r--lib/src/protocol/ipv4.c46
-rw-r--r--lib/src/protocol/ipv6.c47
-rw-r--r--lib/src/protocol/new.c14
-rw-r--r--lib/src/protocol/tcp.c37
-rw-r--r--lib/src/protocol/udp.c38
7 files changed, 9 insertions, 185 deletions
diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c
index 645b0482b..ea028d559 100644
--- a/lib/src/protocol/ah.c
+++ b/lib/src/protocol/ah.c
@@ -50,12 +50,6 @@ DECLARE_get_payload_type (ah, UNEXPECTED);
DECLARE_set_payload_type (ah, UNEXPECTED);
DECLARE_is_last_data (ah, UNEXPECTED);
DECLARE_set_last_data (ah, UNEXPECTED);
-DECLARE_get_ttl (ah, UNEXPECTED);
-DECLARE_set_ttl (ah, UNEXPECTED);
-DECLARE_get_src_port (ah, UNEXPECTED);
-DECLARE_set_src_port (ah, UNEXPECTED);
-DECLARE_get_dst_port (ah, UNEXPECTED);
-DECLARE_set_dst_port (ah, UNEXPECTED);
int
ah_init_packet_header (hicn_packet_buffer_t *pkbuf, size_t pos)
diff --git a/lib/src/protocol/icmp.c b/lib/src/protocol/icmp.c
index 71417a4e0..5ee70f088 100644
--- a/lib/src/protocol/icmp.c
+++ b/lib/src/protocol/icmp.c
@@ -44,12 +44,6 @@ DECLARE_get_signature (icmp, UNEXPECTED);
DECLARE_has_signature (icmp, UNEXPECTED);
DECLARE_is_last_data (icmp, UNEXPECTED);
DECLARE_set_last_data (icmp, UNEXPECTED);
-DECLARE_get_ttl (icmp, UNEXPECTED);
-DECLARE_set_ttl (icmp, UNEXPECTED);
-DECLARE_get_src_port (icmp, UNEXPECTED);
-DECLARE_set_src_port (icmp, UNEXPECTED);
-DECLARE_get_dst_port (icmp, UNEXPECTED);
-DECLARE_set_dst_port (icmp, UNEXPECTED);
int
icmp_init_packet_header (hicn_packet_buffer_t *pkbuf, size_t pos)
diff --git a/lib/src/protocol/ipv4.c b/lib/src/protocol/ipv4.c
index a13728d04..daa5a706a 100644
--- a/lib/src/protocol/ipv4.c
+++ b/lib/src/protocol/ipv4.c
@@ -60,7 +60,7 @@ ipv4_init_packet_header (hicn_packet_buffer_t *pkbuf, size_t pos)
.id = htons (IPV4_DEFAULT_ID),
.frag_off = htons (IPV4_DEFAULT_FRAG_OFF),
.ttl = HICN_DEFAULT_TTL,
- .protocol = format.as_u8[pos + 1],
+ .protocol = HICN_PACKET_FORMAT_GET (format, pos + 1),
.csum = 0,
.saddr.as_u32 = 0,
.daddr.as_u32 = 0,
@@ -530,50 +530,6 @@ ipv4_set_last_data (const hicn_packet_buffer_t *pkbuf, size_t pos)
return CALL_CHILD (set_last_data, pkbuf, pos);
}
-int
-ipv4_get_ttl (const hicn_packet_buffer_t *pkbuf, size_t pos, u8 *hops)
-{
- _ipv4_header_t *ipv4 = pkbuf_get_ipv4 (pkbuf);
-
- *hops = ipv4->ttl;
-
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-ipv4_set_ttl (const hicn_packet_buffer_t *pkbuf, size_t pos, u8 hops)
-{
- _ipv4_header_t *ipv4 = pkbuf_get_ipv4 (pkbuf);
-
- ipv4->ttl = hops;
-
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-ipv4_get_src_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 *port)
-{
- return CALL_CHILD (get_src_port, pkbuf, pos, port);
-}
-
-int
-ipv4_set_src_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 port)
-{
- return CALL_CHILD (set_src_port, pkbuf, pos, port);
-}
-
-int
-ipv4_get_dst_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 *port)
-{
- return CALL_CHILD (get_dst_port, pkbuf, pos, port);
-}
-
-int
-ipv4_set_dst_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 port)
-{
- return CALL_CHILD (set_dst_port, pkbuf, pos, port);
-}
-
DECLARE_HICN_OPS (ipv4, IPV4_HDRLEN);
/*
diff --git a/lib/src/protocol/ipv6.c b/lib/src/protocol/ipv6.c
index aec521afc..c5fa643aa 100644
--- a/lib/src/protocol/ipv6.c
+++ b/lib/src/protocol/ipv6.c
@@ -53,7 +53,7 @@ ipv6_init_packet_header (hicn_packet_buffer_t *pkbuf, size_t pos)
(IPV6_DEFAULT_TRAFFIC_CLASS << 20) |
(IPV6_DEFAULT_FLOW_LABEL & 0xfffff)),
.len = htons(header_len - IPV6_HDRLEN),
- .nxt = format.as_u8[pos + 1],
+ .nxt = HICN_PACKET_FORMAT_GET(format, pos+1),
.hlim = HICN_DEFAULT_TTL,
};
/* clang-format on */
@@ -468,51 +468,6 @@ ipv6_set_last_data (const hicn_packet_buffer_t *pkbuf, size_t pos)
return CALL_CHILD (set_last_data, pkbuf, pos);
}
-int
-ipv6_get_ttl (const hicn_packet_buffer_t *pkbuf, size_t pos, u8 *hops)
-{
- _ipv6_header_t *ipv6 = pkbuf_get_ipv6 (pkbuf);
-
- *hops = ipv6->hlim;
-
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-ipv6_set_ttl (const hicn_packet_buffer_t *pkbuf, size_t pos, u8 hops)
-{
-
- _ipv6_header_t *ipv6 = pkbuf_get_ipv6 (pkbuf);
-
- ipv6->hlim = hops;
-
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-ipv6_get_src_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 *port)
-{
- return CALL_CHILD (get_src_port, pkbuf, pos, port);
-}
-
-int
-ipv6_set_src_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 port)
-{
- return CALL_CHILD (set_src_port, pkbuf, pos, port);
-}
-
-int
-ipv6_get_dst_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 *port)
-{
- return CALL_CHILD (get_dst_port, pkbuf, pos, port);
-}
-
-int
-ipv6_set_dst_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 port)
-{
- return CALL_CHILD (set_dst_port, pkbuf, pos, port);
-}
-
DECLARE_HICN_OPS (ipv6, IPV6_HDRLEN);
/*
diff --git a/lib/src/protocol/new.c b/lib/src/protocol/new.c
index 5308e8c0a..e86ce4753 100644
--- a/lib/src/protocol/new.c
+++ b/lib/src/protocol/new.c
@@ -24,13 +24,6 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
-DECLARE_get_ttl (new, UNEXPECTED);
-DECLARE_set_ttl (new, UNEXPECTED);
-DECLARE_get_src_port (new, UNEXPECTED);
-DECLARE_set_src_port (new, UNEXPECTED);
-DECLARE_get_dst_port (new, UNEXPECTED);
-DECLARE_set_dst_port (new, UNEXPECTED);
-
int
new_init_packet_header (hicn_packet_buffer_t *pkbuf, size_t pos)
{
@@ -45,8 +38,9 @@ new_init_packet_header (hicn_packet_buffer_t *pkbuf, size_t pos)
memset (new, 0, sizeof (_new_header_t));
_set_new_header_version (new);
- uint8_t ah_flag =
- format.as_u8[pos + 1] == IPPROTO_AH ? HICN_NEW_FLAG_SIG : 0;
+ uint8_t ah_flag = (HICN_PACKET_FORMAT_GET (format, pos + 1) == IPPROTO_AH) ?
+ HICN_NEW_FLAG_SIG :
+ 0;
new->flags |= ah_flag;
return CALL_CHILD (init_packet_header, pkbuf, pos);
@@ -128,6 +122,8 @@ new_get_interest_name (const hicn_packet_buffer_t *pkbuf, size_t pos,
return HICN_LIB_ERROR_NONE;
}
+// XXX never called and thus packet is never initialized as interest
+// DECLARE_set_interest_name (udp, UNEXPECTED);
int
new_set_interest_name (const hicn_packet_buffer_t *pkbuf, size_t pos,
const hicn_name_t *name)
diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c
index 822bd3e0c..e09495ecd 100644
--- a/lib/src/protocol/tcp.c
+++ b/lib/src/protocol/tcp.c
@@ -46,8 +46,6 @@ DECLARE_set_data_locator (tcp, UNEXPECTED);
DECLARE_get_data_name (tcp, UNEXPECTED);
DECLARE_set_data_name (tcp, UNEXPECTED);
DECLARE_set_payload_len (tcp, UNEXPECTED);
-DECLARE_get_ttl (tcp, UNEXPECTED);
-DECLARE_set_ttl (tcp, UNEXPECTED);
int tcp_update_checksums_incremental (const hicn_packet_buffer_t *pkbuf,
size_t pos, u16 *old_val, u16 *new_val,
@@ -115,7 +113,8 @@ tcp_init_packet_header (hicn_packet_buffer_t *pkbuf, size_t pos)
.urg_ptr = 65000,
};
- uint8_t ah_flag = ((format.as_u8[pos + 1] == IPPROTO_AH) ? AH_FLAG : 0);
+ uint8_t ah_flag =
+ (HICN_PACKET_FORMAT_GET (format, pos + 1) == IPPROTO_AH) ? AH_FLAG : 0;
tcp->flags |= ah_flag;
@@ -590,38 +589,6 @@ tcp_set_last_data (const hicn_packet_buffer_t *pkbuf, size_t pos)
return HICN_LIB_ERROR_NONE;
}
-int
-tcp_get_src_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 *port)
-{
- _tcp_header_t *tcp = pkbuf_get_tcp (pkbuf);
- *port = ntohs (tcp->sport);
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-tcp_set_src_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 port)
-{
- _tcp_header_t *tcp = pkbuf_get_tcp (pkbuf);
- tcp->sport = htons (port);
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-tcp_get_dst_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 *port)
-{
- _tcp_header_t *tcp = pkbuf_get_tcp (pkbuf);
- *port = ntohs (tcp->dport);
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-tcp_set_dst_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 port)
-{
- _tcp_header_t *tcp = pkbuf_get_tcp (pkbuf);
- tcp->dport = htons (port);
- return HICN_LIB_ERROR_NONE;
-}
-
DECLARE_HICN_OPS (tcp, TCP_HDRLEN);
/*
diff --git a/lib/src/protocol/udp.c b/lib/src/protocol/udp.c
index ff2355b0c..56de0065f 100644
--- a/lib/src/protocol/udp.c
+++ b/lib/src/protocol/udp.c
@@ -30,8 +30,6 @@ DECLARE_set_data_locator (udp, UNEXPECTED);
DECLARE_get_data_name (udp, UNEXPECTED);
DECLARE_set_data_name (udp, UNEXPECTED);
DECLARE_set_payload_len (udp, UNEXPECTED);
-DECLARE_get_ttl (udp, UNEXPECTED);
-DECLARE_set_ttl (udp, UNEXPECTED);
int
udp_init_packet_header (hicn_packet_buffer_t *pkbuf, size_t pos)
@@ -299,42 +297,6 @@ udp_set_last_data (const hicn_packet_buffer_t *pkbuf, size_t pos)
return CALL_CHILD (set_last_data, pkbuf, pos);
}
-int
-udp_get_src_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 *port)
-{
- _udp_header_t *udp = pkbuf_get_udp (pkbuf);
-
- *port = udp->src_port;
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-udp_set_src_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 port)
-{
- _udp_header_t *udp = pkbuf_get_udp (pkbuf);
-
- udp->src_port = port;
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-udp_get_dst_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 *port)
-{
- _udp_header_t *udp = pkbuf_get_udp (pkbuf);
-
- *port = udp->dst_port;
- return HICN_LIB_ERROR_NONE;
-}
-
-int
-udp_set_dst_port (const hicn_packet_buffer_t *pkbuf, size_t pos, u16 port)
-{
- _udp_header_t *udp = pkbuf_get_udp (pkbuf);
-
- udp->dst_port = port;
- return HICN_LIB_ERROR_NONE;
-}
-
DECLARE_HICN_OPS (udp, UDP_HDRLEN);
/*