/* * (c) Copyright, Real-Time Innovations, 2002-2024. * All rights reserved. * * No duplications, whole or partial, manual or electronic, may be made * without express written permission. Any such copies, or * revisions thereof, must display this notice unaltered. * This code contains trade secrets of Real-Time Innovations, Inc. */ #ifndef routingservice_remote_config_h #define routingservice_remote_config_h #include "routingservice/routingservice_dll.h" #include "dds_c/dds_c_infrastructure.h" #include "dds_c/dds_c_subscription.h" #include "connext_c/connext_c_requester.h" #include "connext_c/connext_c_replier.h" #include "apputils/apputils_resource_identifier_impl.h" #ifdef __cplusplus extern "C" { #endif #include "routingservice/ServiceAdmin.h" #include "routingservice/ServiceAdminPlugin.h" #include "routingservice/ServiceAdminSupport.h" #undef NDDSUSERDllExport #define NDDSUSERDllExport ROUTERDllExport RTI_CONNEXT_REQUESTER_DECL( RTI_Service_Admin_CommandRequest, RTI_Service_Admin_CommandReply, RTI_RoutingServiceAdminRequester); RTI_CONNEXT_REPLIER_DECL( RTI_Service_Admin_CommandRequest, RTI_Service_Admin_CommandReply, RTI_RoutingServiceAdminReplier); #undef NDDSUSERDllExport #define NDDSUSERDllExport /* * --- RoutingServiceDataPlugin ----------------------------------------------- */ typedef DDS_Boolean (*RTI_RoutingServiceDataPlugin_SerializeToCdrBufferFcn)( void *buffer, unsigned int *bufferLength, void *sample); typedef DDS_Boolean (*RTI_RoutingServiceDataPlugin_DeserializeFromCdrBufferFcn)( void *sample, void *buffer, unsigned int bufferLength); struct RTI_RoutingServiceDataPlugin { /* @brief Place holder for implementations */ void * plugin_data; /* @brief Handles the serialization of sample into a buffer */ RTI_RoutingServiceDataPlugin_SerializeToCdrBufferFcn serialize_to_buffer; /* @brief Handles the deserialization of sample from a buffer */ RTI_RoutingServiceDataPlugin_DeserializeFromCdrBufferFcn deserialize_from_buffer; }; #define RTI_RoutingServiceDataPlugin_INITIALIZER {\ NULL,\ NULL, \ NULL} /*i \ingroup RTI_RoutingServiceLibModule * * @brief Definition of the supported URI schemes * * The scheme-specific part of the content of a command depends on the scheme: * - file: indicates that the content is a path to a file * - string: indicates that the content is a string * - service: indicates that the content is a service-specific resource. */ typedef enum { RTI_SERVICE_ADMIN_SCHEME_FILE, RTI_SERVICE_ADMIN_SCHEME_STRING, RTI_SERVICE_ADMIN_SCHEME_SERVICE, RTI_SERVICE_ADMIN_SCHEME_OTHER } RTI_RoutingServiceAdminSchemeKind; extern ROUTERCoreDllVariable const char * RTI_SERVICE_ADMIN_SCHEME_FILE_NAME; extern ROUTERCoreDllVariable const char * RTI_SERVICE_ADMIN_SCHEME_STRING_NAME; extern ROUTERCoreDllVariable const char * RTI_SERVICE_ADMIN_SCHEME_SERVICE_NAME; #define RTI_SERVICE_COMMAND_ACTION_CREATE RTI_Service_Admin_CommandActionKind_CREATE_ACTION #define RTI_SERVICE_COMMAND_ACTION_GET RTI_Service_Admin_CommandActionKind_GET_ACTION #define RTI_SERVICE_COMMAND_ACTION_UPDATE RTI_Service_Admin_CommandActionKind_UPDATE_ACTION #define RTI_SERVICE_COMMAND_ACTION_DELETE RTI_Service_Admin_CommandActionKind_DELETE_ACTION #define RTI_SERVICE_COMMAND_REPLY_OK RTI_Service_Admin_CommandReplyRetcode_OK_RETCODE #define RTI_SERVICE_COMMAND_REPLY_ERROR RTI_Service_Admin_CommandReplyRetcode_ERROR_RETCODE #define RTI_Service_Admin_CommandRequest_INITIALIZER { \ 0, \ NULL, \ (RTI_Service_Admin_CommandActionKind) 0, \ NULL, \ NULL, \ DDS_SEQUENCE_INITIALIZER} #define RTI_Service_Admin_CommandReply_INITIALIZER { \ RTI_SERVICE_COMMAND_REPLY_ERROR, \ 0, \ NULL, \ DDS_SEQUENCE_INITIALIZER} /* * --- RemoteConfigInterceptor ------------------------------------------------ */ /*i \ingroup RTI_RoutingServiceLibModule * * Prototype of the function that is called by the RS when an incoming command * request is received. * * It's responsibility of the interceptor to use the replier to send a reply * for the incoming request. * * @param interceptor_data \b In. Interceptor implementation data. * @param output_command_response \b Inout. Result of the execution action that * will be sent as response to the client * that issued the incoming command request. * @param incoming_command_request \b In. Incoming command request. * @param replier \b Inout. Context of the interceptor. * Allows the interceptor to send custom replies. * */ typedef void (*RTI_RoutingServiceConfigInterceptor_OnCommandRequestCallback)( void * interceptor_data, const struct RTI_Service_Admin_CommandRequest* incoming_request, const struct DDS_SampleInfo * request_info, struct RTI_RoutingServiceAdminReplier * replier); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Interface for executing remote commands. * * Listener for executing/processing a remote command. It allows an external RS * client service to define its own sets of commands than can be mapped into * either RS commands or other service-specific actions. */ struct RTI_RoutingServiceConfigInterceptor { /* @brief A place holder for implementors */ void * interceptor_data; /* @brief Handles the reception of a command request */ RTI_RoutingServiceConfigInterceptor_OnCommandRequestCallback on_command_request; }; #define RTI_RoutingServiceConfigInterceptor_INITIALIZER {NULL, NULL} /* * --- RTI_RoutingServiceAdminReplier ----------------------------------------- */ /*i \ingroup RTI_RoutingServiceLibModule * * @brief Checks whether this replier has at least one matching requester that * can communicate with. * * @return True if there is at least one matching requester */ extern ROUTERDllExport DDS_Boolean RTI_RoutingServiceAdminReplier_has_matching_requester( struct RTI_RoutingServiceAdminReplier * self); /* * --- RTI_RoutingServiceAdminRequester --------------------------------------- */ /*i \ingroup RTI_RoutingServiceLibModule * * @brief Checks whether this requester has at least one matching replier that * can communicate with. * * @return True if there is at least one matching replier */ extern ROUTERDllExport DDS_Boolean RTI_RoutingServiceAdminRequester_has_matching_replier( struct RTI_RoutingServiceAdminRequester * self); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Checks whether this requester has expected number of repliers it * can communicate with. * * @return True if there are atleast replier_count matching repliers */ extern ROUTERDllExport DDS_Boolean RTI_RoutingServiceAdminRequester_has_matching_repliers( struct RTI_RoutingServiceAdminRequester * self, int replier_count); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Creates a new RTI Routing Service remote configuration client instance. * * @param domain_id \b In. Domain Id the client operates * @param response_timeout_sec \b In. The maximum time the client blocks waiting * for a response after a request. In seconds. */ extern ROUTERDllExport struct RTI_RoutingServiceAdminRequester * RTI_RoutingServiceAdminSupport_create_requester( int domain_id, int response_timeout_sec); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Deletes a RTI Routing Service remote configuration client instance. * */ extern ROUTERDllExport void RTI_RoutingServiceAdminSupport_delete_requester( struct RTI_RoutingServiceAdminRequester * self); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Serializes the specified sample into the request's octet sequence * body. * * @param data_plugin The data plugin to use for serialization. * @param sample Sample to be serialized. * * @return True on success. */ extern ROUTERDllExport DDS_Boolean RTI_RoutingServiceAdminSupport_serialize_sample_into_request_octet_body( struct RTI_Service_Admin_CommandRequest * self, struct RTI_RoutingServiceDataPlugin * data_plugin, void * sample); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Serializes the specified sample into the reply's octet sequence * body. * * @param data_plugin The data plugin to use for serialization. * @param sample Sample to be serialized. * * @return True on success. */ extern ROUTERDllExport DDS_Boolean RTI_RoutingServiceAdminSupport_serialize_sample_into_reply_octet_body( struct RTI_Service_Admin_CommandReply * self, struct RTI_RoutingServiceDataPlugin * data_plugin, void * sample); /** * i \ingroup RTI_RoutingServiceLibModule * * @brief * Serializes the specified entityStateKind into the reply's octet_body * sequence in the CDR format. * * @param reply * The sample whose octet_body will be used to serialize into. * * @param entityStateKind * Value of the enum RTI_Service_EntityStateKind to serialize. * * @return * True on success. False otherwise. */ extern ROUTERDllExport DDS_Boolean RTI_RoutingServiceAdminSupport_set_state_in_reply( RTI_Service_Admin_CommandReply *reply, RTI_Service_EntityStateKind entityStateKind); /** * i \ingroup RTI_RoutingServiceLibModule * * @brief * Returns the entityStateKind value from the reply's octet_body sequence * by deserializing it from the CDR format. This method also looks at the * string_body of the reply if the octet_body is found to be empty. The string * values are compared against the string translations of the enum values. * * @param reply * The sample whose octet_body contains the entityStateKind value to deserialize. * * @return * RTI_Service_EntityStateKind deserialized value. * RTI_Service_EntityStateKind_INVALID otherwise. */ extern ROUTERDllExport RTI_Service_EntityStateKind RTI_RoutingServiceAdminSupport_get_state_from_reply( const RTI_Service_Admin_CommandReply *reply); /** * i \ingroup RTI_RoutingServiceLibModule * * @brief * Serializes the specified entityStateKind into the request's octet_body * sequence in the CDR format. * * @param request * The sample whose octet_body will be used to serialize into. * * @param entityStateKind * Value of the enum RTI_Service_EntityStateKind to serialize. * * @return * True on success. False otherwise. */ extern ROUTERDllExport DDS_Boolean RTI_RoutingServiceAdminSupport_set_state_in_request( RTI_Service_Admin_CommandRequest *request, RTI_Service_EntityStateKind entityStateKind); /** * i \ingroup RTI_RoutingServiceLibModule * * @brief * Returns the entityStateKind value from the request's octet_body sequence * by deserializing it from the CDR format. This method also looks at the * string_body of the request if the octet_body is found to be empty. The string * values are compared against the string translations of the enum values. * * @param request * The sample whose octet_body contains the entityStateKind value to deserialize. * * @return * RTI_Service_EntityStateKind deserialized value. * RTI_Service_EntityStateKind_INVALID otherwise. */ extern ROUTERDllExport RTI_Service_EntityStateKind RTI_RoutingServiceAdminSupport_get_state_from_request( const RTI_Service_Admin_CommandRequest *request); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Obtains the scheme from the given URI * */ extern ROUTERDllExport RTI_RoutingServiceAdminSchemeKind RTI_RoutingServiceAdminSupport_get_scheme_kind(const char * string_body); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Returns the content of the URI depending of the scheme. * The value returned is a pointer to the position within the URI where the * content starts. * * @return the content of the URI or NULL on error. */ extern ROUTERDllExport const char * RTI_RoutingServiceAdminSupport_get_body_content( const char * string_body); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Gets the actual XML code from a body of the form str://"...xml..." * */ extern ROUTERDllExport char * RTI_RoutingServiceAdminSupport_get_xml_from_string_body_content( char * string_body_content); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Sets the string body in the reply. * * The specified reply shall already have a string body with an specified length. * Allocation may occur if the new required length is bigger than the current * length or than the dynamic length. In this case, a heap-allocated buffer will * be set in the reply's string body. * * @return True on success * */ extern ROUTERDllExport DDS_Boolean RTI_RoutingServiceAdminSupport_set_string_body_buffer( struct RTI_Service_Admin_CommandReply * reply, int string_body_buffer_length, char ** dynamic_buffer, int * dynamic_buffer_length, int string_body_required_length); /*i \ingroup RTI_RoutingServiceLibModule * * @brief Sets the octet body's contiguous buffer in the reply. * * The specified reply shall already have octet body with a loaned contiguous * buffer. Allocation of a new contiguous buffer may occur if the new required * length is bigger than the current length. In this case, a heap-allocated * contiguous buffer will be set in the reply's octet body and the old one will * be returned as an output parameter. * * @return True on success * */ extern ROUTERDllExport DDS_Boolean RTI_RoutingServiceAdminSupport_set_octet_body_contiguous_buffer( struct RTI_Service_Admin_CommandReply * reply, DDS_Octet ** dynamic_contiguous_buffer, int * dynamic_contiguous_buffer_length, int required_octet_body_length); typedef enum { RTI_SERVICE_ENTITY_WELL_KNOWN_RESOURCE = 0, RTI_SERVICE_CONFIG_WELL_KNOWN_RESOURCE, RTI_SERVICE_STATE_WELL_KNOWN_RESOURCE, RTI_SERVICE_MESSAGE_WELL_KNOWN_RESOURCE, RTI_SERVICE_UNKNOWN_WELL_KNOWN_RESOURCE, RTI_ServiceWellKnownResourceKind_COUNT = RTI_SERVICE_UNKNOWN_WELL_KNOWN_RESOURCE, } RTI_ServiceWellKnownResourceKind; extern ROUTERDllVariable const char *RTI_SERVICE_WELL_KNOWN_RESOURCE_KIND_NAMES[RTI_ServiceWellKnownResourceKind_COUNT]; #ifdef __cplusplus } /* extern "C" */ #endif #endif /* routingservice_remote_config_h */