diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/src/compat.c | 7 | ||||
-rw-r--r-- | lib/src/compat.h | 2 | ||||
-rw-r--r-- | lib/src/ops.c | 1 | ||||
-rw-r--r-- | lib/src/ops.h | 16 | ||||
-rw-r--r-- | lib/src/protocol/ah.c | 8 | ||||
-rw-r--r-- | lib/src/protocol/icmp.c | 4 | ||||
-rw-r--r-- | lib/src/protocol/ipv4.c | 7 | ||||
-rw-r--r-- | lib/src/protocol/ipv6.c | 7 | ||||
-rw-r--r-- | lib/src/protocol/tcp.c | 7 |
9 files changed, 55 insertions, 4 deletions
diff --git a/lib/src/compat.c b/lib/src/compat.c index 07f92105e..56504fe5e 100644 --- a/lib/src/compat.c +++ b/lib/src/compat.c @@ -1142,6 +1142,13 @@ hicn_data_reset_for_hash (hicn_format_t format, hicn_header_t * packet) } +int hicn_packet_get_signature(hicn_format_t format, hicn_header_t * packet, uint8_t ** sign_buf) +{ + hicn_type_t type = hicn_format_to_type (format); + return hicn_ops_vft[type.l1]->get_signature (type, + &packet->protocol, sign_buf); +} + /* * fd.io coding-style-patch-verification: ON * diff --git a/lib/src/compat.h b/lib/src/compat.h index 1a1743de2..52dd41f1e 100644 --- a/lib/src/compat.h +++ b/lib/src/compat.h @@ -387,9 +387,9 @@ int hicn_packet_set_src_port (hicn_header_t * packet, u16 src_port); int hicn_packet_get_src_port (const hicn_header_t * packet, u16 * src_port); int hicn_packet_set_dst_port (hicn_header_t * packet, u16 dst_port); int hicn_packet_get_dst_port (const hicn_header_t * packet, u16 * dst_port); +int hicn_packet_get_signature(hicn_format_t format, hicn_header_t * packet, uint8_t ** sign_buf); /* Interest */ - int hicn_interest_get_name (hicn_format_t format, const hicn_header_t * interest, hicn_name_t * name); diff --git a/lib/src/ops.c b/lib/src/ops.c index 4ccf131b5..3e272572a 100644 --- a/lib/src/ops.c +++ b/lib/src/ops.c @@ -70,6 +70,7 @@ DECLARE_set_validation_algorithm (none, NONE); DECLARE_get_validation_algorithm (none, NONE); DECLARE_set_key_id (none, NONE); DECLARE_get_key_id (none, NONE); +DECLARE_get_signature (none, NONE); DECLARE_HICN_OPS (none); /** diff --git a/lib/src/ops.h b/lib/src/ops.h index b698a53fd..47795efd5 100644 --- a/lib/src/ops.h +++ b/lib/src/ops.h @@ -418,7 +418,15 @@ typedef struct hicn_ops_s int (*set_key_id) (hicn_type_t type, hicn_protocol_t * h, uint8_t *key_id); - + /** + * @brief Get a pointer to the signature field in the packet + * @param [in] type - hICN packet type + * @param [in,out] h - Buffer holding the Interest or Data packet + * @param [out] signature - Pointer to the memory region holding the signature + * @return hICN error code + */ + int (*get_signature) (hicn_type_t type, hicn_protocol_t * h, + uint8_t ** signature); } hicn_ops_t; #define DECLARE_HICN_OPS(protocol) \ @@ -459,7 +467,8 @@ typedef struct hicn_ops_s ATTR_INIT(get_validation_algorithm, protocol ## _get_validation_algorithm), \ ATTR_INIT(set_validation_algorithm, protocol ## _set_validation_algorithm), \ ATTR_INIT(get_key_id, protocol ## _get_key_id), \ - ATTR_INIT(set_key_id, protocol ## _set_key_id), \ + ATTR_INIT(set_key_id, protocol ## _set_key_id), \ + ATTR_INIT(get_signature, protocol ## _get_signature), \ } /** @@ -618,6 +627,9 @@ PAYLOAD (hicn_type_t type, const hicn_protocol_t * h) #define DECLARE_get_key_id(protocol, error) \ int protocol ## _get_key_id(hicn_type_t type, hicn_protocol_t * h, uint8_t ** key_id, uint8_t *key_id_size) { return HICN_LIB_ERROR_ ## error ; } +#define DECLARE_get_signature(protocol, error) \ + int protocol ## _get_signature(hicn_type_t type, hicn_protocol_t * h, uint8_t ** signature) { return HICN_LIB_ERROR_ ## error ; } + #endif /* HICN_OPS_H */ /* diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c index 3711a3f95..c1395dee8 100644 --- a/lib/src/protocol/ah.c +++ b/lib/src/protocol/ah.c @@ -144,6 +144,14 @@ ah_get_header_length (hicn_type_t type, const hicn_protocol_t * h, } int +ah_get_signature (hicn_type_t type, hicn_protocol_t * h, + uint8_t ** signature) +{ + *signature = h->ah.validationPayload; + return HICN_LIB_ERROR_NONE; +} + +int ah_get_signature_size (hicn_type_t type, const hicn_protocol_t * h, size_t * signature_size) { diff --git a/lib/src/protocol/icmp.c b/lib/src/protocol/icmp.c index 44b646fb2..45a28959c 100644 --- a/lib/src/protocol/icmp.c +++ b/lib/src/protocol/icmp.c @@ -39,7 +39,9 @@ DECLARE_set_lifetime (icmp, UNEXPECTED) DECLARE_get_length (icmp, UNEXPECTED) DECLARE_get_payload_length (icmp, UNEXPECTED) DECLARE_set_payload_length (icmp, UNEXPECTED) - int icmp_init_packet_header (hicn_type_t type, hicn_protocol_t * h) +DECLARE_get_signature (icmp, UNEXPECTED) + +int icmp_init_packet_header (hicn_type_t type, hicn_protocol_t * h) { h->icmp = (_icmp_header_t) { diff --git a/lib/src/protocol/ipv4.c b/lib/src/protocol/ipv4.c index c0b2aaa8c..4e4c47f5b 100644 --- a/lib/src/protocol/ipv4.c +++ b/lib/src/protocol/ipv4.c @@ -443,6 +443,13 @@ ipv4_get_key_id (hicn_type_t type, hicn_protocol_t * h, return CHILD_OPS (get_key_id, type, h, key_id, key_id_size); } +int +ipv4_get_signature (hicn_type_t type, hicn_protocol_t * h, + uint8_t ** signature) +{ + return CHILD_OPS (get_signature, type, h, signature); +} + DECLARE_HICN_OPS (ipv4); /* diff --git a/lib/src/protocol/ipv6.c b/lib/src/protocol/ipv6.c index 41b00ec92..1cdcc75c0 100644 --- a/lib/src/protocol/ipv6.c +++ b/lib/src/protocol/ipv6.c @@ -401,6 +401,13 @@ ipv6_get_key_id (hicn_type_t type, hicn_protocol_t * h, return CHILD_OPS (get_key_id, type, h, key_id, key_id_size); } +int +ipv6_get_signature (hicn_type_t type, hicn_protocol_t * h, + uint8_t ** signature) +{ + return CHILD_OPS (get_signature, type, h, signature); +} + DECLARE_HICN_OPS (ipv6); /* diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c index 2afc4f6f4..08a1c73ef 100644 --- a/lib/src/protocol/tcp.c +++ b/lib/src/protocol/tcp.c @@ -359,6 +359,13 @@ tcp_get_key_id (hicn_type_t type, hicn_protocol_t * h, return CHILD_OPS (get_key_id, type, h, key_id, key_id_size); } +int +tcp_get_signature (hicn_type_t type, hicn_protocol_t * h, + uint8_t ** signature) +{ + return CHILD_OPS (get_signature, type, h, signature); +} + DECLARE_HICN_OPS (tcp); /* |