Update for changes on Cyclone DDS security branch

The security specification has a mode in which keyhashes containing the
MD5 of the key value are required on the wire, and this requires some
small changes to the topic interface.  Currently, these changes reside
only on the security branch of Cyclone DDS.

The changes use conditional compilation to handle both the master branch
of Cyclone and the security branch to minimise version dependencies.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2020-03-03 14:26:29 +01:00 committed by eboasson
parent b4c0620b5b
commit a6deecfceb

View file

@ -31,6 +31,18 @@
#include "rmw_cyclonedds_cpp/ServiceTypeSupport.hpp" #include "rmw_cyclonedds_cpp/ServiceTypeSupport.hpp"
#include "rmw_cyclonedds_cpp/serdes.hpp" #include "rmw_cyclonedds_cpp/serdes.hpp"
/* Cyclone's nn_keyhash got renamed to ddsi_keyhash and shuffled around in the header
files to avoid pulling in tons of things just for a definition of a keyhash. This
coincides with the introduction of DDS Security, which itself adds another function
that was missing.
If that additional function is not needed, it is known as nn_keyhash and only a forward
declaration is available; else it is known as ddsi_keyhash and a definition is
available */
#if !DDSI_SERDATA_HAS_GET_KEYHASH
#define ddsi_keyhash nn_keyhash
#endif
using MessageTypeSupport_c = using MessageTypeSupport_c =
rmw_cyclonedds_cpp::MessageTypeSupport<rosidl_typesupport_introspection_c__MessageMembers>; rmw_cyclonedds_cpp::MessageTypeSupport<rosidl_typesupport_introspection_c__MessageMembers>;
using MessageTypeSupport_cpp = using MessageTypeSupport_cpp =
@ -173,7 +185,7 @@ static struct ddsi_serdata * serdata_rmw_from_ser_iov(
static struct ddsi_serdata * serdata_rmw_from_keyhash( static struct ddsi_serdata * serdata_rmw_from_keyhash(
const struct ddsi_sertopic * topic, const struct ddsi_sertopic * topic,
const struct nn_keyhash * keyhash) const struct ddsi_keyhash * keyhash)
{ {
static_cast<void>(keyhash); // unused static_cast<void>(keyhash); // unused
/* there is no key field, so from_keyhash is trivial */ /* there is no key field, so from_keyhash is trivial */
@ -377,6 +389,19 @@ static size_t serdata_rmw_print(
} }
#endif #endif
#if DDSI_SERDATA_HAS_GET_KEYHASH
static void serdata_rmw_get_keyhash(
const struct ddsi_serdata * d, struct ddsi_keyhash * buf,
bool force_md5)
{
/* ROS2 doesn't do keys in a meaningful way yet, this is never called for topics without
key fields */
static_cast<void>(d);
static_cast<void>(force_md5);
memset(buf, 0, sizeof(*buf));
}
#endif
static const struct ddsi_serdata_ops serdata_rmw_ops = { static const struct ddsi_serdata_ops serdata_rmw_ops = {
serdata_rmw_eqkey, serdata_rmw_eqkey,
serdata_rmw_size, serdata_rmw_size,
@ -396,6 +421,9 @@ static const struct ddsi_serdata_ops serdata_rmw_ops = {
#if DDSI_SERDATA_HAS_PRINT #if DDSI_SERDATA_HAS_PRINT
, serdata_rmw_print , serdata_rmw_print
#endif #endif
#if DDSI_SERDATA_HAS_GET_KEYHASH
, serdata_rmw_get_keyhash
#endif
}; };
static void sertopic_rmw_free(struct ddsi_sertopic * tpcmn) static void sertopic_rmw_free(struct ddsi_sertopic * tpcmn)