Define a collection of bits for different types of capture file comments.
For each capture file type, have a bitset of comment types supported by that capture file type. Add a Wiretap routine that, for a given file type, returns the bitset of comment types it supports. Have wtap_get_savable_file_types() take a bitset of comment types that need to be supported by the file types it returns. Replace cf_has_comments() with a routine that returns a bitset of capture file comment types in the capture file. Use those routines in the capture file dialogs; don't wire in the notion that pcap-NG supports all comment types and no other file formats support any comment types. (That's currently true, but we don't want to wire that in as being forever true.) svn path=/trunk/; revision=48689
This commit is contained in:
parent
2deedfb1e1
commit
82a602d697
14
file.c
14
file.c
@ -3858,12 +3858,18 @@ cf_update_packet_comment(capture_file *cf, frame_data *fdata, gchar *comment)
|
||||
}
|
||||
|
||||
/*
|
||||
* Does this capture file have any comments?
|
||||
* What types of comments does this capture file have?
|
||||
*/
|
||||
gboolean
|
||||
cf_has_comments(capture_file *cf)
|
||||
guint32
|
||||
cf_comment_types(capture_file *cf)
|
||||
{
|
||||
return (cf_read_shb_comment(cf) != NULL || cf->packet_comment_count != 0);
|
||||
guint32 comment_types = 0;
|
||||
|
||||
if (cf_read_shb_comment(cf) != NULL)
|
||||
comment_types |= WTAP_COMMENT_PER_SECTION;
|
||||
if (cf->packet_comment_count != 0)
|
||||
comment_types |= WTAP_COMMENT_PER_PACKET;
|
||||
return comment_types;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
6
file.h
6
file.h
@ -652,12 +652,12 @@ void cf_update_capture_comment(capture_file *cf, gchar *comment);
|
||||
void cf_update_packet_comment(capture_file *cf, frame_data *fdata, gchar *comment);
|
||||
|
||||
/**
|
||||
* Does this capture file have any comments?
|
||||
* What types of comments does this file have?
|
||||
*
|
||||
* @param cf the capture file
|
||||
* @return TRUE if it does, FALSE if it doesn't
|
||||
* @return bitset of WTAP_COMMENT_ values
|
||||
*/
|
||||
gboolean cf_has_comments(capture_file *cf);
|
||||
guint32 cf_comment_types(capture_file *cf);
|
||||
|
||||
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
|
||||
WS_DLL_PUBLIC
|
||||
|
@ -80,11 +80,12 @@
|
||||
#endif
|
||||
|
||||
static void do_file_save(capture_file *cf, gboolean dont_reopen);
|
||||
static void file_save_as_cmd(capture_file *cf, gboolean must_support_comments,
|
||||
static void file_save_as_cmd(capture_file *cf,
|
||||
gboolean must_support_all_comments,
|
||||
gboolean dont_reopen);
|
||||
static void file_select_file_type_cb(GtkWidget *w, gpointer data);
|
||||
static int set_file_type_list(GtkWidget *combo_box, capture_file *cf,
|
||||
gboolean must_support_comments);
|
||||
gboolean must_support_all_comments);
|
||||
static gboolean test_file_close(capture_file *cf, gboolean from_quit,
|
||||
const char *before_what);
|
||||
|
||||
@ -1289,31 +1290,29 @@ file_close_cmd_cb(GtkWidget *widget _U_, gpointer data _U_) {
|
||||
static check_savability_t
|
||||
check_save_with_comments(capture_file *cf)
|
||||
{
|
||||
guint32 comment_types;
|
||||
GArray *savable_file_types;
|
||||
GtkWidget *msg_dialog;
|
||||
gint response;
|
||||
|
||||
/* Do we have any comments? */
|
||||
if (!cf_has_comments(cf)) {
|
||||
/* No. Let the save happen; no comments to delete. */
|
||||
/* What types of comments do we have? */
|
||||
comment_types = cf_comment_types(cf);
|
||||
|
||||
/* Does the file's format support all the comments we have? */
|
||||
if (wtap_dump_supports_comment_types(cf->cd_t, comment_types)) {
|
||||
/* Yes. Let the save happen; we can save all the comments, so
|
||||
there's no need to delete them. */
|
||||
return SAVE;
|
||||
}
|
||||
|
||||
/* OK, we have comments. Can we write them out in the file's format?
|
||||
/* No. Are there formats in which we can write this file that
|
||||
supports all the comments in this file? */
|
||||
savable_file_types = wtap_get_savable_file_types(cf->cd_t, cf->linktypes,
|
||||
comment_types);
|
||||
if (savable_file_types != NULL) {
|
||||
g_array_free(savable_file_types, TRUE);
|
||||
|
||||
XXX - for now, we "know" that pcap-ng is the only format for which
|
||||
we support comments. We should really ask Wiretap what the
|
||||
format in question supports (and handle different types of
|
||||
comments, some but not all of which some file formats might
|
||||
not support). */
|
||||
if (cf->cd_t == WTAP_FILE_PCAPNG) {
|
||||
/* Yes - the file is a pcap-ng file. Let the save happen; we can
|
||||
save the comments, so no need to delete them. */
|
||||
return SAVE;
|
||||
}
|
||||
|
||||
/* Is pcap-ng one of the formats in which we can write this file? */
|
||||
if (wtap_dump_can_write_encaps(WTAP_FILE_PCAPNG, cf->linktypes)) {
|
||||
/* Yes. Ooffer the user a choice of "Save in a format that
|
||||
/* Yes. Offer the user a choice of "Save in a format that
|
||||
supports comments", "Discard comments and save in the
|
||||
file's own format", or "Cancel", meaning "don't bother
|
||||
saving the file at all". */
|
||||
@ -1511,14 +1510,23 @@ file_save_cmd_cb(GtkWidget *w _U_, gpointer data _U_) {
|
||||
Returns the default file type. */
|
||||
static int
|
||||
set_file_type_list(GtkWidget *combo_box, capture_file *cf,
|
||||
gboolean must_support_comments)
|
||||
gboolean must_support_all_comments)
|
||||
{
|
||||
guint32 required_comment_types;
|
||||
GArray *savable_file_types;
|
||||
guint i;
|
||||
int ft;
|
||||
int default_ft = -1;
|
||||
|
||||
savable_file_types = wtap_get_savable_file_types(cf->cd_t, cf->linktypes);
|
||||
/* What types of comments do we have to support? */
|
||||
if (must_support_all_comments)
|
||||
required_comment_types = cf_comment_types(cf); /* all the ones the file has */
|
||||
else
|
||||
required_comment_types = 0; /* none of them */
|
||||
|
||||
/* What types of file can we save this file as? */
|
||||
savable_file_types = wtap_get_savable_file_types(cf->cd_t, cf->linktypes,
|
||||
required_comment_types);
|
||||
|
||||
if (savable_file_types != NULL) {
|
||||
/* OK, we have at least one file type we can save this file as.
|
||||
@ -1526,10 +1534,6 @@ set_file_type_list(GtkWidget *combo_box, capture_file *cf,
|
||||
place.) Add them all to the combo box. */
|
||||
for (i = 0; i < savable_file_types->len; i++) {
|
||||
ft = g_array_index(savable_file_types, int, i);
|
||||
if (must_support_comments) {
|
||||
if (ft != WTAP_FILE_PCAPNG)
|
||||
continue;
|
||||
}
|
||||
if (default_ft == -1)
|
||||
default_ft = ft; /* first file type is the default */
|
||||
ws_combo_box_append_text_and_pointer(GTK_COMBO_BOX(combo_box),
|
||||
@ -1572,27 +1576,28 @@ file_select_file_type_cb(GtkWidget *w, gpointer parent_arg)
|
||||
static check_savability_t
|
||||
gtk_check_save_as_with_comments(GtkWidget *w, capture_file *cf, int file_type)
|
||||
{
|
||||
guint32 comment_types;
|
||||
GArray *savable_file_types;
|
||||
GtkWidget *msg_dialog;
|
||||
gint response;
|
||||
|
||||
/* Do we have any comments? */
|
||||
if (!cf_has_comments(cf)) {
|
||||
/* No. Let the save happen; no comments to delete. */
|
||||
/* What types of comments do we have? */
|
||||
comment_types = cf_comment_types(cf);
|
||||
|
||||
/* Does the file's format support all the comments we have? */
|
||||
if (wtap_dump_supports_comment_types(file_type, comment_types)) {
|
||||
/* Yes. Let the save happen; we can save all the comments, so
|
||||
there's no need to delete them. */
|
||||
return SAVE;
|
||||
}
|
||||
|
||||
/* XXX - for now, we "know" that pcap-ng is the only format for which
|
||||
we support comments. We should really ask Wiretap what the
|
||||
format in question supports (and handle different types of
|
||||
comments, some but not all of which some file formats might
|
||||
not support). */
|
||||
if (file_type == WTAP_FILE_PCAPNG) {
|
||||
/* Yes - they selected pcap-ng. Let the save happen; we can
|
||||
save the comments, so no need to delete them. */
|
||||
return SAVE;
|
||||
}
|
||||
/* No. Is pcap-ng one of the formats in which we can write this file? */
|
||||
if (wtap_dump_can_write_encaps(WTAP_FILE_PCAPNG, cf->linktypes)) {
|
||||
/* No. Are there formats in which we can write this file that
|
||||
supports all the comments in this file? */
|
||||
savable_file_types = wtap_get_savable_file_types(file_type, cf->linktypes,
|
||||
comment_types);
|
||||
if (savable_file_types != NULL) {
|
||||
g_array_free(savable_file_types, TRUE);
|
||||
|
||||
/* Yes. Offer the user a choice of "Save in a format that
|
||||
supports comments", "Discard comments and save in the
|
||||
format you selected", or "Cancel", meaning "don't bother
|
||||
@ -1693,7 +1698,7 @@ gtk_check_save_as_with_comments(GtkWidget *w, capture_file *cf, int file_type)
|
||||
/* "Save as" */
|
||||
static gboolean
|
||||
gtk_save_as_file(GtkWidget *w _U_, capture_file *cf, GString *file_name, int *file_type,
|
||||
gboolean *compressed, gboolean must_support_comments)
|
||||
gboolean *compressed, gboolean must_support_all_comments)
|
||||
{
|
||||
GtkWidget *file_save_as_w;
|
||||
GtkWidget *main_vb, *ft_hb, *ft_lb, *ft_combo_box, *compressed_cb;
|
||||
@ -1731,7 +1736,7 @@ gtk_save_as_file(GtkWidget *w _U_, capture_file *cf, GString *file_name, int *fi
|
||||
ft_combo_box = ws_combo_box_new_text_and_pointer();
|
||||
|
||||
/* Generate the list of file types we can save. */
|
||||
default_ft = set_file_type_list(ft_combo_box, cf, must_support_comments);
|
||||
default_ft = set_file_type_list(ft_combo_box, cf, must_support_all_comments);
|
||||
gtk_box_pack_start(GTK_BOX(ft_hb), ft_combo_box, FALSE, FALSE, 0);
|
||||
gtk_widget_show(ft_combo_box);
|
||||
g_object_set_data(G_OBJECT(file_save_as_w), E_FILE_TYPE_COMBO_BOX_KEY, ft_combo_box);
|
||||
@ -1841,7 +1846,7 @@ file_add_extension(GString *file_name, int file_type, gboolean compressed) {
|
||||
*/
|
||||
|
||||
static void
|
||||
file_save_as_cmd(capture_file *cf, gboolean must_support_comments,
|
||||
file_save_as_cmd(capture_file *cf, gboolean must_support_all_comments,
|
||||
gboolean dont_reopen)
|
||||
{
|
||||
GString *file_name = g_string_new("");
|
||||
@ -1857,12 +1862,12 @@ file_save_as_cmd(capture_file *cf, gboolean must_support_comments,
|
||||
for (;;) {
|
||||
#ifdef USE_WIN32_FILE_DIALOGS
|
||||
if (win32_save_as_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), cf,
|
||||
file_name, &file_type, &compressed, must_support_comments)) {
|
||||
file_name, &file_type, &compressed, must_support_all_comments)) {
|
||||
/* They discarded comments, so redraw the packet details window
|
||||
to reflect any packets that no longer have comments. */
|
||||
packet_list_queue_draw();
|
||||
#else /* USE_WIN32_FILE_DIALOGS */
|
||||
if (gtk_save_as_file(top_level, cf, file_name, &file_type, &compressed, must_support_comments)) {
|
||||
if (gtk_save_as_file(top_level, cf, file_name, &file_type, &compressed, must_support_all_comments)) {
|
||||
#endif /* USE_WIN32_FILE_DIALOGS */
|
||||
|
||||
/* If the file has comments, does the format the user selected
|
||||
@ -1896,7 +1901,7 @@ file_save_as_cmd(capture_file *cf, gboolean must_support_comments,
|
||||
so run the dialog again, to let the user decide
|
||||
whether to save in one of those formats or give up. */
|
||||
discard_comments = FALSE;
|
||||
must_support_comments = TRUE;
|
||||
must_support_all_comments = TRUE;
|
||||
continue;
|
||||
|
||||
case CANCELLED:
|
||||
|
@ -135,27 +135,28 @@ check_savability_t CaptureFileDialog::checkSaveAsWithComments(QWidget *
|
||||
return CANCELLED;
|
||||
return win32_check_save_as_with_comments(parent->effectiveWinId(), cf, file_type);
|
||||
#else // Q_WS_WIN
|
||||
guint32 comment_types;
|
||||
GArray *savable_file_types;
|
||||
QMessageBox msg_dialog;
|
||||
int response;
|
||||
|
||||
/* Do we have any comments? */
|
||||
if (!cf_has_comments(cf)) {
|
||||
/* No. Let the save happen; no comments to delete. */
|
||||
/* What types of comments do we have? */
|
||||
comment_types = cf_comment_types(cf);
|
||||
|
||||
/* Does the file's format support all the comments we have? */
|
||||
if (wtap_dump_supports_comment_types(file_type, comment_types)) {
|
||||
/* Yes. Let the save happen; we can save all the comments, so
|
||||
there's no need to delete them. */
|
||||
return SAVE;
|
||||
}
|
||||
|
||||
/* XXX - for now, we "know" that pcap-ng is the only format for which
|
||||
we support comments. We should really ask Wiretap what the
|
||||
format in question supports (and handle different types of
|
||||
comments, some but not all of which some file formats might
|
||||
not support). */
|
||||
if (file_type == WTAP_FILE_PCAPNG) {
|
||||
/* Yes - they selected pcap-ng. Let the save happen; we can
|
||||
save the comments, so no need to delete them. */
|
||||
return SAVE;
|
||||
}
|
||||
/* No. Is pcap-ng one of the formats in which we can write this file? */
|
||||
if (wtap_dump_can_write_encaps(WTAP_FILE_PCAPNG, cf->linktypes)) {
|
||||
/* No. Are there formats in which we can write this file that
|
||||
supports all the comments in this file? */
|
||||
savable_file_types = wtap_get_savable_file_types(file_type, cf->linktypes,
|
||||
comment_types);
|
||||
if (savable_file_types != NULL) {
|
||||
g_array_free(savable_file_types, TRUE);
|
||||
|
||||
QPushButton *default_button;
|
||||
/* Yes. Offer the user a choice of "Save in a format that
|
||||
supports comments", "Discard comments and save in the
|
||||
@ -250,11 +251,11 @@ int CaptureFileDialog::open(QString &file_name) {
|
||||
return (int) wof_status;
|
||||
}
|
||||
|
||||
check_savability_t CaptureFileDialog::saveAs(QString &file_name, bool must_support_comments) {
|
||||
check_savability_t CaptureFileDialog::saveAs(QString &file_name, bool must_support_all_comments) {
|
||||
GString *fname = g_string_new(file_name.toUtf8().constData());
|
||||
gboolean wsf_status;
|
||||
|
||||
wsf_status = win32_save_as_file(parentWidget()->effectiveWinId(), cap_file_, fname, &file_type_, &compressed_, must_support_comments);
|
||||
wsf_status = win32_save_as_file(parentWidget()->effectiveWinId(), cap_file_, fname, &file_type_, &compressed_, must_support_all_comments);
|
||||
file_name = fname->str;
|
||||
|
||||
g_string_free(fname, TRUE);
|
||||
@ -518,12 +519,12 @@ int CaptureFileDialog::open(QString &file_name) {
|
||||
}
|
||||
}
|
||||
|
||||
check_savability_t CaptureFileDialog::saveAs(QString &file_name, bool must_support_comments) {
|
||||
check_savability_t CaptureFileDialog::saveAs(QString &file_name, bool must_support_all_comments) {
|
||||
setWindowTitle(tr("Wireshark: Save Capture File As"));
|
||||
// XXX There doesn't appear to be a way to use setNameFilters without restricting
|
||||
// what the user can select. We might want to use our own combobox instead and
|
||||
// let the user select anything.
|
||||
setNameFilters(buildFileSaveAsTypeList(must_support_comments));
|
||||
setNameFilters(buildFileSaveAsTypeList(must_support_all_comments));
|
||||
setAcceptMode(QFileDialog::AcceptSave);
|
||||
setLabelText(FileType, tr("Save as:"));
|
||||
|
||||
@ -605,13 +606,24 @@ int CaptureFileDialog::merge(QString &file_name) {
|
||||
}
|
||||
}
|
||||
|
||||
QStringList CaptureFileDialog::buildFileSaveAsTypeList(bool must_support_comments) {
|
||||
QStringList CaptureFileDialog::buildFileSaveAsTypeList(bool must_support_all_comments) {
|
||||
QStringList filters;
|
||||
guint32 required_comment_types;
|
||||
GArray *savable_file_types;
|
||||
guint i;
|
||||
|
||||
type_hash_.clear();
|
||||
savable_file_types = wtap_get_savable_file_types(cap_file_->cd_t, cap_file_->linktypes);
|
||||
|
||||
/* What types of comments do we have to support? */
|
||||
if (must_support_all_comments)
|
||||
required_comment_types = cf_comment_types(cap_file_); /* all the ones the file has */
|
||||
else
|
||||
required_comment_types = 0; /* none of them */
|
||||
|
||||
/* What types of file can we save this file as? */
|
||||
savable_file_types = wtap_get_savable_file_types(cap_file_->cd_t,
|
||||
cap_file_->linktypes,
|
||||
required_comment_types);
|
||||
|
||||
if (savable_file_types != NULL) {
|
||||
QString file_type;
|
||||
@ -621,10 +633,6 @@ QStringList CaptureFileDialog::buildFileSaveAsTypeList(bool must_support_comment
|
||||
place.) Add them all to the combo box. */
|
||||
for (i = 0; i < savable_file_types->len; i++) {
|
||||
ft = g_array_index(savable_file_types, int, i);
|
||||
if (must_support_comments) {
|
||||
if (ft != WTAP_FILE_PCAPNG)
|
||||
continue;
|
||||
}
|
||||
if (default_ft_ < 1)
|
||||
default_ft_ = ft; /* first file type is the default */
|
||||
file_type = fileType(ft);
|
||||
|
@ -110,8 +110,7 @@ static void range_handle_wm_initdialog(HWND dlg_hwnd, packet_range_t *range);
|
||||
static void range_handle_wm_command(HWND dlg_hwnd, HWND ctrl, WPARAM w_param, packet_range_t *range);
|
||||
|
||||
static TCHAR *build_file_open_type_list(void);
|
||||
static TCHAR *build_file_save_type_list(GArray *savable_file_types,
|
||||
gboolean must_support_comments);
|
||||
static TCHAR *build_file_save_type_list(GArray *savable_file_types);
|
||||
|
||||
static int g_filetype;
|
||||
static gboolean g_compressed;
|
||||
@ -238,29 +237,27 @@ win32_open_file (HWND h_wnd, GString *file_name, GString *display_filter) {
|
||||
check_savability_t
|
||||
win32_check_save_as_with_comments(HWND parent, capture_file *cf, int file_type)
|
||||
{
|
||||
guint32 comment_types;
|
||||
GArray *savable_file_types;
|
||||
gint response;
|
||||
|
||||
/* Do we have any comments? */
|
||||
if (!cf_has_comments(cf)) {
|
||||
/* No. Let the save happen; no comments to delete. */
|
||||
/* What types of comments do we have? */
|
||||
comment_types = cf_comment_types(cf);
|
||||
|
||||
/* Does the file's format support all the comments we have? */
|
||||
if (wtap_dump_supports_comment_types(cf->cd_t, comment_types)) {
|
||||
/* Yes. Let the save happen; we can save all the comments, so
|
||||
there's no need to delete them. */
|
||||
return SAVE;
|
||||
}
|
||||
|
||||
/* OK, we have comments. Can we write them out in the selected
|
||||
format?
|
||||
/* No. Are there formats in which we can write this file that
|
||||
supports all the comments in this file? */
|
||||
savable_file_types = wtap_get_savable_file_types(cf->cd_t, cf->linktypes,
|
||||
comment_types);
|
||||
if (savable_file_types != NULL) {
|
||||
g_array_free(savable_file_types, TRUE);
|
||||
|
||||
XXX - for now, we "know" that pcap-ng is the only format for which
|
||||
we support comments. We should really ask Wiretap what the
|
||||
format in question supports (and handle different types of
|
||||
comments, some but not all of which some file formats might
|
||||
not support). */
|
||||
if (file_type == WTAP_FILE_PCAPNG) {
|
||||
/* Yes - they selected pcap-ng. Let the save happen; we can
|
||||
save the comments, so no need to delete them. */
|
||||
return SAVE;
|
||||
}
|
||||
/* No. Is pcap-ng one of the formats in which we can write this file? */
|
||||
if (wtap_dump_can_write_encaps(WTAP_FILE_PCAPNG, cf->linktypes)) {
|
||||
/* Yes. Offer the user a choice of "Save in a format that
|
||||
supports comments", "Discard comments and save in the
|
||||
format you selected", or "Cancel", meaning "don't bother
|
||||
@ -335,8 +332,9 @@ win32_check_save_as_with_comments(HWND parent, capture_file *cf, int file_type)
|
||||
|
||||
gboolean
|
||||
win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_type,
|
||||
gboolean *compressed, gboolean must_support_comments)
|
||||
gboolean *compressed, gboolean must_support_all_comments)
|
||||
{
|
||||
guint32 required_comment_types;
|
||||
GArray *savable_file_types;
|
||||
OPENFILENAME *ofn;
|
||||
TCHAR file_name16[MAX_PATH] = _T("");
|
||||
@ -354,7 +352,14 @@ win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_t
|
||||
StringCchCopy(file_name16, MAX_PATH, utf_8to16(file_name->str));
|
||||
}
|
||||
|
||||
savable_file_types = wtap_get_savable_file_types(cf->cd_t, cf->linktypes);
|
||||
/* What types of comments do we have to support? */
|
||||
if (must_support_all_comments)
|
||||
required_comment_types = cf_comment_types(cf); /* all the ones the file has */
|
||||
else
|
||||
required_comment_types = 0; /* none of them */
|
||||
|
||||
savable_file_types = wtap_get_savable_file_types(cf->cd_t, cf->linktypes,
|
||||
required_comment_types);
|
||||
if (savable_file_types == NULL)
|
||||
return FALSE; /* shouldn't happen - the "Save As..." item should be disabled if we can't save the file */
|
||||
g_compressed = FALSE;
|
||||
@ -377,8 +382,7 @@ win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_t
|
||||
ofn->lStructSize = ofnsize;
|
||||
ofn->hwndOwner = h_wnd;
|
||||
ofn->hInstance = (HINSTANCE) GetWindowLongPtr(h_wnd, GWLP_HINSTANCE);
|
||||
ofn->lpstrFilter = build_file_save_type_list(savable_file_types,
|
||||
must_support_comments);
|
||||
ofn->lpstrFilter = build_file_save_type_list(savable_file_types);
|
||||
ofn->lpstrCustomFilter = NULL;
|
||||
ofn->nMaxCustFilter = 0;
|
||||
ofn->nFilterIndex = 1; /* the first entry is the best match; 1-origin indexing */
|
||||
@ -442,7 +446,8 @@ win32_export_specified_packets_file(HWND h_wnd, GString *file_name,
|
||||
StringCchCopy(file_name16, MAX_PATH, utf_8to16(file_name->str));
|
||||
}
|
||||
|
||||
savable_file_types = wtap_get_savable_file_types(cfile.cd_t, cfile.linktypes);
|
||||
savable_file_types = wtap_get_savable_file_types(cfile.cd_t,
|
||||
cfile.linktypes, 0);
|
||||
if (savable_file_types == NULL)
|
||||
return FALSE; /* shouldn't happen - the "Save As..." item should be disabled if we can't save the file */
|
||||
|
||||
@ -467,7 +472,7 @@ win32_export_specified_packets_file(HWND h_wnd, GString *file_name,
|
||||
ofn->lStructSize = ofnsize;
|
||||
ofn->hwndOwner = h_wnd;
|
||||
ofn->hInstance = (HINSTANCE) GetWindowLongPtr(h_wnd, GWLP_HINSTANCE);
|
||||
ofn->lpstrFilter = build_file_save_type_list(savable_file_types, FALSE);
|
||||
ofn->lpstrFilter = build_file_save_type_list(savable_file_types);
|
||||
ofn->lpstrCustomFilter = NULL;
|
||||
ofn->nMaxCustFilter = 0;
|
||||
ofn->nFilterIndex = 1; /* the first entry is the best match; 1-origin indexing */
|
||||
@ -1522,8 +1527,7 @@ build_file_open_type_list(void) {
|
||||
}
|
||||
|
||||
static TCHAR *
|
||||
build_file_save_type_list(GArray *savable_file_types,
|
||||
gboolean must_support_comments) {
|
||||
build_file_save_type_list(GArray *savable_file_types) {
|
||||
guint i;
|
||||
int ft;
|
||||
GArray* sa = g_array_new(FALSE /*zero_terminated*/, FALSE /*clear_*/,2 /*element_size*/);
|
||||
@ -1532,10 +1536,6 @@ build_file_save_type_list(GArray *savable_file_types,
|
||||
/* Get only the file types as which we can save this file. */
|
||||
for (i = 0; i < savable_file_types->len; i++) {
|
||||
ft = g_array_index(savable_file_types, int, i);
|
||||
if (must_support_comments) {
|
||||
if (ft != WTAP_FILE_PCAPNG)
|
||||
continue;
|
||||
}
|
||||
append_file_type(sa, ft);
|
||||
}
|
||||
|
||||
|
@ -499,265 +499,330 @@ wtap_fdreopen(wtap *wth, const char *filename, int *err)
|
||||
Entries must be sorted by WTAP_FILE_xxx values in ascending order */
|
||||
static const struct file_type_info dump_open_table_base[] = {
|
||||
/* WTAP_FILE_UNKNOWN (only used internally for initialization) */
|
||||
{ NULL, NULL, NULL, NULL, FALSE, FALSE,
|
||||
{ NULL, NULL, NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_PCAP */
|
||||
/* Gianluca Varenni suggests that we add "deprecated" to the description. */
|
||||
{ "Wireshark/tcpdump/... - libpcap", "libpcap", "pcap", "cap;dmp", FALSE, FALSE,
|
||||
{ "Wireshark/tcpdump/... - libpcap", "libpcap", "pcap", "cap;dmp",
|
||||
FALSE, FALSE, 0,
|
||||
libpcap_dump_can_write_encap, libpcap_dump_open },
|
||||
|
||||
/* WTAP_FILE_PCAPNG */
|
||||
{ "Wireshark - pcapng", "pcapng", "pcapng", "ntar", FALSE, TRUE,
|
||||
{ "Wireshark - pcapng", "pcapng", "pcapng", "ntar",
|
||||
FALSE, TRUE, WTAP_COMMENT_PER_SECTION|WTAP_COMMENT_PER_INTERFACE|WTAP_COMMENT_PER_PACKET,
|
||||
pcapng_dump_can_write_encap, pcapng_dump_open },
|
||||
|
||||
/* WTAP_FILE_PCAP_NSEC */
|
||||
{ "Wireshark - nanosecond libpcap", "nseclibpcap", "pcap", "cap;dmp", FALSE, FALSE,
|
||||
{ "Wireshark - nanosecond libpcap", "nseclibpcap", "pcap", "cap;dmp",
|
||||
FALSE, FALSE, 0,
|
||||
libpcap_dump_can_write_encap, libpcap_dump_open },
|
||||
|
||||
/* WTAP_FILE_PCAP_AIX */
|
||||
{ "AIX tcpdump - libpcap", "aixlibpcap", "pcap", "cap;dmp", FALSE, FALSE,
|
||||
{ "AIX tcpdump - libpcap", "aixlibpcap", "pcap", "cap;dmp",
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_PCAP_SS991029 */
|
||||
{ "Modified tcpdump - libpcap", "modlibpcap", "pcap", "cap;dmp", FALSE, FALSE,
|
||||
{ "Modified tcpdump - libpcap", "modlibpcap", "pcap", "cap;dmp",
|
||||
FALSE, FALSE, 0,
|
||||
libpcap_dump_can_write_encap, libpcap_dump_open },
|
||||
|
||||
/* WTAP_FILE_PCAP_NOKIA */
|
||||
{ "Nokia tcpdump - libpcap ", "nokialibpcap", "pcap", "cap;dmp", FALSE, FALSE,
|
||||
{ "Nokia tcpdump - libpcap ", "nokialibpcap", "pcap", "cap;dmp",
|
||||
FALSE, FALSE, 0,
|
||||
libpcap_dump_can_write_encap, libpcap_dump_open },
|
||||
|
||||
/* WTAP_FILE_PCAP_SS990417 */
|
||||
{ "RedHat 6.1 tcpdump - libpcap", "rh6_1libpcap", "pcap", "cap;dmp", FALSE, FALSE,
|
||||
{ "RedHat 6.1 tcpdump - libpcap", "rh6_1libpcap", "pcap", "cap;dmp",
|
||||
FALSE, FALSE, 0,
|
||||
libpcap_dump_can_write_encap, libpcap_dump_open },
|
||||
|
||||
/* WTAP_FILE_PCAP_SS990915 */
|
||||
{ "SuSE 6.3 tcpdump - libpcap", "suse6_3libpcap", "pcap", "cap;dmp", FALSE, FALSE,
|
||||
{ "SuSE 6.3 tcpdump - libpcap", "suse6_3libpcap", "pcap", "cap;dmp",
|
||||
FALSE, FALSE, 0,
|
||||
libpcap_dump_can_write_encap, libpcap_dump_open },
|
||||
|
||||
/* WTAP_FILE_5VIEWS */
|
||||
{ "InfoVista 5View capture", "5views", "5vw", NULL, TRUE, FALSE,
|
||||
{ "InfoVista 5View capture", "5views", "5vw", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
_5views_dump_can_write_encap, _5views_dump_open },
|
||||
|
||||
/* WTAP_FILE_IPTRACE_1_0 */
|
||||
{ "AIX iptrace 1.0", "iptrace_1", NULL, NULL, FALSE, FALSE,
|
||||
{ "AIX iptrace 1.0", "iptrace_1", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_IPTRACE_2_0 */
|
||||
{ "AIX iptrace 2.0", "iptrace_2", NULL, NULL, FALSE, FALSE,
|
||||
{ "AIX iptrace 2.0", "iptrace_2", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_BER */
|
||||
{ "ASN.1 Basic Encoding Rules", "ber", NULL, NULL, FALSE, FALSE,
|
||||
NULL, NULL },
|
||||
{ "ASN.1 Basic Encoding Rules", "ber", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_HCIDUMP */
|
||||
{ "Bluetooth HCI dump", "hcidump", NULL, NULL, FALSE, FALSE,
|
||||
{ "Bluetooth HCI dump", "hcidump", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_CATAPULT_DCT2000 */
|
||||
{ "Catapult DCT2000 trace (.out format)", "dct2000", "out", NULL, FALSE, FALSE,
|
||||
{ "Catapult DCT2000 trace (.out format)", "dct2000", "out", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
catapult_dct2000_dump_can_write_encap, catapult_dct2000_dump_open },
|
||||
|
||||
/* WTAP_FILE_NETXRAY_OLD */
|
||||
{ "Cinco Networks NetXRay 1.x", "netxray1", "cap", NULL, TRUE, FALSE,
|
||||
{ "Cinco Networks NetXRay 1.x", "netxray1", "cap", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_NETXRAY_1_0 */
|
||||
{ "Cinco Networks NetXRay 2.0 or later", "netxray2", "cap", NULL, TRUE, FALSE,
|
||||
{ "Cinco Networks NetXRay 2.0 or later", "netxray2", "cap", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_COSINE */
|
||||
{ "CoSine IPSX L2 capture", "cosine", "txt", NULL, FALSE, FALSE,
|
||||
{ "CoSine IPSX L2 capture", "cosine", "txt", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_CSIDS */
|
||||
{ "CSIDS IPLog", "csids", NULL, NULL, FALSE, FALSE,
|
||||
{ "CSIDS IPLog", "csids", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_DBS_ETHERWATCH */
|
||||
{ "DBS Etherwatch (VMS)", "etherwatch", "txt", NULL, FALSE, FALSE,
|
||||
{ "DBS Etherwatch (VMS)", "etherwatch", "txt", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL},
|
||||
|
||||
/* WTAP_FILE_ERF */
|
||||
{ "Endace ERF capture", "erf", "erf", NULL, FALSE, FALSE,
|
||||
{ "Endace ERF capture", "erf", "erf", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
erf_dump_can_write_encap, erf_dump_open },
|
||||
|
||||
/* WTAP_FILE_EYESDN */
|
||||
{ "EyeSDN USB S0/E1 ISDN trace format", "eyesdn", "trc", NULL, FALSE, FALSE,
|
||||
{ "EyeSDN USB S0/E1 ISDN trace format", "eyesdn", "trc", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
eyesdn_dump_can_write_encap, eyesdn_dump_open },
|
||||
|
||||
/* WTAP_FILE_NETTL */
|
||||
{ "HP-UX nettl trace", "nettl", "trc0", "trc1", FALSE, FALSE,
|
||||
{ "HP-UX nettl trace", "nettl", "trc0", "trc1",
|
||||
FALSE, FALSE, 0,
|
||||
nettl_dump_can_write_encap, nettl_dump_open },
|
||||
|
||||
/* WTAP_FILE_ISERIES */
|
||||
{ "IBM iSeries comm. trace (ASCII)", "iseries_ascii", "txt", NULL, FALSE, FALSE,
|
||||
{ "IBM iSeries comm. trace (ASCII)", "iseries_ascii", "txt", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_ISERIES_UNICODE */
|
||||
{ "IBM iSeries comm. trace (UNICODE)", "iseries_unicode", "txt", NULL, FALSE, FALSE,
|
||||
{ "IBM iSeries comm. trace (UNICODE)", "iseries_unicode", "txt", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_I4BTRACE */
|
||||
{ "I4B ISDN trace", "i4btrace", NULL, NULL, FALSE, FALSE,
|
||||
{ "I4B ISDN trace", "i4btrace", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_ASCEND */
|
||||
{ "Lucent/Ascend access server trace", "ascend", "txt", NULL, FALSE, FALSE,
|
||||
{ "Lucent/Ascend access server trace", "ascend", "txt", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_NETMON_1_x */
|
||||
{ "Microsoft NetMon 1.x", "netmon1", "cap", NULL, TRUE, FALSE,
|
||||
{ "Microsoft NetMon 1.x", "netmon1", "cap", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
netmon_dump_can_write_encap_1_x, netmon_dump_open },
|
||||
|
||||
/* WTAP_FILE_NETMON_2_x */
|
||||
{ "Microsoft NetMon 2.x", "netmon2", "cap", NULL, TRUE, FALSE,
|
||||
{ "Microsoft NetMon 2.x", "netmon2", "cap", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
netmon_dump_can_write_encap_2_x, netmon_dump_open },
|
||||
|
||||
/* WTAP_FILE_NGSNIFFER_UNCOMPRESSED */
|
||||
{ "NA Sniffer (DOS)", "ngsniffer", "cap", "enc;trc;fdc;syc", FALSE, FALSE,
|
||||
{ "NA Sniffer (DOS)", "ngsniffer", "cap", "enc;trc;fdc;syc",
|
||||
FALSE, FALSE, 0,
|
||||
ngsniffer_dump_can_write_encap, ngsniffer_dump_open },
|
||||
|
||||
/* WTAP_FILE_NGSNIFFER_COMPRESSED */
|
||||
{ "NA Sniffer (DOS), compressed", "ngsniffer_comp", "caz", NULL, FALSE, FALSE,
|
||||
{ "NA Sniffer (DOS), compressed", "ngsniffer_comp", "caz", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_NETXRAY_1_1 */
|
||||
{ "NA Sniffer (Windows) 1.1", "ngwsniffer_1_1", "cap", NULL, TRUE, FALSE,
|
||||
{ "NA Sniffer (Windows) 1.1", "ngwsniffer_1_1", "cap", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
netxray_dump_can_write_encap_1_1, netxray_dump_open_1_1 },
|
||||
|
||||
/* WTAP_FILE_NETXRAY_2_00x */
|
||||
{ "NA Sniffer (Windows) 2.00x", "ngwsniffer_2_0", "cap", NULL, TRUE, FALSE,
|
||||
{ "NA Sniffer (Windows) 2.00x", "ngwsniffer_2_0", "cap", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
netxray_dump_can_write_encap_2_0, netxray_dump_open_2_0 },
|
||||
|
||||
/* WTAP_FILE_NETWORK_INSTRUMENTS */
|
||||
{ "Network Instruments Observer", "niobserver", "bfr", NULL, FALSE, FALSE,
|
||||
{ "Network Instruments Observer", "niobserver", "bfr", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
network_instruments_dump_can_write_encap, network_instruments_dump_open },
|
||||
|
||||
/* WTAP_FILE_LANALYZER */
|
||||
{ "Novell LANalyzer","lanalyzer", "tr1", NULL, TRUE, FALSE,
|
||||
{ "Novell LANalyzer","lanalyzer", "tr1", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
lanalyzer_dump_can_write_encap, lanalyzer_dump_open },
|
||||
|
||||
/* WTAP_FILE_PPPDUMP */
|
||||
{ "pppd log (pppdump format)", "pppd", NULL, NULL, FALSE, FALSE,
|
||||
{ "pppd log (pppdump format)", "pppd", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_RADCOM */
|
||||
{ "RADCOM WAN/LAN analyzer", "radcom", NULL, NULL, FALSE, FALSE,
|
||||
{ "RADCOM WAN/LAN analyzer", "radcom", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_SNOOP */
|
||||
{ "Sun snoop", "snoop", "snoop", "cap", FALSE, FALSE,
|
||||
{ "Sun snoop", "snoop", "snoop", "cap",
|
||||
FALSE, FALSE, 0,
|
||||
snoop_dump_can_write_encap, snoop_dump_open },
|
||||
|
||||
/* WTAP_FILE_SHOMITI */
|
||||
{ "Shomiti/Finisar Surveyor", "shomiti", "cap", NULL, FALSE, FALSE,
|
||||
{ "Shomiti/Finisar Surveyor", "shomiti", "cap", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_VMS */
|
||||
{ "TCPIPtrace (VMS)", "tcpiptrace", "txt", NULL, FALSE, FALSE,
|
||||
{ "TCPIPtrace (VMS)", "tcpiptrace", "txt", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL},
|
||||
|
||||
/* WTAP_FILE_K12 */
|
||||
{ "Tektronix K12xx 32-bit .rf5 format", "rf5", "rf5", NULL, TRUE, FALSE,
|
||||
k12_dump_can_write_encap, k12_dump_open },
|
||||
{ "Tektronix K12xx 32-bit .rf5 format", "rf5", "rf5", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
k12_dump_can_write_encap, k12_dump_open },
|
||||
|
||||
/* WTAP_FILE_TOSHIBA */
|
||||
{ "Toshiba Compact ISDN Router snoop", "toshiba", "txt", NULL, FALSE, FALSE,
|
||||
{ "Toshiba Compact ISDN Router snoop", "toshiba", "txt", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_VISUAL_NETWORKS */
|
||||
{ "Visual Networks traffic capture", "visual", NULL, NULL, TRUE, FALSE,
|
||||
{ "Visual Networks traffic capture", "visual", NULL, NULL,
|
||||
TRUE, FALSE, 0,
|
||||
visual_dump_can_write_encap, visual_dump_open },
|
||||
|
||||
/* WTAP_FILE_PEEKCLASSIC_V56 */
|
||||
{ "WildPackets classic (V5 and V6)", "peekclassic56", "pkt", "tpc;apc;wpz", FALSE, FALSE,
|
||||
{ "WildPackets classic (V5 and V6)", "peekclassic56", "pkt", "tpc;apc;wpz",
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_PEEKCLASSIC_V7 */
|
||||
{ "WildPackets classic (V7)", "peekclassic7", "pkt", "tpc;apc;wpz", FALSE, FALSE,
|
||||
{ "WildPackets classic (V7)", "peekclassic7", "pkt", "tpc;apc;wpz",
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_PEEKTAGGED */
|
||||
{ "WildPackets tagged", "peektagged", "pkt", "tpc;apc;wpz", FALSE, FALSE,
|
||||
{ "WildPackets tagged", "peektagged", "pkt", "tpc;apc;wpz",
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_MPEG */
|
||||
{ "MPEG", "mpeg", "mpeg", "mpg;mp3", FALSE, FALSE,
|
||||
{ "MPEG", "mpeg", "mpeg", "mpg;mp3",
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_K12TEXT */
|
||||
{ "K12 text file", "k12text", "txt", NULL, FALSE, FALSE,
|
||||
{ "K12 text file", "k12text", "txt", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
k12text_dump_can_write_encap, k12text_dump_open },
|
||||
|
||||
/* WTAP_FILE_NETSCREEN */
|
||||
{ "NetScreen snoop text file", "netscreen", "txt", NULL, FALSE, FALSE,
|
||||
{ "NetScreen snoop text file", "netscreen", "txt", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_COMMVIEW */
|
||||
{ "TamoSoft CommView", "commview", "ncf", NULL, FALSE, FALSE,
|
||||
{ "TamoSoft CommView", "commview", "ncf", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
commview_dump_can_write_encap, commview_dump_open },
|
||||
|
||||
/* WTAP_FILE_BTSNOOP */
|
||||
{ "Symbian OS btsnoop", "btsnoop", "log", NULL, FALSE, FALSE,
|
||||
{ "Symbian OS btsnoop", "btsnoop", "log", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
btsnoop_dump_can_write_encap, btsnoop_dump_open_h4 },
|
||||
|
||||
/* WTAP_FILE_TNEF */
|
||||
{ "Transport-Neutral Encapsulation Format", "tnef", NULL, NULL, FALSE, FALSE,
|
||||
{ "Transport-Neutral Encapsulation Format", "tnef", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_DCT3TRACE */
|
||||
{ "Gammu DCT3 trace", "dct3trace", "xml", NULL, FALSE, FALSE,
|
||||
{ "Gammu DCT3 trace", "dct3trace", "xml", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_PACKETLOGGER */
|
||||
{ "PacketLogger", "pklg", "pklg", NULL, FALSE, FALSE,
|
||||
{ "PacketLogger", "pklg", "pklg", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_DAINTREE_SNA */
|
||||
{ "Daintree SNA", "dsna", "dcf", NULL, FALSE, FALSE,
|
||||
{ "Daintree SNA", "dsna", "dcf", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_NETSCALER_1_0 */
|
||||
{ "NetScaler Trace (Version 1.0)", "nstrace10", NULL, NULL, TRUE, FALSE,
|
||||
{ "NetScaler Trace (Version 1.0)", "nstrace10", NULL, NULL,
|
||||
TRUE, FALSE, 0,
|
||||
nstrace_10_dump_can_write_encap, nstrace_dump_open },
|
||||
|
||||
/* WTAP_FILE_NETSCALER_2_0 */
|
||||
{ "NetScaler Trace (Version 2.0)", "nstrace20", "cap", NULL, TRUE, FALSE,
|
||||
{ "NetScaler Trace (Version 2.0)", "nstrace20", "cap", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
nstrace_20_dump_can_write_encap, nstrace_dump_open },
|
||||
|
||||
/* WTAP_FILE_JPEG_JFIF */
|
||||
{ "JPEG/JFIF", "jpeg", "jpg", "jpeg;jfif", FALSE, FALSE,
|
||||
{ "JPEG/JFIF", "jpeg", "jpg", "jpeg;jfif",
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_IPFIX */
|
||||
{ "IPFIX File Format", "ipfix", "pfx", "ipfix", FALSE, FALSE,
|
||||
{ "IPFIX File Format", "ipfix", "pfx", "ipfix",
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_ENCAP_MIME */
|
||||
{ "MIME File Format", "mime", NULL, NULL, FALSE, FALSE,
|
||||
{ "MIME File Format", "mime", NULL, NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_AETHRA */
|
||||
{ "Aethra .aps file", "aethra", "aps", NULL, FALSE, FALSE,
|
||||
{ "Aethra .aps file", "aethra", "aps", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_MPEG_2_TS */
|
||||
{ "MPEG2 transport stream", "mp2t", "mp2t", "ts;mpg", FALSE, FALSE,
|
||||
{ "MPEG2 transport stream", "mp2t", "mp2t", "ts;mpg",
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_VWR_80211 */
|
||||
{ "Ixia IxVeriWave .vwr Raw 802.11 Capture", "vwr80211", "*.vwr", ".vwr", FALSE, FALSE,
|
||||
{ "Ixia IxVeriWave .vwr Raw 802.11 Capture", "vwr80211", "vwr", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_VWR_ETH */
|
||||
{ "Ixia IxVeriWave .vwr Raw Ethernet Capture", "vwreth", "*.vwr", ".vwr", FALSE, FALSE,
|
||||
{ "Ixia IxVeriWave .vwr Raw Ethernet Capture", "vwreth", "vwr", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_CAMINS */
|
||||
{ "CAM Inspector file", "camins", "camins", NULL, FALSE, FALSE, NULL, NULL }
|
||||
|
||||
{ "CAM Inspector file", "camins", "camins", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL }
|
||||
};
|
||||
|
||||
gint wtap_num_file_types = sizeof(dump_open_table_base) / sizeof(struct file_type_info);
|
||||
@ -850,13 +915,14 @@ wtap_dump_can_write_encaps(int ft, const GArray *file_encaps)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Get a GArray of WTAP_FILE_ values for file types that can be used
|
||||
* to save a file of a given type with a given GArray of WTAP_ENCAP_
|
||||
* types.
|
||||
* types and the given bitmask of comment types.
|
||||
*/
|
||||
GArray *
|
||||
wtap_get_savable_file_types(int file_type, const GArray *file_encaps)
|
||||
wtap_get_savable_file_types(int file_type, const GArray *file_encaps,
|
||||
guint32 required_comment_types)
|
||||
{
|
||||
GArray *savable_file_types;
|
||||
int ft;
|
||||
@ -864,22 +930,18 @@ wtap_get_savable_file_types(int file_type, const GArray *file_encaps)
|
||||
int other_file_type = -1;
|
||||
|
||||
/* Can we save this file in its own file type? */
|
||||
if (wtap_dump_can_write_encaps(file_type, file_encaps)) {
|
||||
if (wtap_dump_can_write_encaps(file_type, file_encaps) &&
|
||||
wtap_dump_supports_comment_types(file_type, required_comment_types)) {
|
||||
/* Yes - make that the default file type. */
|
||||
default_file_type = file_type;
|
||||
} else {
|
||||
/* No - can we save it as a pcap-NG file? */
|
||||
if (wtap_dump_can_write_encaps(WTAP_FILE_PCAPNG, file_encaps)) {
|
||||
/* Yes - default to pcap-NG, instead. */
|
||||
default_file_type = WTAP_FILE_PCAPNG;
|
||||
} else {
|
||||
/* OK, find the first file type we *can* save it as. */
|
||||
default_file_type = -1;
|
||||
for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) {
|
||||
if (wtap_dump_can_write_encaps(ft, file_encaps)) {
|
||||
/* OK, got it. */
|
||||
default_file_type = ft;
|
||||
}
|
||||
/* OK, find the first file type we *can* save it as. */
|
||||
default_file_type = -1;
|
||||
for (ft = 0; ft < WTAP_NUM_FILE_TYPES; ft++) {
|
||||
if (wtap_dump_can_write_encaps(ft, file_encaps) &&
|
||||
wtap_dump_supports_comment_types(ft, required_comment_types)) {
|
||||
/* OK, got it. */
|
||||
default_file_type = ft;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -895,13 +957,17 @@ wtap_get_savable_file_types(int file_type, const GArray *file_encaps)
|
||||
/* Put the default file format first in the list. */
|
||||
g_array_append_val(savable_file_types, default_file_type);
|
||||
|
||||
/* If it's pcap, put pcap-NG right after it; otherwise, if it's
|
||||
pcap-NG, put pcap right after it. */
|
||||
/* If the default is pcap, put pcap-NG right after it if we can
|
||||
also write it in pcap-NG format; otherwise, if the default is
|
||||
pcap-NG, put pcap right after it if we can also write it in
|
||||
pcap format. */
|
||||
if (default_file_type == WTAP_FILE_PCAP) {
|
||||
if (wtap_dump_can_write_encaps(WTAP_FILE_PCAPNG, file_encaps))
|
||||
if (wtap_dump_can_write_encaps(WTAP_FILE_PCAPNG, file_encaps) &&
|
||||
wtap_dump_supports_comment_types(WTAP_FILE_PCAPNG, required_comment_types))
|
||||
other_file_type = WTAP_FILE_PCAPNG;
|
||||
} else if (default_file_type == WTAP_FILE_PCAPNG) {
|
||||
if (wtap_dump_can_write_encaps(WTAP_FILE_PCAP, file_encaps))
|
||||
if (wtap_dump_can_write_encaps(WTAP_FILE_PCAP, file_encaps) &&
|
||||
wtap_dump_supports_comment_types(WTAP_FILE_PCAP, required_comment_types))
|
||||
other_file_type = WTAP_FILE_PCAP;
|
||||
}
|
||||
if (other_file_type != -1)
|
||||
@ -913,7 +979,8 @@ wtap_get_savable_file_types(int file_type, const GArray *file_encaps)
|
||||
continue; /* not a real file type */
|
||||
if (ft == default_file_type || ft == other_file_type)
|
||||
continue; /* we've already done this one */
|
||||
if (wtap_dump_can_write_encaps(ft, file_encaps)) {
|
||||
if (wtap_dump_can_write_encaps(ft, file_encaps) &&
|
||||
wtap_dump_supports_comment_types(ft, required_comment_types)) {
|
||||
/* OK, we can write it out in this type. */
|
||||
g_array_append_val(savable_file_types, ft);
|
||||
}
|
||||
@ -1126,6 +1193,20 @@ gboolean wtap_dump_has_name_resolution(int filetype)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean wtap_dump_supports_comment_types(int filetype, guint32 comment_types)
|
||||
{
|
||||
guint32 supported_comment_types;
|
||||
|
||||
if (filetype < 0 || filetype >= wtap_num_file_types)
|
||||
return FALSE;
|
||||
|
||||
supported_comment_types = dump_open_table[filetype].supported_comment_types;
|
||||
|
||||
if ((comment_types & supported_comment_types) == comment_types)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean wtap_dump_open_check(int filetype, int encap, gboolean comressed, int *err);
|
||||
static wtap_dumper* wtap_dump_alloc_wdh(int filetype, int encap, int snaplen,
|
||||
gboolean compressed, int *err);
|
||||
|
@ -1094,6 +1094,13 @@ typedef struct wtap_dumper wtap_dumper;
|
||||
|
||||
typedef struct wtap_reader *FILE_T;
|
||||
|
||||
/*
|
||||
* Types of comments.
|
||||
*/
|
||||
#define WTAP_COMMENT_PER_SECTION 0x00000001 /* per-file/per-file-section */
|
||||
#define WTAP_COMMENT_PER_INTERFACE 0x00000002 /* per-interface */
|
||||
#define WTAP_COMMENT_PER_PACKET 0x00000004 /* per-packet */
|
||||
|
||||
struct file_type_info {
|
||||
/* the file type name */
|
||||
/* should be NULL for all "pseudo" types that are only internally used and not read/writeable */
|
||||
@ -1120,6 +1127,9 @@ struct file_type_info {
|
||||
/* should be FALSE is this file type doesn't support name resolution records */
|
||||
gboolean has_name_resolution;
|
||||
|
||||
/* what types of comment does this file support? */
|
||||
guint32 supported_comment_types;
|
||||
|
||||
/* can this type write this encapsulation format? */
|
||||
/* should be NULL is this file type doesn't have write support */
|
||||
int (*can_write_encap)(int);
|
||||
@ -1245,10 +1255,27 @@ int wtap_dump_file_encap_type(const GArray *file_encaps);
|
||||
WS_DLL_PUBLIC
|
||||
gboolean wtap_dump_can_write_encaps(int ft, const GArray *file_encaps);
|
||||
|
||||
/**
|
||||
* Return TRUE if we can write this capture file format out in
|
||||
* compressed form, FALSE if not.
|
||||
*/
|
||||
WS_DLL_PUBLIC
|
||||
gboolean wtap_dump_can_compress(int filetype);
|
||||
|
||||
/**
|
||||
* Return TRUE if this capture file format supports storing name
|
||||
* resolution information in it, FALSE if not.
|
||||
*/
|
||||
WS_DLL_PUBLIC
|
||||
gboolean wtap_dump_has_name_resolution(int filetype);
|
||||
|
||||
/**
|
||||
* Return TRUE if this capture file format supports all the comment
|
||||
* types specified, FALSE if not.
|
||||
*/
|
||||
WS_DLL_PUBLIC
|
||||
gboolean wtap_dump_supports_comment_types(int filetype, guint32 comment_types);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
wtap_dumper* wtap_dump_open(const char *filename, int filetype, int encap,
|
||||
int snaplen, gboolean compressed, int *err);
|
||||
@ -1283,10 +1310,11 @@ gboolean wtap_dump_close(wtap_dumper *, int *);
|
||||
/**
|
||||
* Get a GArray of WTAP_FILE_ values for file types that can be used
|
||||
* to save a file of a given type with a given GArray of WTAP_ENCAP_
|
||||
* types.
|
||||
* types and the given bitmask of comment types.
|
||||
*/
|
||||
WS_DLL_PUBLIC
|
||||
GArray *wtap_get_savable_file_types(int file_type, const GArray *file_encaps);
|
||||
GArray *wtap_get_savable_file_types(int file_type, const GArray *file_encaps,
|
||||
guint32 required_comment_types);
|
||||
|
||||
/*** various string converter functions ***/
|
||||
WS_DLL_PUBLIC
|
||||
|
Loading…
x
Reference in New Issue
Block a user