#include <errno.h>
#include "wtap-int.h"
-#include "wtap.h"
#include "file_wrappers.h"
-#include <wsutil/buffer.h>
#include "k12.h"
#include <wsutil/str_util.h>
#define CAT(a,b) a##b
#define K12_DBG(level,args) do { if (level <= debug_level) { \
- fprintf(dbg_out,"%s:%d: ",CAT(__FI,LE__),CAT(__LI,NE__)); \
- k12_fprintf args ; \
- fprintf(dbg_out,"\n"); \
+ fprintf(dbg_out,"%s:%d: ",CAT(__FI,LE__),CAT(__LI,NE__)); \
+ k12_fprintf args ; \
+ fprintf(dbg_out,"\n"); \
} } while(0)
void k12_hex_ascii_dump(guint level, gint64 offset, const char* label, const unsigned char* b, unsigned int len) {
* with the "group" code followe by the "type" code. The "group" values
* are:
*
- * 0x0001 - "data event"
- * 0x0002 - "text or L1 event"
- * 0x0007 - "configuration event"
+ * 0x0001 - "data event"
+ * 0x0002 - "text or L1 event"
+ * 0x0007 - "configuration event"
*
* and the "type" values are:
*
* data events:
- * 0x0020 - "frame" (i.e., "an actual packet")
- * 0x0021 - "transparent frame"
- * 0x0022 - "bit data (TRAU frame)"
- * 0x0024 - "used to mark the frame which is a fragment"
- * 0x0026 - "used to mark the frame which is a fragment"
- * 0x0028 - "used to mark the frame which is generated by the LSA"
- * 0x002A - "used to mark the frame which is generated by the LSA"
+ * 0x0020 - "frame" (i.e., "an actual packet")
+ * 0x0021 - "transparent frame"
+ * 0x0022 - "bit data (TRAU frame)"
+ * 0x0024 - "used to mark the frame which is a fragment"
+ * 0x0026 - "used to mark the frame which is a fragment"
+ * 0x0028 - "used to mark the frame which is generated by the LSA"
+ * 0x002A - "used to mark the frame which is generated by the LSA"
*
* text or L1 events:
- * 0x0030 - "text event"
- * 0x0031 - "L1 event"
- * 0x0032 - "L1 event (BAI)"
- * 0x0033 - "L1 event (VX)"
+ * 0x0030 - "text event"
+ * 0x0031 - "L1 event"
+ * 0x0032 - "L1 event (BAI)"
+ * 0x0033 - "L1 event (VX)"
*
* configuration events:
- * 0x0040 - Logical Data Source configuration event
- * 0x0041 - Logical Link configuration event
+ * 0x0040 - Logical Data Source configuration event
+ * 0x0041 - Logical Link configuration event
*/
/* so far we've seen these types of records */
#define K12_REC_PACKET 0x00010020 /* an actual packet */
const guint8 *p = (const guint8 *)ptr;
while (count != 0) {
- if (*p != 0)
- return FALSE;
- p++;
- count--;
+ if (*p != 0)
+ return FALSE;
+ p++;
+ count--;
}
return TRUE;
}
k12_t *k12 = (k12_t *)wth->priv;
destroy_k12_file_data(k12);
- wth->priv = NULL; /* destroy_k12_file_data freed it */
+ wth->priv = NULL; /* destroy_k12_file_data freed it */
#ifdef DEBUG_K12
K12_DBG(5,("k12_close: CLOSED"));
if (env_file) fclose(dbg_out);
gchar* env_level = getenv("K12_DEBUG_LEVEL");
env_file = getenv("K12_DEBUG_FILENAME");
if ( env_file ) {
- dbg_out = ws_fopen(env_file,"w");
- if (dbg_out == NULL) {
- dbg_out = stderr;
- K12_DBG(1,("unable to open K12 DEBUG FILENAME for writing! Logging to standard error"));
- }
+ dbg_out = ws_fopen(env_file,"w");
+ if (dbg_out == NULL) {
+ dbg_out = stderr;
+ K12_DBG(1,("unable to open K12 DEBUG FILENAME for writing! Logging to standard error"));
+ }
}
else
- dbg_out = stderr;
+ dbg_out = stderr;
if ( env_level ) debug_level = (unsigned int)strtoul(env_level,NULL,10);
K12_DBG(1,("k12_open: ENTER debug_level=%u",debug_level));
#endif
if (memiszero(header_buffer + 0x10, K12_FILE_HDR_LEN - 0x10)) {
/*
* The rest of the file header is all zeroes. That means
- * this is a file written by the old Wireshark code, and
- * a count of records in the file is at an offset of 0x0C.
+ * this is a file written by the old Wireshark code, and
+ * a count of records in the file is at an offset of 0x0C.
*/
file_data->num_of_records = pntoh32( header_buffer + 0x0C );
} else {
rec->input_info.ds0mask = 0x00000000;
if (hwpart_len > K12_SRCDESC_DS0_MASK) {
for (i = 0; i < hwpart_len - K12_SRCDESC_DS0_MASK; i++) {
- rec->input_info.ds0mask |= ( *(read_buffer + K12_SRCDESC_HWPART + K12_SRCDESC_DS0_MASK + i) == 0xff ) ? 0x1<<(31-i) : 0x0;
+ rec->input_info.ds0mask |= ( *(read_buffer + K12_SRCDESC_HWPART + K12_SRCDESC_DS0_MASK + i) == 0xff ) ? 1U<<(31-i) : 0x0;
}
}
break;
}
typedef struct {
- guint32 file_len;
- guint32 num_of_records;
- guint32 file_offset;
+ guint32 file_len;
+ guint32 num_of_records;
+ guint32 file_offset;
} k12_dump_t;
int k12_dump_can_write_encap(int encap) {
}
static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
- const guint8 *pd, int *err) {
+ const guint8 *pd, int *err, gchar **err_info _U_) {
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
guint32 len;
/* We can only write packet records. */
if (phdr->rec_type != REC_TYPE_PACKET) {
- *err = WTAP_ERR_REC_TYPE_UNSUPPORTED;
+ *err = WTAP_ERR_UNWRITABLE_REC_TYPE;
return FALSE;
}
static const guint8 k12_eof[] = {0xff,0xff};
-static gboolean k12_dump_close(wtap_dumper *wdh, int *err) {
+static gboolean k12_dump_finish(wtap_dumper *wdh, int *err) {
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
union {
guint8 b[sizeof(guint32)];
return FALSE;
wdh->subtype_write = k12_dump;
- wdh->subtype_close = k12_dump_close;
+ wdh->subtype_finish = k12_dump_finish;
k12 = (k12_dump_t *)g_malloc(sizeof(k12_dump_t));
wdh->priv = (void *)k12;
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */