/* packet-rtps2.c * ~~~~~~~~~~~~~~ * * Routines for Real-Time Publish-Subscribe Protocol (RTPS) dissection * * Copyright 2005, Fabrizio Bertocci * Real-Time Innovations, Inc. * 385 Moffett Park Drive * Sunnyvale, CA 94089 * * Version 2.1 bug fixes to RTPS_DATA provided by * Twin Oaks Computing, Inc. * 755 Maleta Ln, Ste 203 * Castle Rock, CO 80108 * * $Id$ * * Wireshark - Network traffic analyzer * By Gerald Combs * Copyright 1998 Gerald Combs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * ------------------------------------- * * This is the RTPS packet dissector for RTPS version 2.x * * RTPS protocol was initially developed by Real-Time Innovations, Inc. as wire * protocol for Data Distribution System, and then adopted as a standard by * the Object Management Group (as version 2.0). * * Additional information at: * The Real-time Publish-Subscribe Wire Protocol DDS Interoperability Wire Protocol (DDSI): * http://www.omg.org/spec/DDSI/ * Full OMG DDS Standard Specification: * http://www.omg.org/cgi-bin/doc?ptc/2003-07-07 * * RTI DDS and RTPS information: http://www.rti.com/resources.html * */ #include "config.h" #include #include #include #include #include #include #include "packet-rtps2.h" #include "packet-rtps.h" /* Size of the temp buffers used to format various part of the protocol. * Note: Some of those values are bigger than expected. The reason is * because the string buffer can also contains decoded values. * I.e. port size is an integer, but for value 0x0000, it is interpreted * as a string "PORT_INVALID (0x00000000)" */ #define MAX_FLAG_SIZE (40) #define MAX_GUID_PREFIX_SIZE (128) #define MAX_GUID_SIZE (160) #define MAX_VENDOR_ID_SIZE (128) #define MAX_NTP_TIME_SIZE (128) #define MAX_PORT_SIZE (32) #define MAX_PARAM_SIZE (256) #define MAX_LOCATOR_SIZE (200) #define MAX_IPV6_SIZE (100) #define MAX_BITMAP_SIZE (256) #define MAX_LABEL_SIZE (64) #define MAX_IPV4_ADDRESS_SIZE (64) /* Max octets printed on the parameter root for a sequence of octets */ #define MAX_SEQ_OCTETS_PRINTED (20) /***************************************************************************/ /* Protocol Fields Identifiers */ static int proto_rtps = -1; static int hf_rtps_domain_id = -1; static int hf_rtps_participant_idx = -1; static int hf_rtps_nature_type = -1; static int hf_rtps_guid_prefix = -1; static int hf_rtps_host_id = -1; static int hf_rtps_app_id = -1; /* static int hf_rtps_counter = -1; */ static int hf_rtps_sm_id = -1; static int hf_rtps_sm_flags = -1; static int hf_rtps_sm_octets_to_next_header = -1; static int hf_rtps_sm_guid_prefix = -1; static int hf_rtps_sm_host_id = -1; static int hf_rtps_sm_app_id = -1; /* static int hf_rtps_sm_instance_id = -1; */ /* static int hf_rtps_sm_app_kind = -1; */ static int hf_rtps_sm_counter = -1; static int hf_rtps_sm_entity_id = -1; static int hf_rtps_sm_entity_id_key = -1; static int hf_rtps_sm_entity_id_kind = -1; static int hf_rtps_sm_rdentity_id = -1; static int hf_rtps_sm_rdentity_id_key = -1; static int hf_rtps_sm_rdentity_id_kind = -1; static int hf_rtps_sm_wrentity_id = -1; static int hf_rtps_sm_wrentity_id_key = -1; static int hf_rtps_sm_wrentity_id_kind = -1; static int hf_rtps_parameter_id = -1; static int hf_rtps_parameter_length = -1; static int hf_rtps_param_topic_name = -1; static int hf_rtps_param_entity_name = -1; static int hf_rtps_param_strength = -1; static int hf_rtps_param_type_name = -1; static int hf_rtps_param_user_data = -1; static int hf_rtps_param_group_data = -1; static int hf_rtps_param_topic_data = -1; static int hf_rtps_param_content_filter_name = -1; static int hf_rtps_param_related_topic_name = -1; static int hf_rtps_param_filter_name = -1; static int hf_rtps_issue_data = -1; static int hf_rtps_param_status_info = -1; static int hf_rtps_participant_lease_duration = -1; static int hf_rtps_time_based_filter_minimum_separation = -1; static int hf_rtps_deadline_period = -1; static int hf_rtps_latency_budget_duration = -1; static int hf_rtps_lifespan_duration = -1; static int hf_rtps_persistence = -1; static int hf_rtps_data_batch_timestamp = -1; static int hf_rtps_participant_builtin_endpoints= -1; static int hf_rtps_participant_manual_liveliness_count = -1; static int hf_rtps_history_depth = -1; static int hf_rtps_resource_limit_max_samples = -1; static int hf_rtps_resource_limit_max_instances = -1; static int hf_rtps_resource_limit_max_samples_per_instances = -1; static int hf_rtps_filter_bitmap = -1; static int hf_rtps_type_checksum = -1; static int hf_rtps_queue_size = -1; static int hf_param_ip_address = -1; static int hf_rtps_param_port = -1; static int hf_rtps_expects_inline_qos = -1; static int hf_rtps_presentation_coherent_access = -1; static int hf_rtps_presentation_ordered_access = -1; static int hf_rtps_expects_ack = -1; static int hf_rtps_disable_positive_ack = -1; static int hf_rtps_reliability_kind = -1; static int hf_rtps_durability = -1; static int hf_rtps_ownership = -1; static int hf_rtps_presentation_access_scope = -1; static int hf_rtps_destination_order = -1; static int hf_rtps_history_kind = -1; /* Subtree identifiers */ static gint ett_rtps = -1; static gint ett_rtps_default_mapping = -1; static gint ett_rtps_proto_version = -1; static gint ett_rtps_submessage = -1; static gint ett_rtps_parameter_sequence = -1; static gint ett_rtps_parameter = -1; static gint ett_rtps_flags = -1; static gint ett_rtps_entity = -1; static gint ett_rtps_rdentity = -1; static gint ett_rtps_wrentity = -1; static gint ett_rtps_guid_prefix = -1; static gint ett_rtps_part_message_data = -1; static gint ett_rtps_part_message_guid = -1; static gint ett_rtps_locator_udp_v4 = -1; static gint ett_rtps_locator = -1; static gint ett_rtps_locator_list = -1; static gint ett_rtps_ntp_time = -1; static gint ett_rtps_bitmap = -1; static gint ett_rtps_seq_string = -1; static gint ett_rtps_seq_ulong = -1; static gint ett_rtps_serialized_data = -1; static gint ett_rtps_sample_info_list = -1; static gint ett_rtps_sample_info = -1; static gint ett_rtps_sample_batch_list = -1; static gint ett_rtps_locator_filter_channel = -1; static gint ett_rtps_locator_filter_locator = -1; static gint ett_rtps_resource_limit = -1; /***************************************************************************/ /* Value-to-String Tables */ static const value_string entity_id_vals[] = { { ENTITYID_UNKNOWN, "ENTITYID_UNKNOWN" }, { ENTITYID_PARTICIPANT, "ENTITYID_PARTICIPANT" }, { ENTITYID_SEDP_BUILTIN_TOPIC_WRITER, "ENTITYID_SEDP_BUILTIN_TOPIC_WRITER" }, { ENTITYID_SEDP_BUILTIN_TOPIC_READER, "ENTITYID_SEDP_BUILTIN_TOPIC_READER" }, { ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER, "ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER" }, { ENTITYID_SEDP_BUILTIN_PUBLICATIONS_READER, "ENTITYID_SEDP_BUILTIN_PUBLICATIONS_READER" }, { ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER, "ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER" }, { ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_READER, "ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_READER" }, { ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER, "ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER" }, { ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER, "ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER" }, { ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER, "ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER" }, { ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_READER, "ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_READER" }, /* Deprecated Items */ { ENTITYID_APPLICATIONS_WRITER, "writerApplications [DEPRECATED]" }, { ENTITYID_APPLICATIONS_READER, "readerApplications [DEPRECATED]" }, { ENTITYID_CLIENTS_WRITER, "writerClients [DEPRECATED]" }, { ENTITYID_CLIENTS_READER, "readerClients [DEPRECATED]" }, { ENTITYID_SERVICES_WRITER, "writerServices [DEPRECATED]" }, { ENTITYID_SERVICES_READER, "readerServices [DEPRECATED]" }, { ENTITYID_MANAGERS_WRITER, "writerManagers [DEPRECATED]" }, { ENTITYID_MANAGERS_READER, "readerManagers [DEPRECATED]" }, { ENTITYID_APPLICATION_SELF, "applicationSelf [DEPRECATED]" }, { ENTITYID_APPLICATION_SELF_WRITER, "writerApplicationSelf [DEPRECATED]" }, { ENTITYID_APPLICATION_SELF_READER, "readerApplicationSelf [DEPRECATED]" }, { 0, NULL } }; static const value_string entity_kind_vals [] = { { ENTITYKIND_APPDEF_UNKNOWN, "Application-defined unknown kind" }, { ENTITYKIND_APPDEF_PARTICIPANT, "Application-defined participant" }, { ENTITYKIND_APPDEF_WRITER_WITH_KEY, "Application-defined writer (with key)" }, { ENTITYKIND_APPDEF_WRITER_NO_KEY, "Application-defined writer (no key)" }, { ENTITYKIND_APPDEF_READER_WITH_KEY, "Application-defined reader (with key)" }, { ENTITYKIND_APPDEF_READER_NO_KEY, "Application-defined reader (no key)" }, { ENTITYKIND_BUILTIN_PARTICIPANT, "Built-in participant" }, { ENTITYKIND_BUILTIN_WRITER_WITH_KEY, "Built-in writer (with key)" }, { ENTITYKIND_BUILTIN_WRITER_NO_KEY, "Built-in writer (no key)" }, { ENTITYKIND_BUILTIN_READER_WITH_KEY, "Built-in reader (with key)" }, { ENTITYKIND_BUILTIN_READER_NO_KEY, "Built-in reader (no key)" }, { 0, NULL } }; static const value_string nature_type_vals[] = { { PORT_METATRAFFIC_UNICAST, "UNICAST_METATRAFFIC"}, { PORT_METATRAFFIC_MULTICAST, "MULTICAST_METATRAFFIC"}, { PORT_USERTRAFFIC_UNICAST, "UNICAST_USERTRAFFIC"}, { PORT_USERTRAFFIC_MULTICAST, "MULTICAST_USERTRAFFIC"}, { 0, NULL } }; static const value_string app_kind_vals[] = { { APPKIND_UNKNOWN, "APPKIND_UNKNOWN" }, { APPKIND_MANAGED_APPLICATION, "ManagedApplication" }, { APPKIND_MANAGER, "Manager" }, { 0, NULL } }; static const value_string submessage_id_vals[] = { { SUBMESSAGE_PAD, "PAD" }, { SUBMESSAGE_RTPS_DATA, "DATA" }, { SUBMESSAGE_RTPS_DATA_FRAG, "DATA_FRAG" }, { SUBMESSAGE_RTPS_DATA_BATCH, "DATA_BATCH" }, { SUBMESSAGE_ACKNACK, "ACKNACK" }, { SUBMESSAGE_HEARTBEAT, "HEARTBEAT" }, { SUBMESSAGE_GAP, "GAP" }, { SUBMESSAGE_INFO_TS, "INFO_TS" }, { SUBMESSAGE_INFO_SRC, "INFO_SRC" }, { SUBMESSAGE_INFO_REPLY_IP4, "INFO_REPLY_IP4" }, { SUBMESSAGE_INFO_DST, "INFO_DST" }, { SUBMESSAGE_INFO_REPLY, "INFO_REPLY" }, { SUBMESSAGE_NACK_FRAG, "NACK_FRAG" }, { SUBMESSAGE_HEARTBEAT_FRAG, "HEARTBEAT_FRAG" }, { SUBMESSAGE_ACKNACK_BATCH, "ACKNACK_BATCH" }, { SUBMESSAGE_HEARTBEAT_BATCH, "HEARTBEAT_BATCH" }, { SUBMESSAGE_ACKNACK_SESSION, "ACKNACK_SESSION" }, { SUBMESSAGE_HEARTBEAT_SESSION, "HEARTBEAT_SESSION" }, { SUBMESSAGE_RTPS_DATA_SESSION, "DATA_SESSION" }, /* Deprecated submessages */ { SUBMESSAGE_DATA, "DATA_deprecated" }, { SUBMESSAGE_NOKEY_DATA, "NOKEY_DATA_deprecated" }, { SUBMESSAGE_DATA_FRAG, "DATA_FRAG_deprecated" }, { SUBMESSAGE_NOKEY_DATA_FRAG, "NOKEY_DATA_FRAG_deprecated" }, { 0, NULL } }; static const value_string typecode_kind_vals[] = { { RTI_CDR_TK_NULL, "(unknown)" }, { RTI_CDR_TK_SHORT, "short" }, { RTI_CDR_TK_LONG, "long" }, { RTI_CDR_TK_USHORT, "unsigned short" }, { RTI_CDR_TK_ULONG, "unsigned long" }, { RTI_CDR_TK_FLOAT, "float" }, { RTI_CDR_TK_DOUBLE, "double" }, { RTI_CDR_TK_BOOLEAN, "boolean" }, { RTI_CDR_TK_CHAR, "char" }, { RTI_CDR_TK_OCTET, "octet" }, { RTI_CDR_TK_STRUCT, "struct" }, { RTI_CDR_TK_UNION, "union" }, { RTI_CDR_TK_ENUM, "enum" }, { RTI_CDR_TK_STRING, "string" }, { RTI_CDR_TK_SEQUENCE, "sequence" }, { RTI_CDR_TK_ARRAY, "array" }, { RTI_CDR_TK_ALIAS, "alias" }, { RTI_CDR_TK_LONGLONG, "long long" }, { RTI_CDR_TK_ULONGLONG, "unsigned long long" }, { RTI_CDR_TK_LONGDOUBLE, "long double" }, { RTI_CDR_TK_WCHAR, "wchar" }, { RTI_CDR_TK_WSTRING, "wstring" }, { 0, NULL } }; static const value_string parameter_id_vals[] = { { PID_PAD, "PID_PAD" }, { PID_SENTINEL, "PID_SENTINEL" }, { PID_PARTICIPANT_LEASE_DURATION, "PID_PARTICIPANT_LEASE_DURATION" }, { PID_TIME_BASED_FILTER, "PID_TIME_BASED_FILTER" }, { PID_TOPIC_NAME, "PID_TOPIC_NAME" }, { PID_OWNERSHIP_STRENGTH, "PID_OWNERSHIP_STRENGTH" }, { PID_TYPE_NAME, "PID_TYPE_NAME" }, { PID_METATRAFFIC_MULTICAST_IPADDRESS,"PID_METATRAFFIC_MULTICAST_IPADDRESS"}, { PID_DEFAULT_UNICAST_IPADDRESS, "PID_DEFAULT_UNICAST_IPADDRESS" }, { PID_METATRAFFIC_UNICAST_PORT, "PID_METATRAFFIC_UNICAST_PORT" }, { PID_DEFAULT_UNICAST_PORT, "PID_DEFAULT_UNICAST_PORT" }, { PID_MULTICAST_IPADDRESS, "PID_MULTICAST_IPADDRESS" }, { PID_PROTOCOL_VERSION, "PID_PROTOCOL_VERSION" }, { PID_VENDOR_ID, "PID_VENDOR_ID" }, { PID_RELIABILITY, "PID_RELIABILITY" }, { PID_LIVELINESS, "PID_LIVELINESS" }, { PID_DURABILITY, "PID_DURABILITY" }, { PID_DURABILITY_SERVICE, "PID_DURABILITY_SERVICE" }, { PID_OWNERSHIP, "PID_OWNERSHIP" }, { PID_PRESENTATION, "PID_PRESENTATION" }, { PID_DEADLINE, "PID_DEADLINE" }, { PID_DESTINATION_ORDER, "PID_DESTINATION_ORDER" }, { PID_LATENCY_BUDGET, "PID_LATENCY_BUDGET" }, { PID_PARTITION, "PID_PARTITION" }, { PID_LIFESPAN, "PID_LIFESPAN" }, { PID_USER_DATA, "PID_USER_DATA" }, { PID_GROUP_DATA, "PID_GROUP_DATA" }, { PID_TOPIC_DATA, "PID_TOPIC_DATA" }, { PID_UNICAST_LOCATOR, "PID_UNICAST_LOCATOR" }, { PID_MULTICAST_LOCATOR, "PID_MULTICAST_LOCATOR" }, { PID_DEFAULT_UNICAST_LOCATOR, "PID_DEFAULT_UNICAST_LOCATOR" }, { PID_METATRAFFIC_UNICAST_LOCATOR, "PID_METATRAFFIC_UNICAST_LOCATOR " }, { PID_METATRAFFIC_MULTICAST_LOCATOR, "PID_METATRAFFIC_MULTICAST_LOCATOR" }, { PID_PARTICIPANT_MANUAL_LIVELINESS_COUNT, "PID_PARTICIPANT_MANUAL_LIVELINESS_COUNT" }, { PID_CONTENT_FILTER_PROPERTY, "PID_CONTENT_FILTER_PROPERTY" }, { PID_PROPERTY_LIST, "PID_PROPERTY_LIST" }, { PID_HISTORY, "PID_HISTORY" }, { PID_RESOURCE_LIMIT, "PID_RESOURCE_LIMIT" }, { PID_EXPECTS_INLINE_QOS, "PID_EXPECTS_INLINE_QOS" }, { PID_PARTICIPANT_BUILTIN_ENDPOINTS, "PID_PARTICIPANT_BUILTIN_ENDPOINTS" }, { PID_METATRAFFIC_UNICAST_IPADDRESS, "PID_METATRAFFIC_UNICAST_IPADDRESS" }, { PID_METATRAFFIC_MULTICAST_PORT, "PID_METATRAFFIC_MULTICAST_PORT" }, { PID_DEFAULT_MULTICAST_LOCATOR, "PID_DEFAULT_MULTICAST_LOCATOR" }, { PID_TRANSPORT_PRIORITY, "PID_TRANSPORT_PRIORITY" }, { PID_PARTICIPANT_GUID, "PID_PARTICIPANT_GUID" }, { PID_PARTICIPANT_ENTITY_ID, "PID_PARTICIPANT_ENTITY_ID" }, { PID_GROUP_GUID, "PID_GROUP_GUID" }, { PID_GROUP_ENTITY_ID, "PID_GROUP_ENTITY_ID" }, { PID_CONTENT_FILTER_INFO, "PID_CONTENT_FILTER_INFO" }, { PID_COHERENT_SET, "PID_COHERENT_SET" }, { PID_DIRECTED_WRITE, "PID_DIRECTED_WRITE" }, { PID_BUILTIN_ENDPOINT_SET, "PID_BUILTIN_ENDPOINT_SET" }, { PID_PROPERTY_LIST_OLD, "PID_PROPERTY_LIST" }, { PID_ENDPOINT_GUID, "PID_ENDPOINT_GUID" }, { PID_TYPE_MAX_SIZE_SERIALIZED, "PID_TYPE_MAX_SIZE_SERIALIZED" }, { PID_ORIGINAL_WRITER_INFO, "PID_ORIGINAL_WRITER_INFO" }, { PID_ENTITY_NAME, "PID_ENTITY_NAME" }, { PID_KEY_HASH, "PID_KEY_HASH" }, { PID_STATUS_INFO, "PID_STATUS_INFO" }, /* Vendor specific: RTI */ { PID_PRODUCT_VERSION, "PID_PRODUCT_VERSION" }, { PID_PLUGIN_PROMISCUITY_KIND, "PID_PLUGIN_PROMISCUITY_KIND" }, { PID_ENTITY_VIRTUAL_GUID, "PID_ENTITY_VIRTUAL_GUID" }, { PID_SERVICE_KIND, "PID_SERVICE_KIND" }, { PID_TYPECODE_RTPS2, "PID_TYPECODE" }, { PID_DISABLE_POSITIVE_ACKS, "PID_DISABLE_POSITIVE_ACKS" }, { PID_LOCATOR_FILTER_LIST, "PID_LOCATOR_FILTER_LIST" }, /* The following PID are deprecated */ { PID_DEADLINE_OFFERED, "PID_DEADLINE_OFFERED [deprecated]" }, { PID_PERSISTENCE, "PID_PERSISTENCE [deprecated]" }, { PID_TYPE_CHECKSUM, "PID_TYPE_CHECKSUM [deprecated]" }, { PID_TYPE2_NAME, "PID_TYPE2_NAME [deprecated]" }, { PID_TYPE2_CHECKSUM, "PID_TYPE2_CHECKSUM [deprecated]" }, { PID_IS_RELIABLE, "PID_IS_RELIABLE [deprecated]" }, { PID_EXPECTS_ACK, "PID_EXPECTS_ACK [deprecated]" }, { PID_MANAGER_KEY, "PID_MANAGER_KEY [deprecated]" }, { PID_SEND_QUEUE_SIZE, "PID_SEND_QUEUE_SIZE [deprecated]" }, { PID_RELIABILITY_ENABLED, "PID_RELIABILITY_ENABLED [deprecated]" }, { PID_VARGAPPS_SEQUENCE_NUMBER_LAST, "PID_VARGAPPS_SEQUENCE_NUMBER_LAST [deprecated]" }, { PID_RECV_QUEUE_SIZE, "PID_RECV_QUEUE_SIZE [deprecated]" }, { PID_RELIABILITY_OFFERED, "PID_RELIABILITY_OFFERED [deprecated]" }, { PID_LIVELINESS_OFFERED, "PID_LIVELINESS_OFFERED [deprecated]" }, { PID_PRESENTATION_OFFERED, "PID_PRESENTATION_OFFERED [deprecated]" }, { PID_OWNERSHIP_OFFERED, "PID_OWNERSHIP_OFFERED [deprecated]" }, { PID_DESTINATION_ORDER_OFFERED, "PID_DESTINATION_ORDER_OFFERED [deprecated]" }, { PID_LATENCY_BUDGET_OFFERED, "PID_LATENCY_BUDGET_OFFERED [deprecated]" }, { PID_PARTITION_OFFERED, "PID_PARTITION_OFFERED [deprecated]" }, { 0, NULL } }; static const value_string liveliness_qos_vals[] = { { LIVELINESS_AUTOMATIC, "AUTOMATIC_LIVELINESS_QOS" }, { LIVELINESS_BY_PARTICIPANT, "MANUAL_BY_PARTICIPANT_LIVELINESS_QOS" }, { LIVELINESS_BY_TOPIC, "MANUAL_BY_TOPIC_LIVELINESS_QOS" }, { 0, NULL } }; static const value_string durability_qos_vals[] = { { DURABILITY_VOLATILE, "VOLATILE_DURABILITY_QOS" }, { DURABILITY_TRANSIENT_LOCAL, "TRANSIENT_LOCAL_DURABILITY_QOS" }, { DURABILITY_TRANSIENT, "TRANSIENT_DURABILITY_QOS" }, { DURABILITY_PERSISTENT, "PERSISTENT_DURABILITY_QOS" }, { 0, NULL } }; static const value_string ownership_qos_vals[] = { { OWNERSHIP_SHARED, "SHARED_OWNERSHIP_QOS" }, { OWNERSHIP_EXCLUSIVE, "EXCLUSIVE_OWNERSHIP_QOS" }, { 0, NULL } }; static const value_string presentation_qos_vals[] = { { PRESENTATION_INSTANCE, "INSTANCE_PRESENTATION_QOS" }, { PRESENTATION_TOPIC, "TOPIC_PRESENTATION_QOS" }, { PRESENTATION_GROUP, "GROUP_PRESENTATION_QOS" }, { 0, NULL } }; static const value_string history_qos_vals[] = { { HISTORY_KIND_KEEP_LAST, "KEEP_LAST_HISTORY_QOS" }, { HISTORY_KIND_KEEP_ALL, "KEEP_ALL_HISTORY_QOS" }, { 0, NULL } }; static const value_string reliability_qos_vals[] = { { RELIABILITY_BEST_EFFORT, "BEST_EFFORT_RELIABILITY_QOS" }, { RELIABILITY_RELIABLE, "RELIABLE_RELIABILITY_QOS" }, { 0, NULL } }; static const value_string destination_order_qos_vals[] = { { BY_RECEPTION_TIMESTAMP, "BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS" }, { BY_SOURCE_TIMESTAMP, "BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS" }, { 0, NULL } }; static const value_string encapsulation_id_vals[] = { { ENCAPSULATION_CDR_BE, "CDR_BE" }, { ENCAPSULATION_CDR_LE, "CDR_LE" }, { ENCAPSULATION_PL_CDR_BE, "PL_CDR_BE" }, { ENCAPSULATION_PL_CDR_LE, "PL_CDR_LE" }, { 0, NULL } }; static const value_string plugin_promiscuity_kind_vals[] = { { 0x0001, "MATCHING_REMOTE_ENTITIES_PROMISCUITY" }, { 0xffff, "ALL_REMOTE_ENTITIES_PROMISCUITY" }, { 0, NULL } }; static const value_string service_kind_vals[] = { { 0x00000000, "NO_SERVICE_QOS" }, { 0x00000001, "PERSISTENCE_SERVICE_QOS" }, { 0, NULL } }; static const value_string participant_message_data_kind [] = { { PARTICIPANT_MESSAGE_DATA_KIND_UNKNOWN, "PARTICIPANT_MESSAGE_DATA_KIND_UNKNOWN" }, { PARTICIPANT_MESSAGE_DATA_KIND_AUTOMATIC_LIVELINESS_UPDATE, "PARTICIPANT_MESSAGE_DATA_KIND_AUTOMATIC_LIVELINESS_UPDATE" }, { PARTICIPANT_MESSAGE_DATA_KIND_MANUAL_LIVELINESS_UPDATE, "PARTICIPANT_MESSAGE_DATA_KIND_MANUAL_LIVELINESS_UPDATE" }, { 0, NULL } }; /* Flag Decoding defintions ***********************************************/ struct Flag_definition { const char letter; const char *description; }; #define RESERVEDFLAG_CHAR ('_') #define RESERVEDFLAG_STRING ("reserved bit") static const struct Flag_definition DATA_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { 'I', "Status info flag" }, /* Bit 4 */ { 'H', "Hash key flag" }, /* Bit 3 */ { 'D', "Data present" }, /* Bit 2 */ { 'Q', "Inline QoS" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition NOKEY_DATA_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { 'H', "Key Hash" }, /* Bit 2 */ { 'Q', "Inline QoS" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition ACKNACK_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { 'F', "Final flag" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition GAP_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition HEARTBEAT_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { 'L', "Liveliness flag" }, /* Bit 2 */ { 'F', "Final flag" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition HEARTBEAT_BATCH_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { 'L', "Liveliness flag" }, /* Bit 2 */ { 'F', "Final flag" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition INFO_TS_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { 'I', "Invalidate flag" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition INFO_SRC_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition INFO_REPLY_IP4_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { 'M', "Multicast flag" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition INFO_DST_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition INFO_REPLY_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { 'M', "Multicast flag" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition NOKEY_DATA_FRAG_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { 'Q', "Inline QoS" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition HEARTBEAT_FRAG_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition NACK_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { 'F', "Final flag" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition DATA_FRAG_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { 'H', "Hash key flag" }, /* Bit 2 */ { 'Q', "Inline QoS" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition NACK_FRAG_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition RTPS_DATA_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { 'K', "Serialized Key" }, /* Bit 3 */ { 'D', "Data present" }, /* Bit 2 */ { 'Q', "Inline QoS" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition RTPS_DATA_FRAG_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { 'K', "Serialized Key" }, /* Bit 2 */ { 'Q', "Inline QoS" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition RTPS_DATA_BATCH_FLAGS[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 5 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 4 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 3 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 2 */ { 'Q', "Inline QoS" }, /* Bit 1 */ { 'E', "Endianness bit" } /* Bit 0 */ }; static const struct Flag_definition RTPS_SAMPLE_INFO_FLAGS16[] = { { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 15 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 14 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 13 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 12 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 11 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 10 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 9 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 8 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 7 */ { RESERVEDFLAG_CHAR, RESERVEDFLAG_STRING }, /* Bit 6 */ { 'K', "Serialized Key" }, /* Bit 5 */ { 'I', "Invalid sample" }, /* Bit 4 */ { 'D', "Data present" }, /* Bit 3 */ { 'O', "OffsetSN present" }, /* Bit 2 */ { 'Q', "Inline QoS" }, /* Bit 1 */ { 'T', "Timestamp present" } /* Bit 0 */ }; /***************************************************************************/ /*************************************************************************** * Function prototypes * ~~~~~~~~~~~~~~~~~~~ */ /* Utility to add elements to the protocol tree */ static void rtps_util_add_guid_prefix(proto_tree *, tvbuff_t *, gint, int, int, int, int, const guint8 *, guint8 *, gint); static void rtps_util_add_generic_guid(proto_tree *, tvbuff_t *, gint, const char *, guint8 *, gint); static guint16 rtps_util_add_short(proto_tree *, tvbuff_t *, gint, int, int, gboolean, gboolean, const char *, guint8 *, gint); static int rtps_util_add_bitmap(proto_tree *, tvbuff_t *, gint, int, const char *); static int rtps_util_add_fragment_number_set(proto_tree *, tvbuff_t *, gint, int, const char *, gint); static void rtps_util_add_extra_flags(proto_tree *, tvbuff_t *, gint, const char *); /* The data (payload) dissector */ static void dissect_octet_seq(proto_tree *, tvbuff_t *, gint, const char *); /* The data (payload) dissector for parameter sequences */ static gint dissect_parameter_sequence(proto_tree *, packet_info *pinfo, tvbuff_t *, gint, int, int, const char *, guint32 *, guint16 vendor_id); /***************************************************************************/ /* Inline macros */ /***************************************************************************/ #define NEXT_guint16(tvb, offset, le) \ (le ? tvb_get_letohs(tvb, offset) : tvb_get_ntohs(tvb, offset)) #define NEXT_guint32(tvb, offset, le) \ (le ? tvb_get_letohl(tvb, offset) : tvb_get_ntohl(tvb, offset)) /***************************************************************************/ /* Global variables controlled by Wireshark preference panel */ /***************************************************************************/ static guint rtps_max_batch_samples_dissected = 16; /* *********************************************************************** */ /* Appends extra formatting for those submessages that have a status info */ static void info_summary_append_ex(packet_info *pinfo, guint32 writer_id, guint32 status_info) { /* Defines the extra information associated to the writer involved in * this communication * * Format: [?Ptwrpm]\(u?d?\) * * First letter table: * * writerEntityId value | Letter * ---------------------------------------------------+-------------- * ENTITYID_UNKNOWN | ? * ENTITYID_PARTICIPANT | P * ENTITYID_SEDP_BUILTIN_TOPIC_WRITER | t * ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER | w * ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER | r * ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER | p * ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER | m * * The letter is followed by: * status_info &1 | status_info & 2 | Text * ---------------+-----------------------+-------------- * status_info not defined in inlineQos | [?] * 0 | 0 | [__] * 0 | 1 | [u_] * 1 | 0 | [_d] * 1 | 1 | [ud] */ /* 0123456 */ char buffer[10] = "(?[??])"; switch(writer_id) { case ENTITYID_PARTICIPANT: buffer[1] = 'P'; break; case ENTITYID_SEDP_BUILTIN_TOPIC_WRITER: buffer[1] = 't'; break; case ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER: buffer[1] = 'w'; break; case ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER: buffer[1] = 'r'; break; case ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER: buffer[1] = 'p'; break; case ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER: buffer[1] = 'm'; break; default: /* Unknown writer ID, don't format anything */ return; } switch(status_info) { case 0: buffer[3] = '_'; buffer[4] = '_'; break; case 1: buffer[3] = '_'; buffer[4] = 'D'; break; case 2: buffer[3] = 'U'; buffer[4] = '_'; break; case 3: buffer[3] = 'U'; buffer[4] = 'D'; break; default: /* Unknown status info, omit it */ buffer[2] = ')'; buffer[3] = '\0'; } col_append_str(pinfo->cinfo, COL_INFO, buffer); } /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * NOTE: * In general those utility functions (they all starts with 'rtps_util') * are used to dissect some part of a submessage. * They take as first parameter the proto_tree. * Now, the proto_tree can be NULL if the dissector is invoked without * a packet tree. * Sometimes those functions they also return some value (as result of * the dissecting). * At the price of optimizing the code, each function MUST tollerate * a NULl tree. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ /* *********************************************************************** */ static void rtps_util_add_extra_flags(proto_tree *tree, tvbuff_t *tvb, gint offset, const char *label) { if (tree) { guint16 flags = NEXT_guint16(tvb, offset, FALSE); /* Always big endian */ emem_strbuf_t *temp_buffer = ep_strbuf_new_label(NULL); int i; for (i = 0; i < 16; ++i) { ep_strbuf_append_c(temp_buffer, ((flags & (1 << (15-i))) != 0) ? '1' : '0'); } proto_tree_add_text(tree, tvb, offset, 2, "%s: %s", label, temp_buffer->str); } } /* ------------------------------------------------------------------------- */ /* Insert in the protocol tree the next 12 bytes interpreted as GuidPrefix * If tree is specified, it fills up the protocol tree item: * - hf_rtps_guid_prefix * - hf_rtps_host_id * - hf_rtps_app_id * - hf_rtps_counter * * If buffer is specified, it returns in it a string representation of the * data read. */ static void rtps_util_add_guid_prefix(proto_tree *tree, tvbuff_t * tvb, gint offset, int hf_prefix, /* Cannot be 0 if tree != NULL */ int hf_host_id, int hf_app_id, int hf_counter, const guint8 * label, /* Can be NULL */ guint8 * buffer, /* Can be NULL */ gint buffer_size) { guint32 host_id; guint32 app_id; guint32 counter; guint8 * temp_buff; guint8 guid_prefix[12]; const guint8 * safe_label; int i; safe_label = (label == NULL) ? (const guint8 *)"guidPrefix" : label; /* Read values from TVB */ host_id = tvb_get_ntohl(tvb, offset); app_id = tvb_get_ntohl(tvb, offset + 4); counter = tvb_get_ntohl(tvb, offset + 8); for (i = 0; i < 12; ++i) { guid_prefix[i] = tvb_get_guint8(tvb, offset+i); } /* Format the string */ temp_buff = (guint8 *) ep_alloc(MAX_GUID_PREFIX_SIZE); g_snprintf(temp_buff, MAX_GUID_PREFIX_SIZE, "%s=%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x" " { hostId=%08x, appId=%08x, counter=%08x }", safe_label, guid_prefix[0], guid_prefix[1], guid_prefix[2], guid_prefix[3], guid_prefix[4], guid_prefix[5], guid_prefix[6], guid_prefix[7], guid_prefix[8], guid_prefix[9], guid_prefix[10], guid_prefix[11], host_id, app_id, counter); if (tree) { proto_item * ti, *hidden_item; proto_tree * guid_tree; /* The numeric value (used for searches) */ hidden_item = proto_tree_add_item(tree, hf_prefix, tvb, offset, 12, ENC_NA); PROTO_ITEM_SET_HIDDEN(hidden_item); /* The text node (root of the guid prefix sub-tree) */ ti = proto_tree_add_text(tree, tvb, offset, 12, "%s", temp_buff); guid_tree = proto_item_add_subtree(ti, ett_rtps_guid_prefix); /* Host Id */ proto_tree_add_item(guid_tree, hf_host_id, tvb, offset, 4, ENC_BIG_ENDIAN); /* App Id */ proto_tree_add_item(guid_tree, hf_app_id, tvb, offset+4, 4, ENC_BIG_ENDIAN); /* Counter */ proto_tree_add_item(guid_tree, hf_counter, tvb, offset+8, 4, ENC_BIG_ENDIAN); } if (buffer != NULL) { g_strlcpy(buffer, temp_buff, buffer_size); } } /* ------------------------------------------------------------------------- */ /* Interpret the next 16 octets as a generic GUID and insert it in the protocol * tree as simple text (no reference fields are set). * It is mostly used in situation where is not required to perform search for * this kind of GUID (i.e. like in some DATA parameter lists). */ static void rtps_util_add_generic_guid(proto_tree *tree, tvbuff_t * tvb, /* Cannot be NULL */ gint offset, const char *label, /* Cannot be NULL */ guint8 * buffer, /* Can be NULL */ gint buffer_size) { guint32 host_id; guint32 app_id; guint32 entity_id; guint32 entity_key; guint32 counter; guint8 entity_kind; guint8 guid_raw[16]; const char * str_entity_kind; guint8 temp_buff[MAX_GUID_SIZE]; int i; /* Read typed data */ host_id = tvb_get_ntohl(tvb, offset); app_id = tvb_get_ntohl(tvb, offset + 4); counter = tvb_get_ntohl(tvb, offset + 8); entity_id = tvb_get_ntohl(tvb, offset + 12); /* Re-Read raw data */ for (i = 0; i < 16; ++i) { guid_raw[i] = tvb_get_guint8(tvb, offset+i); } /* Split components from typed data */ entity_key = (entity_id >> 8); entity_kind = (entity_id & 0xff); /* Lookup for predefined app kind and entity kind */ str_entity_kind = val_to_str(entity_kind, entity_kind_vals, "%02x"); /* Compose output buffer for raw guid */ g_snprintf(temp_buff, MAX_GUID_SIZE, "%s=%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x: " "{ hostId=%08x, appId=%08x, counter=%08x, entityId=%08x (%s: %06x) }", label, guid_raw[0], guid_raw[1], guid_raw[2], guid_raw[3], guid_raw[4], guid_raw[5], guid_raw[6], guid_raw[7], guid_raw[8], guid_raw[9], guid_raw[10], guid_raw[11], guid_raw[12], guid_raw[13], guid_raw[14], guid_raw[15], host_id, app_id, counter, entity_id, str_entity_kind, entity_key); if (tree) { proto_tree_add_text(tree, tvb, offset, 16, "%s", temp_buff); } if (buffer != NULL) { g_strlcpy(buffer, temp_buff, buffer_size); } } /* ------------------------------------------------------------------------- */ /* Insert in the protocol tree the next data interpreted as a 16-bit short */ static guint16 rtps_util_add_short(proto_tree *tree, tvbuff_t * tvb, gint offset, int hf_item, /* Can be -1 */ gboolean little_endian, gboolean is_hex, /* Format as 0x... */ gboolean is_signed, /* Signed/Unsigned */ const char *label, /* Can be NULL */ guint8 * buffer, gint buffer_size) { char temp_buff[16]; guint16 retVal = NEXT_guint16(tvb, offset, little_endian); g_snprintf(temp_buff, 16, (is_hex ? "0x%04x" : (is_signed ? "%d" : "%u")), retVal); if (tree != NULL) { if (hf_item != -1) { proto_tree_add_item(tree, hf_item, tvb, offset, 2, little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN); } else if (label != NULL) { proto_tree_add_text(tree, tvb, offset, 2, "%s: %s", label, temp_buff); } } if (buffer != NULL) { g_strlcpy(buffer, temp_buff, buffer_size); } return retVal; } /* ------------------------------------------------------------------------- */ /* Insert in the protocol tree the next data interpreted as a signed long. */ static guint32 rtps_util_add_long(proto_tree *tree, /* Can be NULL */ tvbuff_t * tvb, gint offset, int hf_item, /* Can be -1 */ gboolean little_endian, gboolean is_hex, /* Format as 0x... */ gboolean is_signed, /* Signed/Unsigned */ const char *label, /* Can be NULL */ guint8 * buffer, size_t buffer_size) { char temp_buff[16]; guint32 retVal = NEXT_guint32(tvb, offset, little_endian); g_snprintf(temp_buff, 16, (is_hex ? "0x%08x" : (is_signed ? "%d" : "%u")), retVal); if (tree != NULL) { if (hf_item != -1) { proto_tree_add_item(tree, hf_item, tvb, offset, 4, little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN); } else if (label != NULL) { proto_tree_add_text(tree, tvb, offset, 4, "%s: %s", label, temp_buff); } } if (buffer != NULL) { g_strlcpy(buffer, temp_buff, (gulong) buffer_size); } return retVal; } #define LONG_ALIGN(x) (x = (x+3)&0xfffffffc) #define SHORT_ALIGN(x) (x = (x+1)&0xfffffffe) #define MAX_ARRAY_DIMENSION 10 #define KEY_COMMENT (" //@key") /* ------------------------------------------------------------------------- */ static const char * rtps_util_typecode_id_to_string(guint32 typecode_id) { switch(typecode_id) { case RTI_CDR_TK_ENUM: return "enum"; case RTI_CDR_TK_UNION: return "union"; case RTI_CDR_TK_STRUCT: return "struct"; case RTI_CDR_TK_LONG: return "long"; case RTI_CDR_TK_SHORT: return "short"; case RTI_CDR_TK_USHORT: return "unsigned short"; case RTI_CDR_TK_ULONG: return "unsigned long"; case RTI_CDR_TK_FLOAT: return "float"; case RTI_CDR_TK_DOUBLE: return "double"; case RTI_CDR_TK_BOOLEAN:return "boolean"; case RTI_CDR_TK_CHAR: return "char"; case RTI_CDR_TK_OCTET: return "octet"; case RTI_CDR_TK_LONGLONG:return "longlong"; case RTI_CDR_TK_ULONGLONG: return "unsigned long long"; case RTI_CDR_TK_LONGDOUBLE: return "long double"; case RTI_CDR_TK_WCHAR: return "wchar"; case RTI_CDR_TK_WSTRING:return "wstring"; case RTI_CDR_TK_STRING: return "string"; case RTI_CDR_TK_SEQUENCE: return "sequence"; case RTI_CDR_TK_ARRAY: return "array"; case RTI_CDR_TK_ALIAS: return "alias"; case RTI_CDR_TK_VALUE: return "valuetype"; case RTI_CDR_TK_NULL: default: return ""; } } /* ------------------------------------------------------------------------- */ /* Insert in the protocol tree the next bytes interpreted as typecode info * Returns the number of bytes parsed */ static gint rtps_util_add_typecode(proto_tree *tree, tvbuff_t * tvb, gint offset, gboolean little_endian, int indent_level, int is_pointer, guint16 bitfield, int is_key, const gint offset_begin, char * name, int seq_max_len, /* 0 = not a sequence field (-1 = unbounded seq) */ guint32 * arr_dimension, /* if !NULL: array of 10 int */ int ndds_40_hack) { const gint original_offset = offset; guint32 tk_id; guint16 tk_size; unsigned int i; char* indent_string; gint retVal; char type_name[40]; /* Structure of the typecode data: * Offset | Size | Field | Notes * ----------|-------|------------------------------|--------------------- * ? | ? | pad? | * 0 | 4 | RTI_CDR_TK_XXXXX | 4 bytes aligned * 4 | 2 | length the struct | */ /* Calc indent string */ indent_string = (char *)ep_alloc((indent_level*2)+1); memset(indent_string, ' ', indent_level*2); indent_string[indent_level*2] = '\0'; /* Gets TK ID */ LONG_ALIGN(offset); tk_id = NEXT_guint32(tvb, offset, little_endian); offset += 4; /* Gets TK size */ tk_size = NEXT_guint16(tvb, offset, little_endian); offset += 2; retVal = tk_size + 6; /* 6 = 4 (typecode ID) + 2 (size) */ /* The first bit of typecode is set to 1, clear it */ tk_id &= 0x7fffffff; /* HACK: NDDS 4.0 and NDDS 4.1 has different typecode ID list. * The ID listed in the RTI_CDR_TK_XXXXX are the one from NDDS 4.1 * In order to correctly dissect NDDS 4.0 packets containing typecode * information, we check if the ID of the element at level zero is a * struct or union. If not, it means we are dissecting a ndds 4.0 packet * (and we can decrement the ID to match the correct values). */ if (indent_level == 0) { if (tk_id == RTI_CDR_TK_OCTET) { ndds_40_hack = 1; } } if (ndds_40_hack) { ++tk_id; } g_strlcpy(type_name, rtps_util_typecode_id_to_string(tk_id), 40); /* Structure of the typecode data: * * ::= * * * * ::= long (0=TK_NULL, 1=TK_SHORT...) * ::= unsugned short * */ switch(tk_id) { /* Structure of the typecode data: * * ::= * * * * * * + * ::= * ::= unsigned short * ::= * ::= char+ * ::= unsigned long * ::= (char)0 * * ::= * *