aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/netmon.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-12-04 08:32:14 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-12-04 08:32:14 +0000
commita523458070a789d76e0cc4faf65a18a9afdced7b (patch)
tree04954b5a0f08b5ad2fc7e3d49b9655f605e0a9d2 /wiretap/netmon.c
parentc8bf50f50b0cb630ef8d38b551e1eb385b86c283 (diff)
Add some infrastructure for the use of Ethereal, so it can make a list
of all the file types in which a file can be saved. Giving each dumpable file type a routine that checks whether a file of a given file type and encapsulation can be written lets us hoist some checks into common code from out of the open routines. If the "dump close" routine for a dump stream is NULL, have that mean that there's no action that needs to be taken on a close by the code to handle that file type; some file types don't need that, as they can be written purely sequentially. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1200 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'wiretap/netmon.c')
-rw-r--r--wiretap/netmon.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index 6e1db29a96..0921e24a43 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -1,6 +1,6 @@
/* netmon.c
*
- * $Id: netmon.c,v 1.19 1999/12/04 06:21:45 guy Exp $
+ * $Id: netmon.c,v 1.20 1999/12/04 08:32:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -388,22 +388,24 @@ static const int wtap_encap[] = {
};
#define NUM_WTAP_ENCAPS (sizeof wtap_encap / sizeof wtap_encap[0])
-/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
- failure */
-gboolean netmon_dump_open(wtap_dumper *wdh, int *err)
+/* Returns 0 if we could write the specified encapsulation type,
+ an error indication otherwise. */
+int netmon_dump_can_dump_encap(int filetype, int encap)
{
/* Per-packet encapsulations aren't supported. */
- if (wdh->encap == WTAP_ENCAP_PER_PACKET) {
- *err = WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED;
- return FALSE;
- }
+ if (encap == WTAP_ENCAP_PER_PACKET)
+ return WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED;
- if (wdh->encap < 0 || wdh->encap >= NUM_WTAP_ENCAPS
- || wtap_encap[wdh->encap] == -1) {
- *err = WTAP_ERR_UNSUPPORTED_ENCAP;
- return FALSE;
- }
+ if (encap < 0 || encap >= NUM_WTAP_ENCAPS || wtap_encap[encap] == -1)
+ return WTAP_ERR_UNSUPPORTED_ENCAP;
+ return 0;
+}
+
+/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
+ failure */
+gboolean netmon_dump_open(wtap_dumper *wdh, int *err)
+{
/* This is a netmon file */
wdh->subtype_write = netmon_dump;
wdh->subtype_close = netmon_dump_close;