/epan/dissectors/packet-dmp.c
C | 5101 lines | 4232 code | 540 blank | 329 comment | 754 complexity | 84d246a4d8276feb832171e8cb46bcc6 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- /* packet-dmp.c
- *
- * Routines for STANAG 4406 Direct Message Profile packet disassembly.
- * A protocol for optimised transfer of time-critical short messages
- * for use with a reliable bearer service. Checksum and retransmission
- * mechanisms are activated when using unreliable bearer services.
- *
- * Copyright 2006, Stig Bjorlykke <stig@bjorlykke.org>, Thales Norway AS
- *
- * $Id$
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * 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.
- *
- * Ref: http://jcs.dtic.mil/j6/cceb/acps/acp123/
- */
- /*
- * TODO:
- * - Dissect extended Restrictive security categories
- * - Add Transmission/Retransmission statistics
- */
- #include "config.h"
- #include <string.h>
- #include <math.h>
- #include <epan/packet.h>
- #include <epan/address.h>
- #include <epan/addr_resolv.h>
- #include <epan/to_str.h>
- #include <epan/prefs.h>
- #include <epan/emem.h>
- #include <epan/expert.h>
- #include <epan/crc16-tvb.h>
- #include <epan/asn1.h>
- #include <epan/strutil.h>
- #include <epan/uat.h>
- #include "packet-p1.h"
- #include "packet-p22.h"
- #define PNAME "Direct Message Profile"
- #define PSNAME "DMP"
- #define PFNAME "dmp"
- /* Default UDP Port Number */
- #define DEFAULT_DMP_PORT_RANGE "5031"
- /* Protocol Identifier */
- #define PROT_NAT 0x0D
- #define PROT_DMP 0x1D
- /* Versions supported */
- #define DMP_VERSION_1 1
- #define DMP_VERSION_2 2
- /* Message Type (dmp.msg_type) */
- #define STANAG 0x0
- #define IPM 0x1
- #define REPORT 0x2
- #define NOTIF 0x3
- #define ACK 0x4
- /* Message Identifier Type (dmp.msg_id_type) */
- #define ONLY_DMP_ID 0x0
- #define X400_MSG_ID 0x1
- #define NAT_MSG_ID 0x2
- /* Report Type (dmp.report_type) */
- #define DR 0x0
- #define NDR 0x1
- /* Notification Type (dmp.notif_type) */
- #define RN 0x0
- #define NRN 0x1
- #define ON 0x2
- /* Address Encoding (dmp.addr_enc) */
- #define DIRECT_ADDR 0x0
- #define EXTENDED_ADDR 0x1
- /* Address type (internal values) */
- #define ORIGINATOR 1
- #define P1_ADDRESS 2
- #define P2_ADDRESS 3
- #define ORIG_P2_ADDRESS 4
- /* Extended Address Form (dmp_addr_form) */
- #define P1_DIRECT 0x0
- #define P2_DIRECT 0x1
- #define P1_EXTENDED 0x2
- #define P2_EXTENDED 0x3
- #define P1_P2_DIRECT 0x4
- #define P1_DIRECT_P2_EXTENDED 0x5
- #define P1_EXTENDED_P2_DIRECT 0x6
- #define P1_P2_EXTENDED 0x7
- /* Extended Address Type */
- #define ASN1_BER 0x0
- #define ASN1_PER 0x1
- /* Security Policy (dmp_sec_pol) */
- #define NATO 0x4
- #define NATIONAL 0x5
- #define EXTENDED_NATIONAL 0x6
- #define EXTENDED_MISSION 0x7
- #define SEC_CAT_EXT_NONE 0x0
- #define SEC_CAT_EXT_PERMISSIVE 0x1
- #define SEC_CAT_EXT_RESTRICTIVE 0x2
- /* Body Format (dmp.body_format) */
- #define FREE_TEXT 0x0
- #define FREE_TEXT_SUBJECT 0x1
- #define STRUCTURED 0x2
- /* Encoded Information Types */
- #define EIT_BILATERAL 0x3
- /* Compression Algorithm */
- #define ALGORITHM_NONE 0x0
- #define ALGORITHM_ZLIB 0x1
- /* Type of structured id to print */
- #define STRUCT_ID_NONE 0
- #define STRUCT_ID_UINT8 1
- #define STRUCT_ID_UINT16 2
- #define STRUCT_ID_UINT32 3
- #define STRUCT_ID_UINT64 4
- #define STRUCT_ID_STRING 5
- #define STRUCT_ID_ZSTRING 6
- #define NAT_DECODE_NONE 0
- #define NAT_DECODE_DMP 1
- #define NAT_DECODE_THALES 2
- #define IPM_MODIFIER_X400 0
- /* Internal values for not present and reserved time values */
- #define DMP_TIME_NOT_PRESENT -1
- #define DMP_TIME_RESERVED -2
- #define ILLEGAL_FORMAT "<Illegal format>"
- /* Maximum lengths */
- #define MAX_SIC_LEN 30
- void proto_reg_handoff_dmp (void);
- static int proto_dmp = -1;
- static int hf_dmp_id = -1;
- static int hf_mts_id = -1;
- static int hf_ipm_id = -1;
- static int hf_envelope = -1;
- static int hf_envelope_protocol_id = -1;
- static int hf_envelope_version = -1;
- static int hf_envelope_version_value = -1;
- static int hf_envelope_hop_count = -1;
- static int hf_envelope_hop_count_value = -1;
- static int hf_envelope_rec_present = -1;
- static int hf_envelope_addr_enc = -1;
- static int hf_envelope_checksum = -1;
- static int hf_envelope_extensions = -1;
- static int hf_envelope_msg_id_type = -1;
- static int hf_envelope_msg_id_length = -1;
- static int hf_envelope_mts_id_length = -1;
- static int hf_envelope_ipm_id_modifier = -1;
- static int hf_envelope_ipm_id_length = -1;
- static int hf_envelope_mts_id = -1;
- static int hf_envelope_ipm_id = -1;
- static int hf_envelope_type = -1;
- static int hf_envelope_msg_id = -1;
- static int hf_envelope_msg_id_12bit = -1;
- static int hf_envelope_subm_time = -1;
- static int hf_envelope_subm_time_value = -1;
- static int hf_envelope_time_diff_present = -1;
- static int hf_envelope_time_diff = -1;
- static int hf_envelope_time_diff_value = -1;
- static int hf_envelope_flags = -1;
- static int hf_envelope_content_id_discarded = -1;
- static int hf_envelope_recip_reassign_prohib = -1;
- static int hf_envelope_dl_expansion_prohib = -1;
- static int hf_envelope_recipients = -1;
- static int hf_envelope_ext_recipients = -1;
- static int hf_thales_ipm_id_modifier = -1;
- static int hf_extensions = -1;
- static int hf_extension = -1;
- static int hf_extension_header = -1;
- static int hf_extension_more = -1;
- static int hf_extension_length = -1;
- static int hf_extension_data = -1;
- static int hf_message_content = -1;
- static int hf_report_content = -1;
- static int hf_notif_content = -1;
- static int hf_addr_recipient = -1;
- static int hf_addr_originator = -1;
- static int hf_addr_reporting_name = -1;
- static int hf_addr_dl_expanded = -1;
- static int hf_addr_int_rec = -1;
- static int hf_addr_dir_addr_ext = -1;
- static int hf_addr_dir_rec_no = -1;
- static int hf_addr_dir_rec_no1 = -1;
- static int hf_addr_dir_rec_no2 = -1;
- static int hf_addr_dir_rec_no3 = -1;
- static int hf_addr_dir_rec_no_generated = -1;
- static int hf_addr_dir_rep_req1 = -1;
- static int hf_addr_dir_rep_req2 = -1;
- static int hf_addr_dir_rep_req3 = -1;
- static int hf_addr_dir_not_req1 = -1;
- static int hf_addr_dir_not_req2 = -1;
- static int hf_addr_dir_not_req3 = -1;
- static int hf_addr_dir_action = -1;
- static int hf_addr_dir_address = -1;
- static int hf_addr_dir_address1 = -1;
- static int hf_addr_dir_address2 = -1;
- static int hf_addr_dir_address3 = -1;
- static int hf_addr_dir_address_generated = -1;
- static int hf_addr_ext_form = -1;
- static int hf_addr_ext_form_orig_v1 = -1;
- static int hf_addr_ext_form_orig = -1;
- static int hf_addr_ext_action = -1;
- static int hf_addr_ext_rep_req = -1;
- static int hf_addr_ext_not_req = -1;
- static int hf_addr_ext_rec_ext = -1;
- static int hf_addr_ext_rec_no = -1;
- static int hf_addr_ext_rec_no1 = -1;
- static int hf_addr_ext_rec_no2 = -1;
- static int hf_addr_ext_rec_no_generated = -1;
- static int hf_addr_ext_address = -1;
- static int hf_addr_ext_type = -1;
- static int hf_addr_ext_type_ext = -1;
- static int hf_addr_ext_length = -1;
- static int hf_addr_ext_length1 = -1;
- static int hf_addr_ext_length2 = -1;
- static int hf_addr_ext_length_generated = -1;
- static int hf_addr_ext_asn1_ber = -1;
- static int hf_addr_ext_asn1_per = -1;
- static int hf_addr_ext_unknown = -1;
- static int hf_message_body = -1;
- static int hf_message_st_type = -1;
- static int hf_message_precedence = -1;
- static int hf_message_importance = -1;
- static int hf_message_body_format = -1;
- static int hf_message_sec_class_val = -1;
- static int hf_message_sec_pol = -1;
- static int hf_message_heading_flags = -1;
- static int hf_message_auth_users = -1;
- static int hf_message_subject_disc = -1;
- static int hf_message_national_policy_id = -1;
- static int hf_message_mission_policy_id = -1;
- static int hf_message_sec_label = -1;
- static int hf_message_sec_cat_nat = -1;
- static int hf_message_sec_cat_val = -1;
- static int hf_message_sec_cat_cl = -1;
- static int hf_message_sec_cat_cs = -1;
- static int hf_message_sec_cat_ex = -1;
- static int hf_message_sec_cat_ne = -1;
- static int hf_message_sec_cat_permissive = -1;
- static int hf_message_sec_cat_country_code = -1;
- static int hf_message_sec_cat_restrictive = -1;
- static int hf_message_sec_cat_extended = -1;
- static int hf_message_sec_cat_bit0 = -1;
- static int hf_message_sec_cat_bit1 = -1;
- static int hf_message_sec_cat_bit2 = -1;
- static int hf_message_sec_cat_bit3 = -1;
- static int hf_message_sec_cat_bit4 = -1;
- static int hf_message_sec_cat_bit5 = -1;
- static int hf_message_sec_cat_bit6 = -1;
- static int hf_message_sec_cat_bit7 = -1;
- static int hf_message_exp_time = -1;
- static int hf_message_exp_time_val = -1;
- static int hf_message_dtg = -1;
- static int hf_message_dtg_sign = -1;
- static int hf_message_dtg_val = -1;
- static int hf_message_sic = -1;
- static int hf_message_sic_key = -1;
- static int hf_message_sic_key_values = -1;
- static int hf_message_sic_key_type = -1;
- static int hf_message_sic_key_chars = -1;
- static int hf_message_sic_key_num = -1;
- static int hf_message_sic_bitmap = -1;
- static int hf_message_sic_bits = -1;
- static int hf_message_sic_bits_any = -1;
- static int hf_message_subj_id = -1;
- static int hf_message_subj_mts_id = -1;
- static int hf_message_subj_ipm_id = -1;
- static int hf_message_subject = -1;
- static int hf_message_eit = -1;
- static int hf_message_compr = -1;
- static int hf_message_body_data = -1;
- static int hf_message_body_plain = -1;
- static int hf_message_bodyid_uint8 = -1;
- static int hf_message_bodyid_uint16 = -1;
- static int hf_message_bodyid_uint32 = -1;
- static int hf_message_bodyid_uint64 = -1;
- static int hf_message_bodyid_string = -1;
- static int hf_message_bodyid_zstring = -1;
- static int hf_message_body_structured = -1;
- static int hf_message_body_uncompr = -1;
- static int hf_message_body_uncompressed = -1;
- static int hf_delivery_report = -1;
- static int hf_non_delivery_report = -1;
- static int hf_report_type = -1;
- static int hf_report_info_present_dr = -1;
- static int hf_report_addr_enc_dr = -1;
- static int hf_report_del_time = -1;
- static int hf_report_del_time_val = -1;
- static int hf_report_addr_enc_ndr = -1;
- static int hf_report_reason = -1;
- static int hf_report_info_present_ndr = -1;
- static int hf_report_diagn = -1;
- static int hf_report_suppl_info_len = -1;
- static int hf_report_suppl_info = -1;
- static int hf_receipt_notif = -1;
- static int hf_non_receipt_notif = -1;
- static int hf_other_notif = -1;
- static int hf_notif_type = -1;
- static int hf_notif_rec_time = -1;
- static int hf_notif_rec_time_val = -1;
- static int hf_notif_suppl_info_len = -1;
- static int hf_notif_suppl_info = -1;
- static int hf_notif_non_rec_reason = -1;
- static int hf_notif_discard_reason = -1;
- static int hf_notif_on_type = -1;
- static int hf_notif_acp127 = -1;
- static int hf_notif_acp127recip = -1;
- static int hf_ack = -1;
- static int hf_ack_reason = -1;
- static int hf_ack_diagnostic = -1;
- static int hf_ack_recips = -1;
- static int hf_checksum = -1;
- static int hf_checksum_good = -1;
- static int hf_checksum_bad = -1;
- static int hf_analysis_ack_time = -1;
- static int hf_analysis_total_time = -1;
- static int hf_analysis_retrans_time = -1;
- static int hf_analysis_total_retrans_time = -1;
- static int hf_analysis_msg_num = -1;
- static int hf_analysis_msg_missing = -1;
- static int hf_analysis_retrans_no = -1;
- static int hf_analysis_ack_num = -1;
- static int hf_analysis_ack_missing = -1;
- static int hf_analysis_ack_dup_no = -1;
- static int hf_analysis_rep_num = -1;
- static int hf_analysis_rep_time = -1;
- static int hf_analysis_not_num = -1;
- static int hf_analysis_not_time = -1;
- static int hf_analysis_msg_resend_from = -1;
- static int hf_analysis_rep_resend_from = -1;
- static int hf_analysis_not_resend_from = -1;
- static int hf_analysis_ack_resend_from = -1;
- static int hf_reserved_0x01 = -1;
- static int hf_reserved_0x02 = -1;
- static int hf_reserved_0x04 = -1;
- static int hf_reserved_0x07 = -1;
- static int hf_reserved_0x08 = -1;
- static int hf_reserved_0x0F = -1;
- static int hf_reserved_0x1F = -1;
- static int hf_reserved_0x20 = -1;
- static int hf_reserved_0x40 = -1;
- static int hf_reserved_0xC0 = -1;
- static int hf_reserved_0xE0 = -1;
- static int hf_reserved_0x8000 = -1;
- static gint ett_dmp = -1;
- static gint ett_envelope = -1;
- static gint ett_envelope_version = -1;
- static gint ett_envelope_hop_count = -1;
- static gint ett_envelope_rec_present = -1;
- static gint ett_envelope_addr_enc = -1;
- static gint ett_envelope_checksum = -1;
- static gint ett_envelope_extensions = -1;
- static gint ett_envelope_msg_id_type = -1;
- static gint ett_envelope_msg_id = -1;
- static gint ett_envelope_mts_id_length = -1;
- static gint ett_envelope_ipm_id_length = -1;
- static gint ett_envelope_cont_type = -1;
- static gint ett_envelope_subm_time = -1;
- static gint ett_envelope_time_diff = -1;
- static gint ett_envelope_flags = -1;
- static gint ett_envelope_recipients = -1;
- static gint ett_envelope_ext_recipients = -1;
- static gint ett_envelope_addresses = -1;
- static gint ett_address = -1;
- static gint ett_address_direct = -1;
- static gint ett_address_rec_no = -1;
- static gint ett_address_extended = -1;
- static gint ett_address_ext_form = -1;
- static gint ett_address_ext_rec_no = -1;
- static gint ett_address_ext_action = -1;
- static gint ett_address_ext_rep_req = -1;
- static gint ett_address_ext_not_req = -1;
- static gint ett_address_ext_type = -1;
- static gint ett_address_ext_length = -1;
- static gint ett_extensions = -1;
- static gint ett_extension = -1;
- static gint ett_extension_header = -1;
- static gint ett_content = -1;
- static gint ett_message = -1;
- static gint ett_message_st_type = -1;
- static gint ett_message_reserved = -1;
- static gint ett_message_precedence = -1;
- static gint ett_message_importance = -1;
- static gint ett_message_body_format = -1;
- static gint ett_message_sec_class = -1;
- static gint ett_message_sec_pol = -1;
- static gint ett_message_sec_cat = -1;
- static gint ett_message_heading_flags = -1;
- static gint ett_message_exp_time = -1;
- static gint ett_message_dtg = -1;
- static gint ett_message_sic = -1;
- static gint ett_message_sic_key = -1;
- static gint ett_message_sic_bitmap = -1;
- static gint ett_message_sic_bits = -1;
- static gint ett_message_eit = -1;
- static gint ett_message_compr = -1;
- static gint ett_message_body_reserved = -1;
- static gint ett_message_body = -1;
- static gint ett_message_body_uncompr = -1;
- static gint ett_report = -1;
- static gint ett_report_type = -1;
- static gint ett_report_info_present_dr = -1;
- static gint ett_report_info_present_ndr = -1;
- static gint ett_report_addr_enc_dr = -1;
- static gint ett_report_addr_enc_ndr = -1;
- static gint ett_report_reserved = -1;
- static gint ett_report_del_time = -1;
- static gint ett_report_reason = -1;
- static gint ett_report_suppl_info = -1;
- static gint ett_report_diagn = -1;
- static gint ett_notif = -1;
- static gint ett_notif_type = -1;
- static gint ett_notif_rec_time = -1;
- static gint ett_notif_suppl_info = -1;
- static gint ett_notif_acp127recip = -1;
- static gint ett_ack = -1;
- static gint ett_ack_recips = -1;
- static gint ett_checksum = -1;
- static gint ett_analysis = -1;
- static expert_field ei_reserved_value = EI_INIT;
- static expert_field ei_message_sic_illegal = EI_INIT;
- static dissector_handle_t dmp_handle;
- typedef struct _dmp_id_key {
- guint id;
- address src;
- address dst;
- } dmp_id_key;
- typedef struct _dmp_id_val {
- gint msg_type; /* Message type */
- guint prev_msg_id; /* Previous message package num */
- guint msg_id; /* Message package num */
- guint ack_id; /* Acknowledgement package num */
- guint rep_id; /* Report package num */
- guint not_id; /* Notification package num */
- nstime_t msg_time; /* Message receive time */
- nstime_t first_msg_time; /* First message receive time */
- nstime_t prev_msg_time; /* Previous message receive time */
- nstime_t rep_not_msg_time; /* Report or Notification time */
- guint32 msg_resend_count; /* Message resend counter */
- guint32 ack_resend_count; /* Acknowledgement resend counter */
- } dmp_id_val;
- static GHashTable *dmp_id_hash_table = NULL;
- static GHashTable *dmp_long_id_hash_table = NULL;
- /* Global values used in several functions */
- static struct dmp_data {
- gint version;
- gint prot_id;
- gint addr_enc;
- gint checksum;
- gint msg_type;
- gint st_type;
- gint prec;
- gint body_format;
- gint notif_type;
- guchar *struct_id;
- gint32 subm_time;
- guint8 msg_id_type;
- guint8 mts_id_length;
- proto_item *mts_id_item;
- guint8 ack_reason;
- guint16 msg_id;
- guint16 subj_id;
- gboolean extensions;
- gboolean dr;
- gboolean ndr;
- gboolean notif_req;
- gboolean ack_rec_present;
- dmp_id_val *id_val;
- } dmp;
- /* User definable values */
- static range_t *global_dmp_port_range;
- static gint dmp_nat_decode = NAT_DECODE_DMP;
- static gint dmp_local_nation = 0;
- static gboolean use_seq_ack_analysis = TRUE;
- static gboolean dmp_align = FALSE;
- static gboolean dmp_subject_as_id = FALSE;
- static gint dmp_struct_format = STRUCT_ID_NONE;
- static guint dmp_struct_offset = 0;
- static guint dmp_struct_length = 1;
- typedef struct _dmp_security_class_t {
- guint nation;
- guint sec_class;
- char *name;
- } dmp_security_class_t;
- static dmp_security_class_t *dmp_security_classes;
- static guint num_dmp_security_classes;
- static const true_false_string addr_enc = {
- "Use Extended Encoding", "Use Direct Encoding"
- };
- static const true_false_string dtg_sign = {
- "Future", "Past"
- };
- static const true_false_string report_type = {
- "Non-Delivery Report", "Delivery Report"
- };
- static const value_string version_vals[] = {
- { 0x0, "1" },
- { 0x1, "2" },
- { 0x2, "Unknown" },
- { 0x3, "Unknown" },
- { 0x4, "Unknown" },
- { 0x5, "Unknown" },
- { 0x6, "Unknown" },
- { 0x7, "Unknown" },
- { 0, NULL } };
- static const value_string type_vals[] = {
- { 0x0, "Message" },
- { 0x1, "Message (E-Mail)" },
- { 0x2, "Report" },
- { 0x3, "Notification" },
- { 0x4, "Acknowledgement" },
- { 0x5, "Unknown Content" },
- { 0x6, "Unknown Content" },
- { 0x7, "Unknown Content" },
- { 0, NULL } };
- static const value_string msg_id_type_vals[] = {
- { 0x0, "DMP Identifiers only" },
- { 0x1, "X.400 Message Identifiers" },
- { 0x2, "Nationally-defined" },
- { 0x3, "Reserved" },
- { 0, NULL } };
- static const value_string msg_id_length_vals[] = {
- { 0x0, "Full (16 bits)" },
- { 0x1, "Short (12 bits)" },
- { 0, NULL } };
- static const value_string report_vals[] = {
- { 0x0, "No Report" },
- { 0x1, "Non-Delivery Report" },
- { 0x2, "Delivery Report" },
- { 0x3, "Reserved" },
- { 0, NULL } };
- static const value_string report_vals_ext[] = {
- { 0x0, "No Report" },
- { 0x1, "Non-Delivery Report" },
- { 0x2, "Delivery Report" },
- { 0x3, "Recipient Number Extended" },
- { 0, NULL } };
- /* Note the space in front of these values */
- static const value_string report_vals_short[] = {
- { 0x1, " NDR" },
- { 0x2, " DR" },
- { 0, NULL } };
- static const value_string notif_vals[] = {
- { 0x0, "No Notification" },
- { 0x1, "Non-Receipt Notification" },
- { 0x2, "Receipt Notification" },
- { 0x3, "Reserved" },
- { 0, NULL } };
- static const value_string notif_vals_ext[] = {
- { 0x0, "No Notification" },
- { 0x1, "Non-Receipt Notification" },
- { 0x2, "Receipt Notification" },
- { 0x3, "Direct Address Extended" },
- { 0, NULL } };
- /* Note the space in front of these values */
- static const value_string notif_vals_short[] = {
- { 0x1, " NRN" },
- { 0x2, " RN" },
- { 0, NULL } };
- static const value_string notif_type [] = {
- { 0x0, "Receipt Notification (RN)" },
- { 0x1, "Non-Receipt Notification (NRN)" },
- { 0x2, "Other Notification (ON)" },
- { 0x3, "Unknown Notification" },
- { 0, NULL } };
- /* Note the space behind these values */
- static const value_string addr_type_str [] = {
- { ORIGINATOR, "" },
- { P1_ADDRESS, "P1 " },
- { P2_ADDRESS, "P22/P772 " },
- { ORIG_P2_ADDRESS, "P22 " },
- { 0, NULL } };
- static const value_string addr_form [] = {
- { 0x0, "P1 Direct" },
- { 0x1, "P22/P772 Direct" },
- { 0x2, "P1 Extended" },
- { 0x3, "P22/P772 Extended" },
- { 0x4, "P1 and P22/P772 Direct" },
- { 0x5, "P1 Direct and P22/P772 Extended" },
- { 0x6, "P1 Extended and P22/P772 Direct" },
- { 0x7, "P1 and P22/P772 Extended" },
- { 0, NULL } };
- static const value_string addr_form_orig_v1 [] = {
- { 0x0, "Direct" },
- { 0x1, "Reserved" },
- { 0x2, "Extended" },
- { 0x3, "Reserved" },
- { 0x4, "Reserved" },
- { 0x5, "Reserved" },
- { 0x6, "Reserved" },
- { 0x7, "Reserved" },
- { 0, NULL } };
- static const value_string addr_form_orig [] = {
- { 0x0, "Direct" },
- { 0x1, "Reserved" },
- { 0x2, "Extended" },
- { 0x3, "Reserved" },
- { 0x4, "Originator and P2 Direct" },
- { 0x5, "Originator Direct and P2 Extended" },
- { 0x6, "Originator Extended and P2 Direct" },
- { 0x7, "Originator and P2 Extended" },
- { 0, NULL } };
- static const value_string ext_addr_type [] = {
- { 0x0, "ASN.1 BER-encoded OR-name" },
- { 0x1, "ASN.1 PER-encoded OR-name" },
- { 0x2, "Reserved" },
- { 0x3, "Reserved" },
- { 0x4, "Reserved" },
- { 0x5, "Reserved" },
- { 0x6, "Reserved" },
- { 0x7, "Address Length Extended" },
- { 0, NULL } };
- static const value_string ext_addr_type_ext [] = {
- { 0x0, "ASN.1 BER-encoded OR-name" },
- { 0x1, "ASN.1 PER-encoded OR-name" },
- { 0x2, "Reserved" },
- { 0x3, "Reserved" },
- { 0x4, "Reserved" },
- { 0x5, "Reserved" },
- { 0x6, "Reserved" },
- { 0x7, "Reserved" },
- { 0, NULL } };
- static const value_string ext_addr_type_short [] = {
- { 0x0, "OR-name (BER)" },
- { 0x1, "OR-name (PER)" },
- { 0x2, "Reserved" },
- { 0x3, "Reserved" },
- { 0x4, "Reserved" },
- { 0x5, "Reserved" },
- { 0x6, "Reserved" },
- { 0x7, "Reserved" },
- { 0, NULL } };
- static const value_string message_type_vals[] = {
- { 0x0, "Operation" },
- { 0x1, "Project" },
- { 0x2, "Exercise" },
- { 0x3, "Drill" },
- { 0, NULL } };
- static const value_string precedence[] = {
- { 0x0, "Deferred" },
- { 0x1, "Routine" },
- { 0x2, "Priority" },
- { 0x3, "Immediate" },
- { 0x4, "Flash" },
- { 0x5, "Override" },
- { 0x6, "Priority, Info Precedence: Routine" },
- { 0x7, "Immediate, Info Precedence: Routine" },
- { 0, NULL } };
- static const value_string importance[] = {
- { 0x0, "Low" },
- { 0x1, "Reserved" },
- { 0x2, "Normal" },
- { 0x3, "Reserved" },
- { 0x4, "High" },
- { 0x5, "Reserved" },
- { 0x6, "Reserved" },
- { 0x7, "Reserved" },
- { 0, NULL } };
- static const value_string sec_class[] = {
- { 0x0, "Unmarked" },
- { 0x1, "Unclassified" },
- /* { 0x2, "Reserved" }, */
- { 0x3, "Restricted" },
- /* { 0x4, "Reserved" }, */
- { 0x5, "Confidential" },
- { 0x6, "Secret" },
- { 0x7, "Top secret" },
- { 0, NULL } };
- static const value_string sec_pol[] = {
- { 0x0, "Network defined" },
- { 0x1, "Network defined" },
- { 0x2, "Network defined" },
- { 0x3, "Network defined" },
- { 0x4, "NATO" },
- { 0x5, "National (nation of local server)" },
- { 0x6, "Extended, National" },
- { 0x7, "Extended, Mission Defined" },
- { 0, NULL } };
- #define MAX_NATIONAL_VALUES 56
- /* Will be built in build_national_strings() */
- static value_string nat_pol_id[MAX_NATIONAL_VALUES+1];
- /* For name we use the ISO 3166-1 Alfa-3 value for the country,
- * for description we use the Country Name and
- * for value we use the DMP value for National Policy Identifier.
- */
- static const enum_val_t dmp_national_values[MAX_NATIONAL_VALUES+1] = {
- { "???", "None", 0x00 },
- { "alb", "Albania", 0x1B },
- { "arm", "Armenia", 0x20 },
- { "aut", "Austria", 0x21 },
- { "aze", "Azerbaijan", 0x22 },
- { "blr", "Belarus", 0x23 },
- { "bel", "Belgium", 0x01 },
- { "bih", "Bosnia and Hercegowina", 0x24 },
- { "bgr", "Bulgaria", 0x02 },
- { "can", "Canada", 0x03 },
- { "hrv", "Croatia", 0x1C },
- { "cze", "Czech Republic", 0x04 },
- { "dnk", "Denmark", 0x05 },
- { "est", "Estonia", 0x06 },
- { "eapc", "Euro-Atlantic Partnership Council (EAPC)", 0x3A },
- { "eu", "European Union (EU)", 0x3B },
- { "fin", "Finland", 0x25 },
- { "mkd", "Former Yugoslav Republic of Macedonia", 0x26 },
- { "fra", "France", 0x07 },
- { "geo", "Georgia", 0x27 },
- { "deu", "Germany", 0x08 },
- { "grc", "Greece", 0x09 },
- { "hun", "Hungary", 0x0A },
- { "isl", "Iceland", 0x0B },
- { "isaf", "International Security Assistance Force (ISAF)", 0x3C },
- { "irl", "Ireland", 0x28 },
- { "ita", "Italy", 0x0C },
- { "kaz", "Kazakhstan", 0x29 },
- { "kgz", "Kyrgyztan", 0x2A },
- { "lva", "Latvia", 0x0D },
- { "ltu", "Lithuania", 0x0E },
- { "lux", "Luxembourg", 0x0F },
- { "mlt", "Malta", 0x2B },
- { "mda", "Moldova", 0x2C },
- { "mne", "Montenegro", 0x2D },
- { "nld", "Netherlands", 0x10 },
- { "nor", "Norway", 0x11 },
- { "pfp", "Partnership for Peace (PfP)", 0x3D },
- { "pol", "Poland", 0x12 },
- { "ptr", "Portugal", 0x13 },
- { "rou", "Romania", 0x14 },
- { "rus", "Russian Federation", 0x2E },
- { "srb", "Serbia", 0x2F },
- { "svk", "Slovakia", 0x15 },
- { "svn", "Slovenia", 0x16 },
- { "esp", "Spain", 0x17 },
- { "swe", "Sweden", 0x30 },
- { "che", "Switzerland", 0x31 },
- { "tjk", "Tajikistan", 0x32 },
- { "tur", "Turkey", 0x18 },
- { "tkm", "Turkmenistan", 0x33 },
- { "gbr", "United Kingdom", 0x19 },
- { "usa", "United States", 0x1A },
- { "ukr", "Ukraine", 0x34 },
- { "uzb", "Uzbekistan", 0x35 },
- { "weu", "Western European Union (WEU)", 0x3E },
- { NULL, NULL, 0 }
- };
- static const value_string ext_sec_cat[] = {
- { 0x0, "Not present" },
- { 0x1, "Permissive category follows" },
- { 0x2, "Restrictive category follows" },
- { 0x3, "Reserved" },
- { 0, NULL } };
- static const value_string sic_key_type[] = {
- { 0xc, "2 or more 3-character SICs" },
- { 0xd, "1 or more 3-to-8 character SICs" },
- { 0, NULL } };
- static const true_false_string sic_key_chars = {
- "Any", "[A-Z0-9] only"
- };
- static const value_string sic_key_num[] = {
- { 0, "1" },
- { 1, "2" },
- { 2, "3" },
- { 3, "4" },
- { 4, "5" },
- { 5, "6" },
- { 6, "7" },
- { 7, "8" },
- { 0, NULL } };
- static const value_string sic_bit_vals[] = {
- { 0, "length:6, bytes:4" },
- { 1, "length:6, bytes:4" },
- { 2, "length:6, bytes:4" },
- { 3, "length:6, bytes:4" },
- { 4, "length:6, bytes:4" },
- { 5, "length:6, bytes:4" },
- { 6, "length:6, bytes:4" },
- { 7, "length:6, bytes:4" },
- { 8, "length:6, bytes:4" },
- { 9, "reserved" },
- { 10, "length:5, bytes:4" },
- { 11, "length:8, bytes:6" },
- { 12, "length:4, bytes:3" },
- { 13, "length:4, bytes:3" },
- { 14, "length:7, bytes:5" },
- { 15, "length:7, bytes:5" },
- { 0, NULL } };
- static const value_string sic_bit_any_vals[] = {
- { 0, "length:5, bytes:4" },
- { 1, "length:5, bytes:4" },
- { 2, "length:5, bytes:4" },
- { 3, "length:5, bytes:4" },
- { 4, "length:5, bytes:4" },
- { 5, "length:5, bytes:4" },
- { 6, "length:5, bytes:4" },
- { 7, "length:5, bytes:4" },
- { 8, "length:5, bytes:4" },
- { 9, "length:8, bytes:7" },
- { 10, "length:4, bytes:4" },
- { 11, "length:7, bytes:6" },
- { 12, "length:6, bytes:5" },
- { 13, "length:6, bytes:5" },
- { 14, "length:6, bytes:5" },
- { 15, "length:6, bytes:5" },
- { 0, NULL } };
- static const value_string body_format_vals[] = {
- { 0x0, "Free text" },
- { 0x1, "Free text including subject" },
- { 0x2, "Structured" },
- { 0x3, "Reserved" },
- { 0, NULL } };
- static const value_string eit_vals[] = {
- { 0x0, "Empty" },
- { 0x1, "IA5-text" },
- { 0x2, "General text" },
- { 0x3, "Bilaterally defined (binary data)" },
- { 0x4, "AdatP-3" },
- { 0x5, "Reserved" },
- { 0x6, "Reserved" },
- { 0x7, "Reserved" },
- { 0, NULL } };
- static const value_string compression_vals[] = {
- { 0x0, "No compression" },
- { 0x1, "ZLib compressed" },
- { 0x2, "Reserved" },
- { 0x3, "Reserved" },
- { 0, NULL } };
- static const value_string ack_reason [] = {
- { 0x00, "Successful, positive acknowledgement" },
- { 0x01, "Unspecified error" },
- { 0x02, "Checksum incorrect" },
- { 0, NULL } };
- static const value_string non_del_reason [] = {
- { 0x3D, "Unknown reason" },
- { 0x3E, "Reason code greater than 0x3c (60)" },
- { 0x3F, "Reserved" },
- { 0, NULL } };
- static const value_string non_del_diagn [] = {
- { 0x7C, "Diagnostic not specified" },
- { 0x7D, "Unknown diagnostic" },
- { 0x7E, "Diagnostic code greater than 0x7b (123)" },
- { 0x7F, "Reserved" },
- { 0, NULL } };
- static const value_string discard_reason [] = {
- { 0xFE, "Discard Reason absent" },
- { 0xFF, "Reserved" },
- { 0, NULL } };
- static const value_string on_type [] = {
- { 0x00, "acp127-nn" },
- { 0x01, "acp127-pn" },
- { 0x02, "acp127-tn" },
- { 0, NULL } };
- static const value_string ack_msg_type [] = {
- { STANAG, " (message)" },
- { IPM, " (e-mail)" },
- { REPORT, " (report)" },
- { NOTIF, " (notif)" },
- { ACK, " (ack)" },
- { 0, NULL } };
- static const enum_val_t struct_id_options[] = {
- { "none", "None", STRUCT_ID_NONE },
- { "1byte", "1 Byte value", STRUCT_ID_UINT8 },
- { "2byte", "2 Byte value", STRUCT_ID_UINT16 },
- { "4byte", "4 Byte value", STRUCT_ID_UINT32 },
- { "8byte", "8 Byte value", STRUCT_ID_UINT64 },
- { "fstring", "Fixed text string", STRUCT_ID_STRING },
- { "zstring", "Zero terminated text string", STRUCT_ID_ZSTRING },
- { NULL, NULL, 0 }
- };
- static const enum_val_t national_decoding[] = {
- { "none", "None (raw data)", NAT_DECODE_NONE },
- { "dmp", "As for regular", NAT_DECODE_DMP },
- { "thales", "Thales XOmail", NAT_DECODE_THALES },
- { NULL, NULL, 0 }
- };
- static const value_string ipm_id_modifier[] = {
- { 0x0, "X.400 IPM Identifier" },
- { 0x1, "Nationally-defined" },
- { 0x2, "Nationally-defined" },
- { 0x3, "Nationally-defined" },
- { 0, NULL }
- };
- static const value_string thales_ipm_id_modifier[] = {
- { 0x0, "X.400 IPM Identifier" },
- { 0x1, "3 or 5 digits" },
- { 0x2, "4 digits" },
- { 0x3, "5 digits" },
- { 0, NULL }
- };
- UAT_VS_DEF(dmp_security_class, nation, dmp_security_class_t, guint, 0, "None")
- UAT_DEC_CB_DEF(dmp_security_class, sec_class, dmp_security_class_t)
- UAT_CSTRING_CB_DEF(dmp_security_class, name, dmp_security_class_t)
- static void *
- dmp_class_copy_cb(void *dest, const void *orig, size_t len _U_)
- {
- dmp_security_class_t *u = (dmp_security_class_t *)dest;
- const dmp_security_class_t *o = (const dmp_security_class_t *)orig;
- u->nation = o->nation;
- u->sec_class = o->sec_class;
- u->name = g_strdup(o->name);
- return dest;
- }
- static void
- dmp_class_free_cb(void *r)
- {
- dmp_security_class_t *u = (dmp_security_class_t *)r;
- g_free(u->name);
- }
- static gchar *dmp_national_sec_class (guint nation, guint dmp_sec_class)
- {
- guint i;
- for (i = 0; i < num_dmp_security_classes; i++) {
- dmp_security_class_t *u = &(dmp_security_classes[i]);
- if (u->nation == nation && u->sec_class == dmp_sec_class) {
- return u->name;
- }
- }
- return NULL;
- }
- static void build_national_strings (void)
- {
- gint i = 0;
- /*
- ** We use values from dmp_national_values to build value_string for nat_pol_id.
- */
- while (dmp_national_values[i].name && i < MAX_NATIONAL_VALUES) {
- nat_pol_id[i].value = dmp_national_values[i].value;
- nat_pol_id[i].strptr = dmp_national_values[i].description;
- i++;
- }
- nat_pol_id[i].value = 0;
- nat_pol_id[i].strptr = NULL;
- }
- static const gchar *get_nat_pol_id_short (gint nation)
- {
- gint i = 0;
- while (dmp_national_values[i].name) {
- if (dmp_national_values[i].value == nation) {
- return dmp_national_values[i].name;
- }
- i++;
- }
- return "???";
- }
- static const gchar *msg_type_to_str (void)
- {
- const gchar *msg_type;
- gboolean have_msg = FALSE;
- switch (dmp.msg_type) {
- case STANAG:
- /* Include message type and precedence */
- msg_type = ep_strdup_printf ("%s (%s) [%s]",
- val_to_str_const (dmp.msg_type, type_vals, "Unknown"),
- val_to_str_const (dmp.st_type, message_type_vals, "Unknown"),
- (dmp.prec == 0x6 || dmp.prec == 0x7) ?
- val_to_str_const (dmp.prec-4, precedence, "Unknown") :
- val_to_str_const (dmp.prec, precedence, "Unknown"));
- break;
- case IPM:
- /* Include importance */
- msg_type = ep_strdup_printf ("%s [%s]",
- val_to_str_const (dmp.msg_type, type_vals, "Unknown"),
- val_to_str_const (dmp.prec, importance, "Unknown"));
- break;
- case REPORT:
- /* Include report types included */
- msg_type = ep_strdup_printf ("Report (%s%s%s)",
- dmp.dr ? "DR" : "", (dmp.dr && dmp.ndr) ? " and " : "",
- dmp.ndr ? "NDR" : "");
- break;
- case NOTIF:
- msg_type = val_to_str_const (dmp.notif_type, notif_type, "Unknown");
- break;
- case ACK:
- /* If we have msg_time we have a matching packet */
- have_msg = (dmp.id_val &&
- (dmp.id_val->msg_time.secs>0 || dmp.id_val->msg_time.nsecs>0));
- msg_type = ep_strdup_printf ( "Acknowledgement%s%s",
- have_msg ? val_to_str (dmp.id_val->msg_type, ack_msg_type,
- " (unknown:%d)") : "",
- dmp.ack_reason ? " [negative]" : "");
- break;
- default:
- msg_type = "Unknown";
- break;
- }
- return msg_type;
- }
- static const gchar *non_del_reason_str (guint32 value)
- {
- if (value < 0x3D) {
- /* Standard values according to P1 */
- return val_to_str_const (value, p1_NonDeliveryReasonCode_vals, "Unknown");
- } else {
- return val_to_str_const (value, non_del_reason, "Unknown");
- }
- }
- static const gchar *non_del_diagn_str (guint32 value)
- {
- if (value < 0x7C) {
- /* Standard values according to P1 */
- return val_to_str_const (value, p1_NonDeliveryDiagnosticCode_vals, "Unknown");
- } else {
- return val_to_str_const (value, non_del_diagn, "Unknown");
- }
- }
- static const gchar *nrn_reason_str (guint32 value)
- {
- /* Standard values according to P22 */
- return val_to_str_const (value, p22_NonReceiptReasonField_vals, "Reserved");
- }
- static const gchar *discard_reason_str (guint32 value)
- {
- if (value < 0xFE) {
- /* Standard values according to P22 */
- return val_to_str_const (value, p22_DiscardReasonField_vals, "Reserved");
- } else {
- return val_to_str_const (value, discard_reason, "Unknown");
- }
- }
- /* Ref chapter 6.2.8.10 TimeDifference */
- static gint32 dmp_dec_time_diff (guint8 dmp_time_diff)
- {
- gint32 time_diff = 0;
- if (dmp_time_diff <= 0x01) {
- /* Reserved - low value */
- time_diff = DMP_TIME_RESERVED;
- } else if (dmp_time_diff <= 0x1D) {
- /* Number of 2-second units (2-58 seconds) */
- time_diff = dmp_time_diff * 2;
- } else if (dmp_time_diff <= 0x91) {
- /* Number of 15-second units (1 min - 29 min 45 sec) */
- time_diff = (dmp_time_diff - 0x1D + 3) * 15;
- } else if (dmp_time_diff <= 0xDF) {
- /* Number of 5-minute units (30 min - 6 hours 55 min) */
- time_diff = (dmp_time_diff - 0x91 + 5) * 5*60;
- } else if (dmp_time_diff <= 0xF7) {
- /* Number of 30-minute units (7 hours - 18 hours 30 min) */
- time_diff = (dmp_time_diff - 0xDF + 7) * 30*60;
- } else {
- /* Reserved - high value */
- time_diff = DMP_TIME_RESERVED;
- }
- return time_diff;
- }
- /*
- * Ref chapter 6.3.7.2.10 ExpiryTime
- * and chapter 6.3.9.2.2 DeliveryTime
- */
- static gint32 dmp_dec_exp_del_time (guint8 timev, gboolean expiry_time)
- {
- gint32 time_value = 0;
- if (expiry_time && (timev == 0x00)) {
- /* No expiry time */
- time_value = DMP_TIME_NOT_PRESENT;
- } else if (timev <= 0x1D) {
- /* Number of 2-second units (2-58 seconds) */
- time_value = timev * 2;
- } else if (timev <= 0x91) {
- /* Number of 15-second units (1 min - 29 min 45 sec) */
- time_value = (timev - 0x1D + 3) * 15;
- } else if (timev <= 0xBB) {
- /* Number of 5-minute units (30 min - 3 hours 55 min) */
- time_value = (timev - 0x91 + 5) * 5*60;
- } else if (timev <= 0xE3) {
- /* Number of 30-minute units (4 hours - 23 hours 30 min) */
- time_value = (timev - 0xBB + 7) * 30*60;
- } else if (timev < 0xFF) {
- /* Number of 2-hour units (24 - 78 hours) */
- time_value = (timev - 0xE3 + 11) * 2*3600;
- } else {
- /* Reserved */
- time_value = DMP_TIME_RESERVED;
- }
- return time_value;
- }
- static gint32 dmp_dec_exp_time (guint8 expiry_time)
- {
- return dmp_dec_exp_del_time (expiry_time, TRUE);
- }
- static gint32 dmp_dec_del_time (guint8 delivery_time)
- {
- return dmp_dec_exp_del_time (delivery_time, FALSE);
- }
- /* Ref chapter 6.3.7.2.11 DTG */
- static gint32 dmp_dec_dtg (guint32 dtg)
- {
- gint32 value;
- if (dtg == 0x00) {
- /* Not present */
- value = DMP_TIME_NOT_PRESENT;
- } else if (dtg <= 0x3C) {
- /* Number of minutes (0-59 min) */
- value = (dtg - 1) * 60;
- } else if (dtg <= 0x64) {
- /* Number of 15-minute units (1 hour - 10 hours 45 min) */
- value = (dtg - 0x3C + 3) * 15 * 60;
- } else if (dtg < 0x7F) {
- /* Number of hours (11-36 hours) */
- value = (dtg - 0x64 + 10) * 3600;
- } else {
- /* Reserved */
- value = DMP_TIME_RESERVED;
- }
- return value;
- }
- /*
- * Ref chapter 7.10.11.1 Submission time
- *
- * start_time (current time)
- * delta1 = E (encoded submission time)
- * delta2 = C (encoded current time)
- * 0x01C2 = Pn + 15min (maximum point for S1)
- * 0x7E38 = Pn+1 - 15min (minimum point for S3)
- * 0x7FF8 = Pn+1 (length of P (period))
- */
- static gint32 dmp_dec_subm_time (guint16 delta1, gint32 start_time)
- {
- gint32 subm_time = start_time;
- guint16 delta2;
- delta2 = (guint16) ((subm_time / 2) % 0x7FF8);
- if ((delta1 < 0x01C2) && (delta2 >= delta1 + 0x7E38)) {
- subm_time += 2 * (0x7FF8 - delta2 + delta1);
- } else if ((delta1 >= 0x01C2) && (delta2 < delta1 - 0x01C2)) {
- subm_time -= 2 * (0x7FF8 - delta1 + delta2);
- } else {
- subm_time -= 2 * (delta2 - delta1);
- }
- return subm_time;
- }
- /* Ref chapter 6.3.7.2.12 SIC */
- static gboolean dmp_dec_xbyte_sic (guint64 bin, gchar *sic,
- guint8 no_char, gboolean any)
- {
- gboolean failure = FALSE;
- gdouble multiplier;
- guint8 i;
- guint64 p, tmp;
- if (no_char >= MAX_SIC_LEN) {
- /* Illegal length */
- g_snprintf (sic, MAX_SIC_LEN, "Illegal length: %d", no_char);
- return TRUE;
- }
- if (any) {
- multiplier = 74.0;
- } else {
- multiplier = 36.0;
- }
- for (i = 0; i < no_char; i++) {
- p = (guint64) pow (multiplier, no_char - 1 - i);
- tmp = bin / p;
- bin -= tmp * p;
- sic[i] = (gchar) tmp;
- if (sic[i] <= 9) {
- sic[i] += '0';
- } else if (sic[i] <= 35) {
- sic[i] += ('A' - 10);
- } else if (!any) {
- sic[i] = '*';
- failure = TRUE;
- } else if (sic[i] <= 61) {
- sic[i] += ('a' - 36);
- } else if (sic[i] == 62) {
- sic[i] = '\'';
- } else if (sic[i] == 63) {
- sic[i] = '(';
- } else if (sic[i] == 64) {
- sic[i] = ')';
- } else if (sic[i] == 65) {
- sic[i] = '+';
- } else if (sic[i] == 66) {
- sic[i] = ',';
- } else if (sic[i] == 67) {
- sic[i] = '-';
- } else if (sic[i] == 68) {
- sic[i] = '.';
- } else if (sic[i] == 69) {
- sic[i] = '/';
- } else if (sic[i] == 70) {
- sic[i] = ':';
- } else if (sic[i] == 71) {
- sic[i] = '=';
- } else if (sic[i] == 72) {
- sic[i] = '?';
- } else if (sic[i] == 73) {
- sic[i] = ' ';
- } else {
- sic[i] = '*';
- failure = TRUE;
- }
- }
- sic[i] = '\0';
- return failure;
- }
- static guint dmp_id_hash (gconstpointer k)
- {
- dmp_id_key *dmpx=(dmp_id_key *)k;
- return dmpx->id;
- }
- static gint dmp_id_hash_equal (gconstpointer k1, gconstpointer k2)
- {
- dmp_id_key *dmp1=(dmp_id_key *)k1;
- dmp_id_key *dmp2=(dmp_id_key *)k2;
- if (dmp1->id != dmp2->id)
- return 0;
- return (ADDRESSES_EQUAL (&dmp1->src, &dmp2->src) &&
- ADDRESSES_EQUAL (&dmp1->dst, &dmp2->dst));
- }
- static void register_dmp_id (packet_info *pinfo, guint8 reason)
- {
- dmp_id_val *dmp_data = NULL, *pkg_data = NULL;
- dmp_id_key *dmp_key = NULL;
- nstime_t msg_time;
- guint msg_id = 0;
- if (pinfo->flags.in_error_pkt) {
- /* No analysis of error packets */
- return;
- }
- nstime_set_zero(&msg_time);
- dmp_key = se_new (dmp_id_key);
- if (!pinfo->fd->flags.visited &&
- (dmp.msg_type == REPORT || dmp.msg_type == NOTIF))
- {
- /* Try to match corresponding message */
- dmp_key->id = (guint) dmp.subj_id;
- SE_COPY_ADDRESS(&dmp_key->src, &(pinfo->dst));
- SE_COPY_ADDRESS(&dmp_key->dst, &(pinfo->src));
- dmp_data = (dmp_id_val *) g_hash_table_lookup (dmp_id_hash_table, dmp_key);
- if (dmp_data) {
- /* Found message */
- if (dmp_data->prev_msg_id > 0) {
- msg_id = dmp_data->prev_msg_id;
- } else {
- msg_id = dmp_data->msg_id;
- }
- msg_time = dmp_data->msg_time;
- }
- }
- if (dmp.msg_type == ACK) {
- dmp_key->id = (guint) dmp.subj_id;
- SE_COPY_ADDRESS(&dmp_key->src, &(pinfo->dst));
- SE_COPY_ADDRESS(&dmp_key->dst, &(pinfo->src));
- } else {
- dmp_key->id = (guint) dmp.msg_id;
- SE_COPY_ADDRESS(&dmp_key->src, &(pinfo->src));
- SE_COPY_ADDRESS(&dmp_key->dst, &(pinfo->dst));
- }
- dmp_data = (dmp_id_val *) g_hash_table_lookup (dmp_id_hash_table, dmp_key);
- if (!pinfo->fd->flags.visited) {
- if (dmp_data) {
- if (dmp.msg_type == ACK) {
- /* Only save this data if positive ack */
- if (reason == 0) {
- if (dmp_data->ack_id == 0) {
- /* Only save reference to first ACK */
- dmp_data->ack_id = pinfo->fd->num;
- } else {
- /* Only count when resending */
- dmp_data->ack_resend_count++;
- }
- }
- } else {
- /* Message resent */
- dmp_data->msg_resend_count++;
- dmp_data->prev_msg_id = pinfo->fd->num;
- dmp_data->prev_msg_time = dmp_data->msg_time;
- dmp_data->msg_time = pinfo->fd->abs_ts;
- }
- } else {
- /* New message */
- dmp_data = se_new0 (dmp_id_val);
- dmp_data->msg_type = dmp.msg_type;
- if (dmp.msg_type == ACK) {
- /* No matching message for this ack */
- dmp_data->ack_id = pinfo->fd->num;
- } else {
- dmp_data->first_msg_time = pinfo->fd->abs_ts;
- dmp_data->msg_time = pinfo->fd->abs_ts;
- if (dmp.msg_type == REPORT) {
- dmp_data->rep_id = pinfo->fd->num;
- dmp_data->msg_id = msg_id;
- dmp_data->rep_not_msg_time = msg_time;
- } else if (dmp.msg_type == NOTIF) {
- dmp_data->not_id = pinfo->fd->num;
- dmp_data->msg_id = msg_id;
- dmp_data->rep_not_msg_time = msg_time;
- } else {
- dmp_data->msg_id = pinfo->fd->num;
- }
- g_hash_table_insert (dmp_id_hash_table, dmp_key, dmp_data);
- }
- }
- pkg_data = se_new (dmp_id_val);
- *pkg_data = *dmp_data;
- p_add_proto_data (pinfo->fd, proto_dmp, 0, pkg_data);
- } else {
- /* Fetch last values from data saved in packet */
- pkg_data = (dmp_id_val *)p_get_proto_data (pinfo->fd, proto_dmp, 0);
- if (dmp_data && pkg_data && dmp.msg_type != ACK && pkg_data->ack_id == 0) {
- pkg_data->ack_id = dmp_data->ack_id;
- }
- }
- DISSECTOR_ASSERT (pkg_data);
- dmp.id_val = pkg_data;
- }
- static void dmp_add_seq_ack_analysis (tvbuff_t *tvb, packet_info *pinfo,
- proto_tree *dmp_tree, gint offset)
- {
- proto_tree *analysis_tree = NULL;
- proto_item *en = NULL, *eh = NULL;
- nstime_t ns;
- if (dmp.msg_type > ACK || (dmp.msg_type < ACK && !dmp.checksum) ||
- dmp.id_val == NULL || pinfo->flags.in_error_pkt)
- {
- /* No need for seq/ack analysis */
- return;
- }
- en = proto_tree_add_text (dmp_tree, tvb, 0, 0, "SEQ/ACK analysis");
- PROTO_ITEM_SET_GENERATED (en);
- analysis_tree = proto_item_add_subtree (en, ett_analysis);
- if ((dmp.msg_type == STANAG) || (dmp.msg_type == IPM) ||
- (dmp.msg_type == REPORT) || (dmp.msg_type == NOTIF)) {
- if (dmp.id_val->ack_id) {
- en = proto_tree_add_uint (analysis_tree, hf_analysis_ack_num, tvb,
- 0, 0, dmp.id_val->ack_id);
- PROTO_ITEM_SET_GENERATED (en);
- if (!dmp.checksum) {
- proto_item_append_text (en, " (unexpected)");
- expert_add_info_format (pinfo, en, PI_SEQUENCE, PI_NOTE,
- "Unexpected ACK");
- }
- } else if (dmp.checksum && !dmp.id_val->msg_resend_count) {
- en = proto_tree_add_item (analysis_tree, hf_analysis_ack_missing, tvb, offset, 0, ENC_NA);
- if (pinfo->fd->flags.visited) {
- /* We do not know this on first visit and we do not want to
- add a entry in the "Expert Severity Info" for this note */
- expert_add_info_format (pinfo, en, PI_SEQUENCE, PI_NOTE,
- "Acknowledgement missing");
- PROTO_ITEM_SET_GENERATED (en);
- }
- }
- if (dmp.msg_type == REPORT) {
- if (dmp.id_val->msg_id) {
- en = proto_tree_add_uint (analysis_tree, hf_analysis_msg_num,
- tvb, 0, 0, dmp.id_val->msg_id);
- PROTO_ITEM_SET_GENERATED (en);
- nstime_delta (&ns, &pinfo->fd->abs_ts, &dmp.id_val->rep_not_msg_time);
- en = proto_tree_add_time (analysis_tree, hf_analysis_rep_time,
- tvb, 0, 0, &ns);
- PROTO_ITEM_SET_GENERATED (en);
- } else {
- en = proto_tree_add_item (analysis_tree, hf_analysis_msg_missing, tvb, 0, 0, ENC_NA);
- PROTO_ITEM_SET_GENERATED (en);
- expert_add_info_format (pinfo, en, PI_SEQUENCE, PI_NOTE,
- "Message missing");
- }
- } else if (dmp.msg_type == NOTIF) {
- if (dmp.id_val->msg_id) {
- en = proto_tree_add_uint (analysis_tree, hf_analysis_msg_num,
- tvb, 0, 0, dmp.id_val->msg_id);
- PROTO_ITEM_SET_GENERATED (en);
- nstime_delta (&ns, &pinfo->fd->abs_ts, &dmp.id_val->rep_not_msg_time);
- en = proto_tree_add_time (analysis_tree, hf_analysis_not_time,
- tvb, 0, 0, &ns);
- PROTO_ITEM_SET_GENERATED (en);
- } else {
- en = proto_tree_add_item (analysis_tree, hf_analysis_msg_missing, tvb, 0, 0, ENC_NA);
- PROTO_ITEM_SET_GENERATED (en);
- expert_add_info_format (pinfo, en, PI_SEQUENCE, PI_NOTE,
- "Message missing");
- }
- }
- if (dmp.id_val->msg_resend_count) {
- en = proto_tree_add_uint (analysis_tree, hf_analysis_retrans_no,
- tvb, 0, 0, dmp.id_val->msg_resend_count);
- PROTO_ITEM_SET_GENERATED (en);
- expert_add_info_format (pinfo, en, PI_SEQUENCE, PI_NOTE,
- "Retransmission #%d",
- dmp.id_val->msg_resend_count);
- if (dmp.msg_type == REPORT) {
- en = proto_tree_add_uint (analysis_tree, hf_analysis_rep_resend_from,
- tvb, 0, 0, dmp.id_val->rep_id);
- } else if (dmp.msg_type == NOTIF) {
- en = proto_tree_add_uint (analysis_tree, hf_analysis_not_resend_from,
- tvb, 0, 0, dmp.id_val->not_id);
- } else {
- en = proto_tree_add_uint (analysis_tree, hf_analysis_msg_resend_from,
- tvb, 0, 0, dmp.id_val->msg_id);
- }
- PROTO_ITEM_SET_GENERATED (en);
- nstime_delta (&ns, &pinfo->fd->abs_ts, &dmp.id_val->prev_msg_time);
- en = proto_tree_add_time (analysis_tree, hf_analysis_retrans_time,
- tvb, 0, 0, &ns);
- PROTO_ITEM_SET_GENERATED (en);
- nstime_delta (&ns, &pinfo->fd->abs_ts, &dmp.id_val->first_msg_time);
- eh = proto_tree_add_time (analysis_tree, hf_analysis_total_retrans_time,
- tvb, 0, 0, &ns);
- PROTO_ITEM_SET_GENERATED (eh);
- if (dmp.id_val->first_msg_time.secs == dmp.id_val->prev_msg_time.secs &&
- dmp.id_val->first_msg_time.nsecs == dmp.id_val->prev_msg_time.nsecs) {
- /* Time values does not differ, hide the total time */
- PROTO_ITEM_SET_HIDDEN (eh);
- }
- }
- } else if (dmp.msg_ty…
Large files files are truncated, but you can click here to view the full file