diff --git a/src/core/ddsc/src/dds_serdata_builtintopic.c b/src/core/ddsc/src/dds_serdata_builtintopic.c index b3cf343f0b..04967970d5 100644 --- a/src/core/ddsc/src/dds_serdata_builtintopic.c +++ b/src/core/ddsc/src/dds_serdata_builtintopic.c @@ -442,7 +442,8 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_builtintopic = { .to_untyped = serdata_builtin_to_untyped, .untyped_to_sample = serdata_builtin_untyped_to_sample, .print = serdata_builtin_type_print, - .get_keyhash = 0 + .get_keyhash = 0, + .get_sequencenumber = 0 }; #ifdef DDS_HAS_TOPIC_DISCOVERY @@ -497,7 +498,8 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_builtintopic_topic = { .to_untyped = serdata_builtin_to_untyped, .untyped_to_sample = serdata_builtin_untyped_to_sample, .print = serdata_builtin_type_print, - .get_keyhash = 0 + .get_keyhash = 0, + .get_sequencenumber = 0 }; #endif /* DDS_HAS_TOPIC_DISCOVERY */ diff --git a/src/core/ddsc/src/dds_serdata_default.c b/src/core/ddsc/src/dds_serdata_default.c index 911a0d9de8..4f6cec23d2 100644 --- a/src/core/ddsc/src/dds_serdata_default.c +++ b/src/core/ddsc/src/dds_serdata_default.c @@ -124,6 +124,12 @@ static uint32_t serdata_default_get_size(const struct ddsi_serdata *dcmn) return d->pos + (uint32_t)sizeof (struct dds_cdr_header); } +static uint64_t serdata_default_get_sequencenumber(const struct ddsi_serdata *dcmn) +{ + const struct dds_serdata_default *d = (const struct dds_serdata_default *) dcmn; + return d->c.sequence_number; +} + static bool serdata_default_eqkey(const struct ddsi_serdata *acmn, const struct ddsi_serdata *bcmn) { const struct dds_serdata_default *a = (const struct dds_serdata_default *)acmn; @@ -842,7 +848,8 @@ const struct ddsi_serdata_ops dds_serdata_ops_cdr = { .to_untyped = serdata_default_to_untyped, .untyped_to_sample = serdata_default_untyped_to_sample_cdr, .print = serdata_default_print_cdr, - .get_keyhash = serdata_default_get_keyhash + .get_keyhash = serdata_default_get_keyhash, + .get_sequencenumber = serdata_default_get_sequencenumber #ifdef DDS_HAS_SHM , .get_sample_size = ddsi_serdata_iox_size , .from_iox_buffer = serdata_default_from_iox @@ -864,7 +871,8 @@ const struct ddsi_serdata_ops dds_serdata_ops_xcdr2 = { .to_untyped = serdata_default_to_untyped, .untyped_to_sample = serdata_default_untyped_to_sample_cdr, .print = serdata_default_print_cdr, - .get_keyhash = serdata_default_get_keyhash + .get_keyhash = serdata_default_get_keyhash, + .get_sequencenumber = serdata_default_get_sequencenumber #ifdef DDS_HAS_SHM , .get_sample_size = ddsi_serdata_iox_size , .from_iox_buffer = serdata_default_from_iox @@ -886,7 +894,8 @@ const struct ddsi_serdata_ops dds_serdata_ops_cdr_nokey = { .to_untyped = serdata_default_to_untyped, .untyped_to_sample = serdata_default_untyped_to_sample_cdr_nokey, .print = serdata_default_print_cdr, - .get_keyhash = serdata_default_get_keyhash + .get_keyhash = serdata_default_get_keyhash, + .get_sequencenumber = serdata_default_get_sequencenumber #ifdef DDS_HAS_SHM , .get_sample_size = ddsi_serdata_iox_size , .from_iox_buffer = serdata_default_from_iox @@ -908,7 +917,8 @@ const struct ddsi_serdata_ops dds_serdata_ops_xcdr2_nokey = { .to_untyped = serdata_default_to_untyped, .untyped_to_sample = serdata_default_untyped_to_sample_cdr_nokey, .print = serdata_default_print_cdr, - .get_keyhash = serdata_default_get_keyhash + .get_keyhash = serdata_default_get_keyhash, + .get_sequencenumber = serdata_default_get_sequencenumber #ifdef DDS_HAS_SHM , .get_sample_size = ddsi_serdata_iox_size , .from_iox_buffer = serdata_default_from_iox diff --git a/src/core/ddsc/tests/cdr.c b/src/core/ddsc/tests/cdr.c index 7d952712b9..30c55142b2 100644 --- a/src/core/ddsc/tests/cdr.c +++ b/src/core/ddsc/tests/cdr.c @@ -463,7 +463,8 @@ static const struct ddsi_serdata_ops sd_ops = { .to_untyped = sd_to_untyped, .untyped_to_sample = sd_untyped_to_sample, .print = sd_print, - .get_keyhash = sd_get_keyhash + .get_keyhash = sd_get_keyhash, + .get_sequencenumber = 0 }; /*---------------------------------------------------------------- diff --git a/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h b/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h index 0d76ced0cf..e3133d39f6 100644 --- a/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h +++ b/src/core/ddsi/include/dds/ddsi/ddsi_serdata.h @@ -149,6 +149,9 @@ typedef size_t (*ddsi_serdata_print_t) (const struct ddsi_sertype *type, const s - buf needs to be at least 16 bytes large */ typedef void (*ddsi_serdata_get_keyhash_t) (const struct ddsi_serdata *d, struct ddsi_keyhash *buf, bool force_md5); +/* Sequence number of the sample as advertised by the publisher */ +typedef uint64_t (*ddsi_serdata_get_sequencenumber_t) (const struct ddsi_serdata *d); + #ifdef DDS_HAS_SHM typedef uint32_t(*ddsi_serdata_iox_size_t) (const struct ddsi_serdata* d); @@ -176,6 +179,7 @@ struct ddsi_serdata_ops { ddsi_serdata_free_t free; ddsi_serdata_print_t print; ddsi_serdata_get_keyhash_t get_keyhash; + ddsi_serdata_get_sequencenumber_t get_sequencenumber; #ifdef DDS_HAS_SHM ddsi_serdata_iox_size_t get_sample_size; ddsi_serdata_from_iox_t from_iox_buffer; @@ -242,6 +246,10 @@ DDS_INLINE_EXPORT inline uint32_t ddsi_serdata_size (const struct ddsi_serdata * } /** @component typesupport_if */ +DDS_INLINE_EXPORT inline uint64_t ddsi_serdata_sequencenumber(const struct ddsi_serdata *d) { + return d->ops->get_sequencenumber (d); +} + DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_from_ser (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const struct ddsi_rdata *fragchain, size_t size) { return type->serdata_ops->from_ser (type, kind, fragchain, size); } diff --git a/src/core/ddsi/src/ddsi_serdata_cdr.c b/src/core/ddsi/src/ddsi_serdata_cdr.c index 93cfde6a55..518e60337f 100644 --- a/src/core/ddsi/src/ddsi_serdata_cdr.c +++ b/src/core/ddsi/src/ddsi_serdata_cdr.c @@ -355,8 +355,9 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_cdr = { .untyped_to_sample = serdata_cdr_untyped_to_sample_cdr, .print = serdata_cdr_print_cdr, .get_keyhash = 0, + .get_sequencenumber = 0 #ifdef DDS_HAS_SHM - .get_sample_size = 0, - .from_iox_buffer = 0 + , .get_sample_size = 0 + , .from_iox_buffer = 0 #endif }; diff --git a/src/core/ddsi/src/ddsi_serdata_plist.c b/src/core/ddsi/src/ddsi_serdata_plist.c index f59b71c2e6..e50c24623b 100644 --- a/src/core/ddsi/src/ddsi_serdata_plist.c +++ b/src/core/ddsi/src/ddsi_serdata_plist.c @@ -325,5 +325,6 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_plist = { .to_untyped = serdata_plist_to_untyped, .untyped_to_sample = serdata_plist_untyped_to_sample, .print = serdata_plist_print_plist, - .get_keyhash = serdata_plist_get_keyhash + .get_keyhash = serdata_plist_get_keyhash, + .get_sequencenumber = 0 }; diff --git a/src/core/ddsi/src/ddsi_serdata_pserop.c b/src/core/ddsi/src/ddsi_serdata_pserop.c index d21786c154..ad4bb3ec21 100644 --- a/src/core/ddsi/src/ddsi_serdata_pserop.c +++ b/src/core/ddsi/src/ddsi_serdata_pserop.c @@ -304,5 +304,6 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_pserop = { .to_untyped = serdata_pserop_to_untyped, .untyped_to_sample = serdata_pserop_untyped_to_sample, .print = serdata_pserop_print_pserop, - .get_keyhash = serdata_pserop_get_keyhash + .get_keyhash = serdata_pserop_get_keyhash, + .get_sequencenumber = 0 };