ImportTextDialog::ImportTextDialog(QWidget *parent) : QDialog(parent), ti_ui_(new Ui::ImportTextDialog), import_info_() { int encap; int i; ti_ui_->setupUi(this); memset(&import_info_, 0, sizeof(import_info_)); ok_button_ = ti_ui_->buttonBox->button(QDialogButtonBox::Ok); ok_button_->setEnabled(false); #ifdef Q_OS_MAC // The grid layout squishes each line edit otherwise. int le_height = ti_ui_->textFileLineEdit->sizeHint().height(); ti_ui_->ethertypeLineEdit->setMinimumHeight(le_height); ti_ui_->protocolLineEdit->setMinimumHeight(le_height); ti_ui_->sourcePortLineEdit->setMinimumHeight(le_height); ti_ui_->destinationPortLineEdit->setMinimumHeight(le_height); ti_ui_->tagLineEdit->setMinimumHeight(le_height); ti_ui_->ppiLineEdit->setMinimumHeight(le_height); #endif on_dateTimeLineEdit_textChanged(ti_ui_->dateTimeLineEdit->text()); for (i = 0; i < ti_ui_->headerGridLayout->count(); i++) { QRadioButton *rb = qobject_cast<QRadioButton *>(ti_ui_->headerGridLayout->itemAt(i)->widget()); if (rb) encap_buttons_.append(rb); } /* Scan all Wiretap encapsulation types */ import_info_.encapsulation = WTAP_ENCAP_ETHERNET; for (encap = import_info_.encapsulation; encap < wtap_get_num_encap_types(); encap++) { /* Check if we can write to a PCAP file * * Exclude wtap encapsulations that require a pseudo header, * because we won't setup one from the text we import and * wiretap doesn't allow us to write 'raw' frames */ if ((wtap_wtap_encap_to_pcap_encap(encap) > 0) && !wtap_encap_requires_phdr(encap)) { const char *name; /* If it has got a name */ if ((name = wtap_encap_string(encap))) { ti_ui_->encapComboBox->addItem(name, QVariant(encap)); } } } ti_ui_->encapComboBox->model()->sort(0); }
void proto_register_frame(void) { static hf_register_info hf[] = { { &hf_frame_arrival_time, { "Arrival Time", "frame.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, "Absolute time when this frame was captured", HFILL }}, { &hf_frame_shift_offset, { "Time shift for this packet", "frame.offset_shift", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, "Time shift applied to this packet", HFILL }}, { &hf_frame_arrival_time_epoch, { "Epoch Time", "frame.time_epoch", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, "Epoch time when this frame was captured", HFILL }}, { &hf_frame_time_delta, { "Time delta from previous captured frame", "frame.time_delta", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_frame_time_delta_displayed, { "Time delta from previous displayed frame", "frame.time_delta_displayed", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_frame_time_relative, { "Time since reference or first frame", "frame.time_relative", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, "Time relative to time reference or first frame", HFILL }}, { &hf_frame_time_reference, { "This is a Time Reference frame", "frame.ref_time", FT_NONE, BASE_NONE, NULL, 0x0, "This frame is a Time Reference frame", HFILL }}, { &hf_frame_number, { "Frame Number", "frame.number", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_len, { "Frame length on the wire", "frame.len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_capture_len, { "Frame length stored into the capture file", "frame.cap_len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_md5_hash, { "Frame MD5 Hash", "frame.md5_hash", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_frame_p2p_dir, { "Point-to-Point Direction", "frame.p2p_dir", FT_INT8, BASE_DEC, VALS(p2p_dirs), 0x0, NULL, HFILL }}, { &hf_link_number, { "Link Number", "frame.link_nr", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_file_off, { "File Offset", "frame.file_off", FT_INT64, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_marked, { "Frame is marked", "frame.marked", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Frame is marked in the GUI", HFILL }}, { &hf_frame_ignored, { "Frame is ignored", "frame.ignored", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Frame is ignored by the dissectors", HFILL }}, { &hf_frame_protocols, { "Protocols in frame", "frame.protocols", FT_STRING, BASE_NONE, NULL, 0x0, "Protocols carried by this frame", HFILL }}, { &hf_frame_color_filter_name, { "Coloring Rule Name", "frame.coloring_rule.name", FT_STRING, BASE_NONE, NULL, 0x0, "The frame matched the coloring rule with this name", HFILL }}, { &hf_frame_color_filter_text, { "Coloring Rule String", "frame.coloring_rule.string", FT_STRING, BASE_NONE, NULL, 0x0, "The frame matched this coloring rule string", HFILL }}, { &hf_frame_interface_id, { "Interface id", "frame.interface_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_pack_flags, { "Packet flags", "frame.packet_flags", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_frame_pack_direction, { "Direction", "frame.packet_flags_direction", FT_UINT32, BASE_HEX, VALS(packet_word_directions), PACKET_WORD_DIRECTION_MASK, NULL, HFILL }}, { &hf_frame_pack_reception_type, { "Reception type", "frame.packet_flags_reception_type", FT_UINT32, BASE_DEC, VALS(packet_word_reception_types), PACKET_WORD_RECEPTION_TYPE_MASK, NULL, HFILL }}, { &hf_frame_pack_fcs_length, { "FCS length", "frame.packet_flags_fcs_length", FT_UINT32, BASE_DEC, NULL, PACKET_WORD_FCS_LENGTH_MASK, NULL, HFILL }}, { &hf_frame_pack_reserved, { "Reserved", "frame.packet_flags_reserved", FT_UINT32, BASE_DEC, NULL, PACKET_WORD_RESERVED_MASK, NULL, HFILL }}, { &hf_frame_pack_crc_error, { "CRC error", "frame.packet_flags_crc_error", FT_BOOLEAN, 32, TFS(&tfs_set_notset), PACKET_WORD_CRC_ERR_MASK, NULL, HFILL }}, { &hf_frame_pack_wrong_packet_too_long_error, { "Packet too long error", "frame.packet_flags_packet_too_error", FT_BOOLEAN, 32, TFS(&tfs_set_notset), PACKET_WORD_PACKET_TOO_LONG_ERR_MASK, NULL, HFILL }}, { &hf_frame_pack_wrong_packet_too_short_error, { "Packet too short error", "frame.packet_flags_packet_too_short_error", FT_BOOLEAN, 32, TFS(&tfs_set_notset), PACKET_WORD_PACKET_TOO_SHORT_ERR_MASK, NULL, HFILL }}, { &hf_frame_pack_wrong_inter_frame_gap_error, { "Wrong interframe gap error", "frame.packet_flags_wrong_inter_frame_gap_error", FT_BOOLEAN, 32, TFS(&tfs_set_notset), PACKET_WORD_WRONG_INTER_FRAME_GAP_ERR_MASK, NULL, HFILL }}, { &hf_frame_pack_unaligned_frame_error, { "Unaligned frame error", "frame.packet_flags_unaligned_frame_error", FT_BOOLEAN, 32, TFS(&tfs_set_notset), PACKET_WORD_UNALIGNED_FRAME_ERR_MASK, NULL, HFILL }}, { &hf_frame_pack_start_frame_delimiter_error, { "Start frame delimiter error", "frame.packet_flags_start_frame_delimiter_error", FT_BOOLEAN, 32, TFS(&tfs_set_notset), PACKET_WORD_START_FRAME_DELIMITER_ERR_MASK, NULL, HFILL }}, { &hf_frame_pack_preamble_error, { "Preamble error", "frame.packet_flags_preamble_error", FT_BOOLEAN, 32, TFS(&tfs_set_notset), PACKET_WORD_PREAMBLE_ERR_MASK, NULL, HFILL }}, { &hf_frame_pack_symbol_error, { "Symbol error", "frame.packet_flags_symbol_error", FT_BOOLEAN, 32, TFS(&tfs_set_notset), PACKET_WORD_SYMBOL_ERR_MASK, NULL, HFILL }}, { &hf_comments_text, { "Comment", "frame.comment", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, }; static hf_register_info hf_encap = { &hf_frame_wtap_encap, { "Encapsulation type", "frame.encap_type", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}; static gint *ett[] = { &ett_frame, &ett_flags, &ett_comments }; static ei_register_info ei[] = { { &ei_comments_text, { "frame.comment.expert", PI_COMMENTS_GROUP, PI_COMMENT, "Formatted comment", EXPFILL }}, { &ei_arrive_time_out_of_range, { "frame.time_invalid", PI_SEQUENCE, PI_NOTE, "Arrival Time: Fractional second out of range (0-1000000000)", EXPFILL }}, }; module_t *frame_module; expert_module_t* expert_frame; if (hf_encap.hfinfo.strings == NULL) { int encap_count = wtap_get_num_encap_types(); value_string *arr; int i; hf_encap.hfinfo.strings = arr = g_new(value_string, encap_count+1); for (i = 0; i < encap_count; i++) { arr[i].value = i; arr[i].strptr = wtap_encap_string(i); } arr[encap_count].value = 0; arr[encap_count].strptr = NULL; } wtap_encap_dissector_table = register_dissector_table("wtap_encap", "Wiretap encapsulation type", FT_UINT32, BASE_DEC); wtap_fts_rec_dissector_table = register_dissector_table("wtap_fts_rec", "Wiretap file type for file-type-specific records", FT_UINT32, BASE_DEC); proto_frame = proto_register_protocol("Frame", "Frame", "frame"); proto_pkt_comment = proto_register_protocol("Packet comments", "Pkt_Comment", "pkt_comment"); proto_register_field_array(proto_frame, hf, array_length(hf)); proto_register_field_array(proto_frame, &hf_encap, 1); proto_register_subtree_array(ett, array_length(ett)); expert_frame = expert_register_protocol(proto_frame); expert_register_field_array(expert_frame, ei, array_length(ei)); register_dissector("frame",dissect_frame,proto_frame); /* You can't disable dissection of "Frame", as that would be tantamount to not doing any dissection whatsoever. */ proto_set_cant_toggle(proto_frame); /* Our preferences */ frame_module = prefs_register_protocol(proto_frame, NULL); prefs_register_bool_preference(frame_module, "show_file_off", "Show File Offset", "Show offset of frame in capture file", &show_file_off); prefs_register_bool_preference(frame_module, "force_docsis_encap", "Treat all frames as DOCSIS frames", "Treat all frames as DOCSIS Frames", &force_docsis_encap); prefs_register_bool_preference(frame_module, "generate_md5_hash", "Generate an MD5 hash of each frame", "Whether or not MD5 hashes should be generated for each frame, useful for finding duplicate frames.", &generate_md5_hash); prefs_register_bool_preference(frame_module, "generate_epoch_time", "Generate an epoch time entry for each frame", "Whether or not an Epoch time entry should be generated for each frame.", &generate_epoch_time); prefs_register_bool_preference(frame_module, "generate_bits_field", "Show the number of bits in the frame", "Whether or not the number of bits in the frame should be shown.", &generate_bits_field); frame_tap=register_tap("frame"); }
void proto_register_frame(void) { static hf_register_info hf[] = { { &hf_frame_arrival_time, { "Arrival Time", "frame.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, "Absolute time when this frame was captured", HFILL }}, { &hf_frame_shift_offset, { "Time shift for this packet", "frame.offset_shift", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, "Time shift applied to this packet", HFILL }}, { &hf_frame_arrival_time_epoch, { "Epoch Time", "frame.time_epoch", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, "Epoch time when this frame was captured", HFILL }}, { &hf_frame_time_invalid, { "Arrival Timestamp invalid", "frame.time_invalid", FT_NONE, BASE_NONE, NULL, 0x0, "The timestamp from the capture is out of the valid range", HFILL }}, { &hf_frame_time_delta, { "Time delta from previous captured frame", "frame.time_delta", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_frame_time_delta_displayed, { "Time delta from previous displayed frame", "frame.time_delta_displayed", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_frame_time_relative, { "Time since reference or first frame", "frame.time_relative", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, "Time relative to time reference or first frame", HFILL }}, { &hf_frame_time_reference, { "This is a Time Reference frame", "frame.ref_time", FT_NONE, BASE_NONE, NULL, 0x0, "This frame is a Time Reference frame", HFILL }}, { &hf_frame_number, { "Frame Number", "frame.number", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_len, { "Frame length on the wire", "frame.len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_capture_len, { "Frame length stored into the capture file", "frame.cap_len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_md5_hash, { "Frame MD5 Hash", "frame.md5_hash", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_frame_p2p_dir, { "Point-to-Point Direction", "frame.p2p_dir", FT_INT8, BASE_DEC, VALS(p2p_dirs), 0x0, NULL, HFILL }}, { &hf_link_number, { "Link Number", "frame.link_nr", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_file_off, { "File Offset", "frame.file_off", FT_INT64, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_frame_marked, { "Frame is marked", "frame.marked", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Frame is marked in the GUI", HFILL }}, { &hf_frame_ignored, { "Frame is ignored", "frame.ignored", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Frame is ignored by the dissectors", HFILL }}, { &hf_frame_protocols, { "Protocols in frame", "frame.protocols", FT_STRING, BASE_NONE, NULL, 0x0, "Protocols carried by this frame", HFILL }}, { &hf_frame_color_filter_name, { "Coloring Rule Name", "frame.coloring_rule.name", FT_STRING, BASE_NONE, NULL, 0x0, "The frame matched the coloring rule with this name", HFILL }}, { &hf_frame_color_filter_text, { "Coloring Rule String", "frame.coloring_rule.string", FT_STRING, BASE_NONE, NULL, 0x0, "The frame matched this coloring rule string", HFILL }}, { &hf_frame_interface_id, { "Interface id", "frame.interface_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_comments_text, { "Comment", "frame.comment", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, }; static hf_register_info hf_encap = { &hf_frame_wtap_encap, { "Encapsulation type", "frame.encap_type", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}; static gint *ett[] = { &ett_frame, &ett_comments }; module_t *frame_module; if (hf_encap.hfinfo.strings == NULL) { int encap_count = wtap_get_num_encap_types(); value_string *arr; int i; hf_encap.hfinfo.strings = arr = g_new(value_string, encap_count+1); for (i = 0; i < encap_count; i++) { arr[i].value = i; arr[i].strptr = wtap_encap_string(i); } arr[encap_count].value = 0; arr[encap_count].strptr = NULL; } wtap_encap_dissector_table = register_dissector_table("wtap_encap", "Wiretap encapsulation type", FT_UINT32, BASE_DEC); proto_frame = proto_register_protocol("Frame", "Frame", "frame"); proto_pkt_comment = proto_register_protocol("Packet comments", "Pkt_Comment", "pkt_comment"); proto_register_field_array(proto_frame, hf, array_length(hf)); proto_register_field_array(proto_frame, &hf_encap, 1); proto_register_subtree_array(ett, array_length(ett)); register_dissector("frame",dissect_frame,proto_frame); /* You can't disable dissection of "Frame", as that would be tantamount to not doing any dissection whatsoever. */ proto_set_cant_toggle(proto_frame); proto_short = proto_register_protocol("Short Frame", "Short frame", "short"); proto_malformed = proto_register_protocol("Malformed Packet", "Malformed packet", "malformed"); proto_unreassembled = proto_register_protocol( "Unreassembled Fragmented Packet", "Unreassembled fragmented packet", "unreassembled"); /* "Short Frame", "Malformed Packet", and "Unreassembled Fragmented Packet" aren't really protocols, they're error indications; disabling them makes no sense. */ proto_set_cant_toggle(proto_short); proto_set_cant_toggle(proto_malformed); proto_set_cant_toggle(proto_unreassembled); /* Our preferences */ frame_module = prefs_register_protocol(proto_frame, NULL); prefs_register_bool_preference(frame_module, "show_file_off", "Show File Offset", "Show offset of frame in capture file", &show_file_off); prefs_register_bool_preference(frame_module, "force_docsis_encap", "Treat all frames as DOCSIS frames", "Treat all frames as DOCSIS Frames", &force_docsis_encap); prefs_register_bool_preference(frame_module, "generate_md5_hash", "Generate an MD5 hash of each frame", "Whether or not MD5 hashes should be generated for each frame, useful for finding duplicate frames.", &generate_md5_hash); prefs_register_bool_preference(frame_module, "generate_epoch_time", "Generate an epoch time entry for each frame", "Whether or not an Epoch time entry should be generated for each frame.", &generate_epoch_time); prefs_register_bool_preference(frame_module, "generate_bits_field", "Show the number of bits in the frame", "Whether or not the number of bits in the frame should be shown.", &generate_bits_field); frame_tap=register_tap("frame"); }