diff options
author | Jordan Augé <jordan.auge+fdio@cisco.com> | 2019-10-07 09:52:33 +0200 |
---|---|---|
committer | Jordan Augé <jordan.auge+fdio@cisco.com> | 2019-10-07 15:55:42 +0200 |
commit | 6b84ec54083da9911f5ad4816d0eb4f4745afad4 (patch) | |
tree | e4296ebb218fff02dc0bbea73ce1c8d12aba7bcc /lib/src/protocol | |
parent | 85a791ac2cdd35d79c00141e748b4c68fbdafb0d (diff) |
[HICN-298] Release new hICN app for Android
Change-Id: I43adc62fadf00690b687078d739788dffdc5e566
Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'lib/src/protocol')
-rw-r--r-- | lib/src/protocol/ah.c | 10 | ||||
-rw-r--r-- | lib/src/protocol/ah.h | 80 | ||||
-rw-r--r-- | lib/src/protocol/icmp.c | 6 | ||||
-rw-r--r-- | lib/src/protocol/icmp.h | 84 | ||||
-rw-r--r-- | lib/src/protocol/icmprd.h | 72 | ||||
-rw-r--r-- | lib/src/protocol/ipv4.c | 10 | ||||
-rw-r--r-- | lib/src/protocol/ipv4.h | 105 | ||||
-rw-r--r-- | lib/src/protocol/ipv6.c | 6 | ||||
-rw-r--r-- | lib/src/protocol/ipv6.h | 80 | ||||
-rw-r--r-- | lib/src/protocol/tcp.c | 6 | ||||
-rw-r--r-- | lib/src/protocol/tcp.h | 173 | ||||
-rw-r--r-- | lib/src/protocol/udp.h | 44 |
12 files changed, 19 insertions, 657 deletions
diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c index 5a30f66f6..c2f3f552a 100644 --- a/lib/src/protocol/ah.c +++ b/lib/src/protocol/ah.c @@ -19,11 +19,11 @@ */ #include <string.h> // memcpy -#include "../common.h" -#include "../error.h" -#include "../header.h" -#include "../ops.h" -#include "ah.h" +#include <hicn/common.h> +#include <hicn/error.h> +#include <hicn/header.h> +#include <hicn/ops.h> +#include <hicn/protocol/ah.h> DECLARE_get_interest_locator (ah, UNEXPECTED); DECLARE_set_interest_locator (ah, UNEXPECTED); diff --git a/lib/src/protocol/ah.h b/lib/src/protocol/ah.h deleted file mode 100644 index a59a5051a..000000000 --- a/lib/src/protocol/ah.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file protocol/ah.h - * @brief AH packet header - */ -#ifndef HICN_PROTOCOL_AH_H -#define HICN_PROTOCOL_AH_H - -#include "../common.h" - -/* - * The TCP PSH flag is set to indicate TCP payload in fact contains a AH header - * with signature information for the packet - */ -#define AH_FLAG 0x10 - -/* - * The length of the AH struct must be 44 bytes. - */ -#define EXPECTED_AH_HDRLEN 44 - -typedef struct -{ - u8 nh; // (to match with reserved in IPSEC AH) - u8 payloadlen; // Len of signature/HMAC in 4-bytes words - union - { - u16 reserved; - - struct - { - u8 validationAlgorithm; // As defined in parc_SignerAlgorithm.h - u8 unused; // Unused (to match with reserved in IPSEC AH) - }; - }; - union - { - struct - { - u32 spi; - u32 seq; - }; - // Unix timestamp indicating when the signature has been calculated - u8 timestamp_as_u8[8]; - u16 timestamp_as_u16[4]; - u32 timestamp_as_u32[2]; - }; - // ICV would follow - u8 keyId[32]; // Hash of the pub key - /* 44 B + validationPayload */ - u8 validationPayload[0]; // Holds the signature -} _ah_header_t; - -#define AH_HDRLEN sizeof(_ah_header_t) -static_assert (EXPECTED_AH_HDRLEN == AH_HDRLEN, - "Size of AH Struct does not match its expected size."); - -#endif /* HICN_PROTOCOL_AH_H */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/lib/src/protocol/icmp.c b/lib/src/protocol/icmp.c index 45a28959c..85605a2c3 100644 --- a/lib/src/protocol/icmp.c +++ b/lib/src/protocol/icmp.c @@ -14,10 +14,10 @@ */ #include <string.h> -#include "icmp.h" +#include <hicn/protocol/icmp.h> -#include "../error.h" -#include "../ops.h" +#include <hicn/error.h> +#include <hicn/ops.h> DECLARE_get_interest_locator (icmp, UNEXPECTED) DECLARE_set_interest_locator (icmp, UNEXPECTED) diff --git a/lib/src/protocol/icmp.h b/lib/src/protocol/icmp.h deleted file mode 100644 index 36954bb6d..000000000 --- a/lib/src/protocol/icmp.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file protocol/icmp.h - * @brief ICMP packet header - */ -#ifndef HICN_PROTOCOL_ICMP_H -#define HICN_PROTOCOL_ICMP_H - -#include "../common.h" - -/* - * The length of the ICMP header struct must be 4 bytes. - */ -#define EXPECTED_ICMP_HDRLEN 4 - -typedef struct -{ - u8 type; - u8 code; - u16 csum; -} _icmp_header_t; - -#define ICMP_HDRLEN sizeof(_icmp_header_t) -static_assert (EXPECTED_ICMP_HDRLEN == ICMP_HDRLEN, - "Size of ICMP struct does not match its expected size."); - -/* - * The length of the ICMPWLDR header struct must be 4 bytes. - */ -#define EXPECTED_ICMPWLDR_HDRLEN 8 - -typedef struct -{ - u8 type; - u8 code; - u16 csum; - union - { - struct - { - u16 id; - u16 sequence; - } echo; /* echo datagram */ - u32 gateway; /* gateway address */ - struct - { - u16 _unused; - u16 mtu; - } frag; /* path mtu discovery */ - struct - { - u16 expected_lbl; - u16 received_lbl; - } wldr_notification_lbl; - }; -} _icmp_wldr_header_t; - -#define ICMPWLDR_HDRLEN sizeof(_icmp_wldr_header_t) -static_assert (EXPECTED_ICMPWLDR_HDRLEN == ICMPWLDR_HDRLEN, - "Size of ICMPWLDR struct does not match its expected size."); - -#endif /* HICN_PROTOCOL_ICMP_H */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/lib/src/protocol/icmprd.h b/lib/src/protocol/icmprd.h deleted file mode 100644 index aa1fa01ae..000000000 --- a/lib/src/protocol/icmprd.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file protocol/icmp-rd.c - * @brief hICN operations for ICMP Redirect header - */ -#ifndef HICN_PROTOCOL_ICMPRD_H -#define HICN_PROTOCOL_ICMPRD_H - -#include "../common.h" -#include "ipv4.h" - -/* - * The length of the ICMPRD4 header struct must be 92 bytes. - */ -#define EXPECTED_ICMPRD4_HDRLEN 92 - -typedef struct -{ - u8 type; - u8 code; - u16 csum; - ip4_address_t ip; - _ipv4_header_t iph; - u8 data[64]; -} _icmprd4_header_t; - -#define ICMPRD4_HDRLEN sizeof(_icmprd4_header_t) -static_assert (EXPECTED_ICMPRD4_HDRLEN == ICMPRD4_HDRLEN, - "Size of ICMPWLDR struct does not match its expected size."); - -/* - * The length of the ICMPRD header struct must be 40 bytes. - */ -#define EXPECTED_ICMPRD_HDRLEN 40 - -typedef struct -{ - u8 type; - u8 code; - u16 csum; - u32 res; - ip6_address_t tgt; - ip6_address_t dst; -} _icmprd_header_t; - -#define ICMPRD_HDRLEN sizeof(_icmprd_header_t) -static_assert (EXPECTED_ICMPRD_HDRLEN == ICMPRD_HDRLEN, - "Size of ICMPWLDR struct does not match its expected size."); - -#endif /* HICN_PROTOCOL_ICMPRD_H */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/lib/src/protocol/ipv4.c b/lib/src/protocol/ipv4.c index 3c82b3223..d8d958350 100644 --- a/lib/src/protocol/ipv4.c +++ b/lib/src/protocol/ipv4.c @@ -27,12 +27,12 @@ #include <stdlib.h> #include <string.h> -#include "../error.h" -#include "../ops.h" -#include "../common.h" -#include "../header.h" +#include <hicn/error.h> +#include <hicn/ops.h> +#include <hicn/common.h> +#include <hicn/header.h> -#include "ipv4.h" +#include <hicn/protocol/ipv4.h> int ipv4_get_payload_length (hicn_type_t type, const hicn_protocol_t * h, size_t * payload_length); diff --git a/lib/src/protocol/ipv4.h b/lib/src/protocol/ipv4.h deleted file mode 100644 index 8a5b6683b..000000000 --- a/lib/src/protocol/ipv4.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef HICN_PROTOCOL_IPV4 -#define HICN_PROTOCOL_IPV4 - -#include "../base.h" -#include "../common.h" -#include "../protocol.h" - -/* Headers were adapted from linux' definitions in netinet/ip.h */ - -/* - * The length of the IPV4 header struct must be 20 bytes. - */ -#define EXPECTED_IPV4_HDRLEN 20 - -typedef struct -{ - union - { - struct - { -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - u8 ihl:4; - u8 version:4; -#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - u8 version:4; - u8 ihl:4; -#else -#error "Unsupported endianness" -#endif - }; - - u8 version_ihl; - }; - u8 tos; - u16 len; - u16 id; - u16 frag_off; - u8 ttl; - u8 protocol; - u16 csum; - ip4_address_t saddr; - ip4_address_t daddr; -} _ipv4_header_t; - -#define ipv4_header_bytes(ipv4_header) (sizeof(u32) * (ipv4_header->version_ihl & 0xf)) - -#define IPV4_HDRLEN sizeof(_ipv4_header_t) -static_assert (EXPECTED_IPV4_HDRLEN == IPV4_HDRLEN, - "Size of IPV4 struct does not match its expected size."); - -/* - * The length of the IPV4 pseudo header struct must be 12 bytes. - */ -#define EXPECTED_IPV4_PSHDRLEN 12 - -typedef struct -{ - ip4_address_t ip_src; - ip4_address_t ip_dst; - u8 zero; - u8 protocol; - u16 size; -} ipv4_pseudo_header_t; - -#define IPV4_PSHDRLEN sizeof(ipv4_pseudo_header_t) -static_assert (EXPECTED_IPV4_PSHDRLEN == IPV4_PSHDRLEN, - "Size of IPV4_PSHDR struct does not match its expected size."); - -/* Default field values */ -#define IPV4_DEFAULT_VERSION 4 -#define IPV4_DEFAULT_IHL 5 -#define IPV4_DEFAULT_TOS 0 -#define IPV4_DEFAULT_PAYLOAD_LENGTH 0 -#define IPV4_DEFAULT_ID 300 -#define IPV4_DEFAULT_FRAG_OFF 0x000 -#define IPV4_DEFAULT_TTL 64 -#define IPV4_DEFAULT_PROTOCOL IPPROTO_TCP -#define IPV4_DEFAULT_SRC_IP 0, 0, 0, 0 -#define IPV4_DEFAULT_DST_IP 0, 0, 0, 0 - - -#endif /* HICN_PROTOCOL_IPV4 */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/lib/src/protocol/ipv6.c b/lib/src/protocol/ipv6.c index 7554eadf2..622355294 100644 --- a/lib/src/protocol/ipv6.c +++ b/lib/src/protocol/ipv6.c @@ -16,9 +16,9 @@ #include <stdlib.h> #include <string.h> -#include "../common.h" -#include "../error.h" -#include "../ops.h" +#include <hicn/common.h> +#include <hicn/error.h> +#include <hicn/ops.h> int ipv6_get_payload_length (hicn_type_t type, const hicn_protocol_t * h, diff --git a/lib/src/protocol/ipv6.h b/lib/src/protocol/ipv6.h deleted file mode 100644 index 5a83abcae..000000000 --- a/lib/src/protocol/ipv6.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef HICN_PROTOCOL_IPV6_H -#define HICN_PROTOCOL_IPV6_H - -#include "../common.h" - -/* - * The length of the IPV6 header struct must be 40 bytes. - */ -#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; - -#define IPV6_HDRLEN sizeof(_ipv6_header_t) -static_assert (EXPECTED_IPV6_HDRLEN == IPV6_HDRLEN, - "Size of IPV6 struct does not match its expected size."); - -/* - * The length of the IPV6 pseudo header struct must be 40 bytes. - */ -#define EXPECTED_IPV6_PSHDRLEN 40 - -typedef struct -{ - ip6_address_t ip_src; - ip6_address_t ip_dst; - u32 size; - u16 zeros; - u8 zero; - u8 protocol; -} ipv6_pseudo_header_t; - -#define IPV6_PSHDRLEN sizeof(ipv6_pseudo_header_t) -static_assert (EXPECTED_IPV6_PSHDRLEN == IPV6_PSHDRLEN, - "Size of IPV6_PSHDR struct does not match its expected size."); - -/* Default field values */ -#define IPV6_DEFAULT_VERSION 6 -#define IPV6_DEFAULT_TRAFFIC_CLASS 0 -#define IPV6_DEFAULT_FLOW_LABEL 0 -#define IPV6_DEFAULT_PAYLOAD_LENGTH 0 - -#endif - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c index b9f1d2775..0e3155020 100644 --- a/lib/src/protocol/tcp.c +++ b/lib/src/protocol/tcp.c @@ -14,10 +14,10 @@ */ #include <string.h> -#include "tcp.h" +#include <hicn/protocol/tcp.h> -#include "../error.h" -#include "../ops.h" +#include <hicn/error.h> +#include <hicn/ops.h> #define TCP_DEFAULT_SRC_PORT 0x8000 #define TCP_DEFAULT_DST_PORT 0x0080 diff --git a/lib/src/protocol/tcp.h b/lib/src/protocol/tcp.h deleted file mode 100644 index ded9a06b2..000000000 --- a/lib/src/protocol/tcp.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef HICN_PROTOCOL_TCP_H -#define HICN_PROTOCOL_TCP_H - -#include "../base.h" -#include "../common.h" -#include "../name.h" - -/* - * The length of the TCP header struct must be 20 bytes. - */ -#define EXPECTED_TCP_HDRLEN 20 - -/* - * NOTE: bitfields are problematic for portability reasons. There are provided - * here for reference and documentation purposes, we might just provide a macro - * to disable and use it instead of __BYTE_ORDER__. - */ -typedef struct -{ - u16 sport; - u16 dport; - union - { - u32 seq; - hicn_name_suffix_t name_suffix; - }; - union - { - u32 seq_ack; - struct - { - hicn_pathlabel_t pathlabel; - u8 pad[3]; - }; - }; - - union - { - struct - { - u8 data_offset_and_reserved; - u8 flags; - }; -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - struct - { - u16 reserved:4; - u16 doff:4; - u16 fin:1; - u16 syn:1; - u16 rst:1; - u16 psh:1; - u16 ack:1; - u16 urg:1; - u16 ece:1; - u16 cwr:1; - }; - struct - { /* __ denotes unchanged bitfields */ - u16 timescale:4; - u16 __doff:4; - u16 __fin:1; - u16 __syn:1; - u16 __rst:1; - u16 sig:1; - u16 __ack:1; - u16 man:1; - u16 id:1; - u16 __cwr:1; - }; -#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - struct - { - u16 doff:4; - u16 reserved:4; - u16 cwr:1; - u16 ece:1; - u16 urg:1; - u16 ack:1; - u16 psh:1; - u16 rst:1; - u16 syn:1; - u16 fin:1; - }; - struct - { - u16 __doff:4; - u16 timescale:4; - u16 __cwr:1; - u16 id:1 u16 man:1; - u16 __ack:1; - u16 sig:1; - u16 __rst:1; - u16 __syn:1; - u16 __fin:1; - }; -#endif - }; - union - { - u16 window; - u16 ldr; - }; - u16 csum; - union - { - u16 urg_ptr; - u16 lifetime; - }; -} _tcp_header_t; - -#define TCP_HDRLEN sizeof(_tcp_header_t) -static_assert (EXPECTED_TCP_HDRLEN == TCP_HDRLEN, - "Size of TCP struct does not match its expected size."); - -#ifndef HICN_VPP_PLUGIN - -/* TCP flags bit 0 first. */ -#define foreach_tcp_flag \ - _ (FIN) /**< No more data from sender. */ \ - _ (SYN) /**< Synchronize sequence numbers. */ \ - _ (RST) /**< Reset the connection. */ \ - _ (PSH) /**< Push function. */ \ - _ (ACK) /**< Ack field significant. */ \ - _ (URG) /**< Urgent pointer field significant. */ \ - _ (ECE) /**< ECN-echo. Receiver got CE packet */ \ - _ (CWR) /**< Sender reduced congestion window */ - -enum -{ -#define _(f) HICN_TCP_FLAG_BIT_##f, - foreach_tcp_flag -#undef _ - HICN_TCP_N_FLAG_BITS, -}; - -enum -{ -#define _(f) HICN_TCP_FLAG_##f = 1 << HICN_TCP_FLAG_BIT_##f, - foreach_tcp_flag -#undef _ -}; - -#endif /* HICN_VPP_PLUGIN */ - -// get_data_name_suffix -// name->ip4.suffix = h->v4.tcp.seq; - - -#endif /* HICN_PROTOCOL_TCP_H */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/lib/src/protocol/udp.h b/lib/src/protocol/udp.h deleted file mode 100644 index 75d1ea98c..000000000 --- a/lib/src/protocol/udp.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef HICN_PROTOCOL_UDP_H -#define HICN_PROTOCOL_UDP_H - -/* - * The length of the UDP header struct must be 8 bytes. - */ -#define EXPECTED_UDP_HDRLEN 8 - -typedef struct -{ - u16 src_port; - u16 dst_port; - u16 length; - u16 checksum; -} _udp_header_t; - -#define UDP_HDRLEN sizeof(_udp_header_t) -static_assert (EXPECTED_UDP_HDRLEN == UDP_HDRLEN, - "Size of UDP struct does not match its expected size."); - -#endif /* HICN_PROTOCOL_UDP_H */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ |