Test interface dropping incoming/outgoing packets

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2020-02-28 16:49:09 +01:00 committed by eboasson
parent 9c272c98b8
commit 0845337f47
5 changed files with 96 additions and 102 deletions

View file

@ -3370,6 +3370,40 @@ DDS_EXPORT dds_return_t
dds_assert_liveliness (
dds_entity_t entity);
/**
* @brief This operation allows making the domain's network stack
* temporarily deaf and/or mute. It is a support function for testing and,
* other special uses and is subject to change.
*
* @param[in] entity A domain entity or an entity bound to a domain, such
* as a participant, reader or writer.
* @param[in] deaf Whether to network stack should pretend to be deaf and
* ignore any incoming packets.
* @param[in] mute Whether to network stack should pretend to be mute and
* discard any outgoing packets where it normally would.
* pass them to the operating system kernel for transmission.
* @param[in] reset_after Any value less than INFINITY will cause it to
* set deaf = mute = false after reset_after ns have passed.
* This is done by an event scheduled for the appropriate
* time and otherwise forgotten. These events are not
* affected by subsequent calls to this function.
*
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* The operation was successful.
* @retval DDS_BAD_PARAMETER
* The entity parameter is not a valid parameter.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
*/
DDS_EXPORT dds_return_t
dds_domain_set_deafmute (
dds_entity_t entity,
bool deaf,
bool mute,
dds_duration_t reset_after);
#if defined (__cplusplus)
}
#endif

View file

@ -286,6 +286,23 @@ static dds_return_t dds_domain_free (dds_entity *vdomain)
return DDS_RETCODE_NO_DATA;
}
dds_return_t dds_domain_set_deafmute (dds_entity_t entity, bool deaf, bool mute, dds_duration_t reset_after)
{
struct dds_entity *e;
dds_return_t rc;
if ((rc = dds_entity_pin (entity, &e)) < 0)
return rc;
if (e->m_domain == NULL)
rc = DDS_RETCODE_ILLEGAL_OPERATION;
else
{
ddsi_set_deafmute (&e->m_domain->gv, deaf, mute, reset_after);
rc = DDS_RETCODE_OK;
}
dds_entity_unpin (e);
return rc;
}
#include "dds__entity.h"
static void pushdown_set_batch (struct dds_entity *e, bool enable)
{