diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-05-23 10:50:02 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-05-23 10:50:10 +0000 |
commit | a344c9736efe5519543da1290e1ad9065d0b0cff (patch) | |
tree | 7757d80d74ae710e5d4e4a1b0cb638d0ec644fc4 /wiretap/dbs-etherwatch.c | |
parent | 716fdc8e398ea7435b23192ab1f7d59e7b21e32b (diff) | |
download | wireshark-a344c9736efe5519543da1290e1ad9065d0b0cff.tar.gz |
Revert "Allow wtap_read() and wtap_seek_read() to return non-packet records."
This reverts commit c0c480d08c175eed4524ea9e73ec86298f468cf4.
A better way to do this is to have the record type be part of struct wtap_pkthdr; that keeps the metadata for the record together and requires fewer API changes. That is in-progress.
Change-Id: Ic558f163a48e2c6d0df7f55e81a35a5e24b53bc6
Reviewed-on: https://code.wireshark.org/review/1741
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/dbs-etherwatch.c')
-rw-r--r-- | wiretap/dbs-etherwatch.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index 31fa9af630..0a3e9f57e1 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -84,11 +84,11 @@ static const char dbs_etherwatch_rec_magic[] = */ #define DBS_ETHERWATCH_MAX_PACKET_LEN 16384 -static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, +static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset); -static int dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off, +static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info); -static int parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, +static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, int *err, gchar **err_info); static guint parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset); @@ -196,7 +196,7 @@ int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info) } /* Find the next packet and parse it; called from wtap_read(). */ -static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, +static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; @@ -204,7 +204,7 @@ static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, /* Find the next packet */ offset = dbs_etherwatch_seek_next_packet(wth, err, err_info); if (offset < 1) - return -1; + return FALSE; *data_offset = offset; /* Parse the packet */ @@ -213,12 +213,12 @@ static int dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info, } /* Used to read packets in random-access fashion */ -static int +static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) { if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1) - return -1; + return FALSE; return parse_dbs_etherwatch_packet(phdr, wth->random_fh, buf, err, err_info); @@ -268,7 +268,7 @@ unnumbered. Unnumbered has length 1, numbered 2. */ #define CTL_UNNUMB_MASK 0x03 #define CTL_UNNUMB_VALUE 0x03 -static int +static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, int *err, gchar **err_info) { @@ -298,7 +298,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } /* Get the destination address */ @@ -306,14 +306,14 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if(!p) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: destination address not found"); - return -1; + return FALSE; } p += strlen(DEST_MAC_PREFIX); if(parse_hex_dump(p, &pd[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END) != MAC_ADDR_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: destination address not valid"); - return -1; + return FALSE; } eth_hdr_len += MAC_ADDR_LENGTH; @@ -331,7 +331,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_END) != MAC_ADDR_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: source address not valid"); - return -1; + return FALSE; } eth_hdr_len += MAC_ADDR_LENGTH; @@ -341,14 +341,14 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } /* Check the lines is as least as long as the length position */ if(strlen(line) < LENGTH_POS) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: line too short"); - return -1; + return FALSE; } num_items_scanned = sscanf(line + LENGTH_POS, @@ -361,7 +361,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if (num_items_scanned != 8) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: header line not valid"); - return -1; + return FALSE; } /* Determine whether it is Ethernet II or IEEE 802 */ @@ -373,7 +373,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_END) != PROTOCOL_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: Ethernet II protocol value not valid"); - return -1; + return FALSE; } eth_hdr_len += PROTOCOL_LENGTH; } else { @@ -389,7 +389,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_END) != SAP_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: 802.2 DSAP+SSAP value not valid"); - return -1; + return FALSE; } eth_hdr_len += SAP_LENGTH; /* Get the (first part of the) control field */ @@ -397,7 +397,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_END) != CTL_UNNUMB_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: 802.2 control field first part not valid"); - return -1; + return FALSE; } /* Determine whether the control is numbered, and thus longer */ if((pd[eth_hdr_len] & CTL_UNNUMB_MASK) != CTL_UNNUMB_VALUE) { @@ -407,7 +407,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_HDR_SPR) != CTL_NUMB_LENGTH - CTL_UNNUMB_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: 802.2 control field second part value not valid"); - return -1; + return FALSE; } eth_hdr_len += CTL_NUMB_LENGTH; } else { @@ -421,7 +421,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, HEX_PID_END) != PID_LENGTH) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: 802.2 PID value not valid"); - return -1; + return FALSE; } eth_hdr_len += PID_LENGTH; } @@ -457,22 +457,22 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, if (*err == 0) { *err = WTAP_ERR_SHORT_READ; } - return -1; + return FALSE; } if (!(line_count = parse_single_hex_dump_line(line, &pd[eth_hdr_len + count], count))) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: packet data value not valid"); - return -1; + return FALSE; } count += line_count; if (count > pkt_len) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup("dbs_etherwatch: packet data value has too many bytes"); - return -1; + return FALSE; } } - return REC_TYPE_PACKET; + return TRUE; } /* Parse a hex dump line */ |