aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-02-05 22:32:48 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-02-06 08:34:26 +0100
commit216e35ba535efa00af39b7624f363ca832836e3f (patch)
tree90e4b4f49aeb91f5e2efd43dba5b77c1fd08615b /lib/src
parent7f4916ae09e89aadfc2029ffbe81231ba1ea8016 (diff)
[HICN-34] Fixed bug on struct size and implemented initialization method
Change-Id: I975fce31c2da5ad42d6787b0c5f305c60390d68c Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/protocol/ah.c14
-rw-r--r--lib/src/protocol/ah.h9
2 files changed, 14 insertions, 9 deletions
diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c
index f9ddf7775..3711a3f95 100644
--- a/lib/src/protocol/ah.c
+++ b/lib/src/protocol/ah.c
@@ -48,7 +48,15 @@ DECLARE_set_payload_length (ah, UNEXPECTED);
int
ah_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
{
- return HICN_LIB_ERROR_NOT_IMPLEMENTED;
+ /* *INDENT-OFF* */
+ h->ah = (_ah_header_t)
+ {
+ .nh = (u8)0,
+ .payloadlen = (u8)0,
+ .reserved = (u16)0,
+ };
+ /* *INDENT-ON* */
+ return CHILD_OPS (init_packet_header, type, h);
}
int
@@ -155,7 +163,7 @@ int
ah_set_signature_timestamp(hicn_type_t type, hicn_protocol_t * h,
uint64_t signature_timestamp)
{
- h->ah.timestamp_as_u64 = signature_timestamp;
+ memcpy(h->ah.timestamp_as_u8, &signature_timestamp, 8);
return HICN_LIB_ERROR_NONE;
}
@@ -163,7 +171,7 @@ int
ah_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t * h,
uint64_t * signature_timestamp)
{
- *signature_timestamp = h->ah.timestamp_as_u64;
+ memcpy(signature_timestamp, h->ah.timestamp_as_u8, 8);
return HICN_LIB_ERROR_NONE;
}
diff --git a/lib/src/protocol/ah.h b/lib/src/protocol/ah.h
index 0b4171135..f8a05bf38 100644
--- a/lib/src/protocol/ah.h
+++ b/lib/src/protocol/ah.h
@@ -33,6 +33,7 @@ typedef struct
union
{
u16 reserved;
+
struct
{
u8 validationAlgorithm; // As defined in parc_SignerAlgorithm.h
@@ -46,12 +47,8 @@ typedef struct
u32 spi;
u32 seq;
};
- union
- {
- u8 timestamp_as_u8[8];
- u64 timestamp_as_u64;
- }; // Unix timestamp indicating when the signature has been calculated
-
+ // Unix timestamp indicating when the signature has been calculated
+ u8 timestamp_as_u8[8];
};
// ICV would follow
u8 keyId[32]; // Hash of the pub key