diff options
Diffstat (limited to '')
-rw-r--r-- | wiretap/vwr.c | 582 |
1 files changed, 291 insertions, 291 deletions
diff --git a/wiretap/vwr.c b/wiretap/vwr.c index 251ddf52..3bd47759 100644 --- a/wiretap/vwr.c +++ b/wiretap/vwr.c @@ -8,45 +8,45 @@ * */ #include "config.h" +#include "vwr.h" #include <string.h> #include "wtap-int.h" #include "file_wrappers.h" -#include "vwr.h" #include <wsutil/ws_assert.h> /* platform-specific definitions for portability */ /* unsigned long long constants */ -# define NS_IN_US G_GUINT64_CONSTANT(1000) /* nanoseconds-to-microseconds */ -# define NS_IN_SEC G_GUINT64_CONSTANT(1000000000) /* nanoseconds-to-seconds */ -# define US_IN_SEC G_GUINT64_CONSTANT(1000000) /* microseconds-to-seconds */ -# define LL_ZERO G_GUINT64_CONSTANT(0) /* zero in unsigned long long */ +# define NS_IN_US UINT64_C(1000) /* nanoseconds-to-microseconds */ +# define NS_IN_SEC UINT64_C(1000000000) /* nanoseconds-to-seconds */ +# define US_IN_SEC UINT64_C(1000000) /* microseconds-to-seconds */ +# define LL_ZERO UINT64_C(0) /* zero in unsigned long long */ /* * Fetch a 64-bit value in "Corey-endian" form. */ -#define pcoreytohll(p) ((guint64)*((const guint8 *)(p)+4)<<56| \ - (guint64)*((const guint8 *)(p)+5)<<48| \ - (guint64)*((const guint8 *)(p)+6)<<40| \ - (guint64)*((const guint8 *)(p)+7)<<32| \ - (guint64)*((const guint8 *)(p)+0)<<24| \ - (guint64)*((const guint8 *)(p)+1)<<16| \ - (guint64)*((const guint8 *)(p)+2)<<8| \ - (guint64)*((const guint8 *)(p)+3)<<0) +#define pcoreytohll(p) ((uint64_t)*((const uint8_t *)(p)+4)<<56| \ + (uint64_t)*((const uint8_t *)(p)+5)<<48| \ + (uint64_t)*((const uint8_t *)(p)+6)<<40| \ + (uint64_t)*((const uint8_t *)(p)+7)<<32| \ + (uint64_t)*((const uint8_t *)(p)+0)<<24| \ + (uint64_t)*((const uint8_t *)(p)+1)<<16| \ + (uint64_t)*((const uint8_t *)(p)+2)<<8| \ + (uint64_t)*((const uint8_t *)(p)+3)<<0) /* * Fetch a 48-bit value in "Corey-endian" form; it's stored as * a 64-bit Corey-endian value, with the upper 16 bits ignored. */ -#define pcorey48tohll(p) ((guint64)*((const guint8 *)(p)+6)<<40| \ - (guint64)*((const guint8 *)(p)+7)<<32| \ - (guint64)*((const guint8 *)(p)+0)<<24| \ - (guint64)*((const guint8 *)(p)+1)<<16| \ - (guint64)*((const guint8 *)(p)+2)<<8| \ - (guint64)*((const guint8 *)(p)+3)<<0) +#define pcorey48tohll(p) ((uint64_t)*((const uint8_t *)(p)+6)<<40| \ + (uint64_t)*((const uint8_t *)(p)+7)<<32| \ + (uint64_t)*((const uint8_t *)(p)+0)<<24| \ + (uint64_t)*((const uint8_t *)(p)+1)<<16| \ + (uint64_t)*((const uint8_t *)(p)+2)<<8| \ + (uint64_t)*((const uint8_t *)(p)+3)<<0) /* .vwr log file defines */ #define B_SIZE 32768 /* max var len message = 32 kB */ @@ -479,7 +479,7 @@ #define vVW510021_W_PREAMBLE_OFF vVW510021_W_L1P_1_OFF #define vVW510021_W_RSSI_TXPOWER_OFF 2 /* RSSI (NOTE: RSSI must be negated!) */ #define vVW510021_W_MSDU_LENGTH_OFF 3 /* 7:0 of length, next byte 11:8 in top 4 bits */ -#define vVW510021_W_BVCV_VALID_OFF 4 /* BV,CV Determine validaity of bssid and txpower */ +#define vVW510021_W_BVCV_VALID_OFF 4 /* BV,CV Determine validity of bssid and txpower */ #define vVW510021_W_VCID_OFF 6 /* offset of VC (client) ID */ #define vVW510021_W_PLCP_LENGTH_OFF 12 /* LENGTH field in the plcp header */ @@ -692,73 +692,73 @@ typedef struct { /* offsets in stats block; these are dependent on the frame type (Ethernet/WLAN) and */ /* version number of .vwr file, and are set up by setup_defaults() */ - guint32 STATS_LEN; /* length of stats block trailer */ - guint32 STATS_START_OFF; /* STATS OFF AFTER HEADER */ - guint32 VALID_OFF; /* bit 6 (0x40) is flow-is-valid flag */ - guint32 MTYPE_OFF; /* offset of modulation type */ - guint32 VCID_OFF; /* offset of VC ID */ - guint32 FLOWSEQ_OFF; /* offset of signature sequence number */ - guint32 FLOWID_OFF; /* offset of flow ID */ - guint32 OCTET_OFF; /* offset of octets */ - guint32 ERRORS_OFF; /* offset of error vector */ - guint32 PATN_OFF; /* offset of pattern match vector */ - guint32 RSSI_OFF; /* RSSI (NOTE: RSSI must be negated!) */ - guint32 STARTT_OFF; /* offset of start time, 64 bits */ - guint32 ENDT_OFF; /* offset of end time, 64 bits */ - guint32 LATVAL_OFF; /* offset of latency, 32 bits */ - guint32 INFO_OFF; /* offset of INFO field, 16 bits */ - guint32 L1P_1_OFF; /* offset 1ST Byte of l1params */ - guint32 L1P_2_OFF; /* offset 2nd Byte of l1params */ - guint32 L4ID_OFF; /* LAYER 4 id offset*/ - guint32 IPLEN_OFF; /* */ - guint32 PLCP_LENGTH_OFF; /* offset of length field in the PLCP header */ - guint32 FPGA_VERSION_OFF; /* offset of fpga version field, 16 bits */ - guint32 HEADER_VERSION_OFF; /* offset of header version, 16 bits */ - guint32 RXTX_OFF; /* offset of CMD bit, rx or tx */ - guint32 FRAME_TYPE_OFF; + uint32_t STATS_LEN; /* length of stats block trailer */ + uint32_t STATS_START_OFF; /* STATS OFF AFTER HEADER */ + uint32_t VALID_OFF; /* bit 6 (0x40) is flow-is-valid flag */ + uint32_t MTYPE_OFF; /* offset of modulation type */ + uint32_t VCID_OFF; /* offset of VC ID */ + uint32_t FLOWSEQ_OFF; /* offset of signature sequence number */ + uint32_t FLOWID_OFF; /* offset of flow ID */ + uint32_t OCTET_OFF; /* offset of octets */ + uint32_t ERRORS_OFF; /* offset of error vector */ + uint32_t PATN_OFF; /* offset of pattern match vector */ + uint32_t RSSI_OFF; /* RSSI (NOTE: RSSI must be negated!) */ + uint32_t STARTT_OFF; /* offset of start time, 64 bits */ + uint32_t ENDT_OFF; /* offset of end time, 64 bits */ + uint32_t LATVAL_OFF; /* offset of latency, 32 bits */ + uint32_t INFO_OFF; /* offset of INFO field, 16 bits */ + uint32_t L1P_1_OFF; /* offset 1ST Byte of l1params */ + uint32_t L1P_2_OFF; /* offset 2nd Byte of l1params */ + uint32_t L4ID_OFF; /* LAYER 4 id offset*/ + uint32_t IPLEN_OFF; /* */ + uint32_t PLCP_LENGTH_OFF; /* offset of length field in the PLCP header */ + uint32_t FPGA_VERSION_OFF; /* offset of fpga version field, 16 bits */ + uint32_t HEADER_VERSION_OFF; /* offset of header version, 16 bits */ + uint32_t RXTX_OFF; /* offset of CMD bit, rx or tx */ + uint32_t FRAME_TYPE_OFF; /* other information about the file in question */ - guint32 MT_10_HALF; /* 10 Mb/s half-duplex */ - guint32 MT_10_FULL; /* 10 Mb/s full-duplex */ - guint32 MT_100_HALF; /* 100 Mb/s half-duplex */ - guint32 MT_100_FULL; /* 100 Mb/s full-duplex */ - guint32 MT_1G_HALF; /* 1 Gb/s half-duplex */ - guint32 MT_1G_FULL; /* 1 Gb/s full-duplex */ - guint32 FCS_ERROR; /* FCS error in frame */ - guint32 CRYPTO_ERR; /* RX decrypt error flags */ - guint32 PAYCHK_ERR; /* payload checksum failure */ - guint32 RETRY_ERR; /* excessive retries on TX failure */ - guint8 IS_RX; /* TX/RX bit in STATS block */ - guint8 MT_MASK; /* modulation type mask */ - guint16 VCID_MASK; /* VC ID might not be a full 16 bits */ - guint32 FLOW_VALID; /* flow-is-valid flag (else force to 0) */ - guint16 QOS_VALID; - guint32 RX_DECRYPTS; /* RX-frame-was-decrypted bits */ - guint32 TX_DECRYPTS; /* TX-frame-was-decrypted bits */ - guint32 FC_PROT_BIT; /* Protected Frame bit in FC1 of frame */ - guint32 MT_CCKL; /* CCK modulation, long preamble */ - guint32 MT_CCKS; /* CCK modulation, short preamble */ - guint32 MT_OFDM; /* OFDM modulation */ - guint32 MCS_INDEX_MASK; /* mcs index type mask */ - guint32 FPGA_VERSION; - guint32 WEPTYPE; /* frame is WEP */ - guint32 TKIPTYPE; /* frame is TKIP */ - guint32 CCMPTYPE; /* frame is CCMP */ - guint32 IS_TCP; - guint32 IS_UDP; - guint32 IS_ICMP; - guint32 IS_IGMP; - guint16 IS_QOS; - guint32 IS_VLAN; - guint32 MPDU_OFF; - guint32 OCTO_VERSION; + uint32_t MT_10_HALF; /* 10 Mb/s half-duplex */ + uint32_t MT_10_FULL; /* 10 Mb/s full-duplex */ + uint32_t MT_100_HALF; /* 100 Mb/s half-duplex */ + uint32_t MT_100_FULL; /* 100 Mb/s full-duplex */ + uint32_t MT_1G_HALF; /* 1 Gb/s half-duplex */ + uint32_t MT_1G_FULL; /* 1 Gb/s full-duplex */ + uint32_t FCS_ERROR; /* FCS error in frame */ + uint32_t CRYPTO_ERR; /* RX decrypt error flags */ + uint32_t PAYCHK_ERR; /* payload checksum failure */ + uint32_t RETRY_ERR; /* excessive retries on TX failure */ + uint8_t IS_RX; /* TX/RX bit in STATS block */ + uint8_t MT_MASK; /* modulation type mask */ + uint16_t VCID_MASK; /* VC ID might not be a full 16 bits */ + uint32_t FLOW_VALID; /* flow-is-valid flag (else force to 0) */ + uint16_t QOS_VALID; + uint32_t RX_DECRYPTS; /* RX-frame-was-decrypted bits */ + uint32_t TX_DECRYPTS; /* TX-frame-was-decrypted bits */ + uint32_t FC_PROT_BIT; /* Protected Frame bit in FC1 of frame */ + uint32_t MT_CCKL; /* CCK modulation, long preamble */ + uint32_t MT_CCKS; /* CCK modulation, short preamble */ + uint32_t MT_OFDM; /* OFDM modulation */ + uint32_t MCS_INDEX_MASK; /* mcs index type mask */ + uint32_t FPGA_VERSION; + uint32_t WEPTYPE; /* frame is WEP */ + uint32_t TKIPTYPE; /* frame is TKIP */ + uint32_t CCMPTYPE; /* frame is CCMP */ + uint32_t IS_TCP; + uint32_t IS_UDP; + uint32_t IS_ICMP; + uint32_t IS_IGMP; + uint16_t IS_QOS; + uint32_t IS_VLAN; + uint32_t MPDU_OFF; + uint32_t OCTO_VERSION; } vwr_t; /* * NSS for various MCS values. */ #define MAX_HT_MCS 76 -static guint nss_for_mcs[MAX_HT_MCS+1] = { +static unsigned nss_for_mcs[MAX_HT_MCS+1] = { 1, 1, 1, 1, 1, 1, 1, 1, /* 0-7 */ 2, 2, 2, 2, 2, 2, 2, 2, /* 8-15 */ 3, 3, 3, 3, 3, 3, 3, 3, /* 16-23 */ @@ -771,42 +771,42 @@ static guint nss_for_mcs[MAX_HT_MCS+1] = { }; /* internal utility functions */ -static int decode_msg(vwr_t *vwr, register guint8 *, int *, int *, int *); -static guint8 get_ofdm_rate(const guint8 *); -static guint8 get_cck_rate(const guint8 *plcp); -static void setup_defaults(vwr_t *, guint16); - -static gboolean vwr_read(wtap *, wtap_rec *, Buffer *, int *, - gchar **, gint64 *); -static gboolean vwr_seek_read(wtap *, gint64, wtap_rec *, - Buffer *, int *, gchar **); - -static gboolean vwr_read_rec_header(vwr_t *, FILE_T, int *, int *, int *, int *, gchar **); -static gboolean vwr_process_rec_data(FILE_T fh, int rec_size, +static int decode_msg(vwr_t *vwr, register uint8_t *, int *, int *, int *); +static uint8_t get_ofdm_rate(const uint8_t *); +static uint8_t get_cck_rate(const uint8_t *plcp); +static void setup_defaults(vwr_t *, uint16_t); + +static bool vwr_read(wtap *, wtap_rec *, Buffer *, int *, + char **, int64_t *); +static bool vwr_seek_read(wtap *, int64_t, wtap_rec *, + Buffer *, int *, char **); + +static bool vwr_read_rec_header(vwr_t *, FILE_T, int *, int *, int *, int *, char **); +static bool vwr_process_rec_data(FILE_T fh, int rec_size, wtap_rec *record, Buffer *buf, vwr_t *vwr, int IS_TX, int log_mode, int *err, - gchar **err_info); + char **err_info); -static int vwr_get_fpga_version(wtap *, int *, gchar **); +static int vwr_get_fpga_version(wtap *, int *, char **); -static gboolean vwr_read_s1_W_rec(vwr_t *, wtap_rec *, Buffer *, - const guint8 *, int, int *, gchar **); -static gboolean vwr_read_s2_W_rec(vwr_t *, wtap_rec *, Buffer *, - const guint8 *, int, int, int *, - gchar **); +static bool vwr_read_s1_W_rec(vwr_t *, wtap_rec *, Buffer *, + const uint8_t *, int, int *, char **); +static bool vwr_read_s2_W_rec(vwr_t *, wtap_rec *, Buffer *, + const uint8_t *, int, int, int *, + char **); /* For FPGA version >= 48 (OCTO Platform), following function will be used */ -static gboolean vwr_read_s3_W_rec(vwr_t *, wtap_rec *, Buffer *, - const guint8 *, int, int, int, int *, - gchar **); -static gboolean vwr_read_rec_data_ethernet(vwr_t *, wtap_rec *, - Buffer *, const guint8 *, int, - int, int *, gchar **); - -static int find_signature(const guint8 *, int, int, register guint32, register guint8); -static guint64 get_signature_ts(const guint8 *, int, int); -static float get_legacy_rate(guint8); -static float get_ht_rate(guint8, guint16); -static float get_vht_rate(guint8, guint16, guint8); +static bool vwr_read_s3_W_rec(vwr_t *, wtap_rec *, Buffer *, + const uint8_t *, int, int, int, int *, + char **); +static bool vwr_read_rec_data_ethernet(vwr_t *, wtap_rec *, + Buffer *, const uint8_t *, int, + int, int *, char **); + +static int find_signature(const uint8_t *, int, int, register uint32_t, register uint8_t); +static uint64_t get_signature_ts(const uint8_t *, int, int); +static float get_legacy_rate(uint8_t); +static float get_ht_rate(uint8_t, uint16_t); +static float get_vht_rate(uint8_t, uint16_t, uint8_t); static int vwr_80211_file_type_subtype = -1; static int vwr_eth_file_type_subtype = -1; @@ -817,7 +817,7 @@ void register_vwr(void); /* This does very little, except setting the wiretap header for a VWR file type */ /* and setting the timestamp precision to microseconds. */ -wtap_open_return_val vwr_open(wtap *wth, int *err, gchar **err_info) +wtap_open_return_val vwr_open(wtap *wth, int *err, char **err_info) { int fpgaVer; vwr_t *vwr; @@ -871,15 +871,15 @@ wtap_open_return_val vwr_open(wtap *wth, int *err, gchar **err_info) /* frame, and a 64-byte statistics block trailer. */ /* The PLCP frame consists of a 4-byte or 6-byte PLCP header, followed by the MAC frame */ -static gboolean vwr_read(wtap *wth, wtap_rec *rec, Buffer *buf, - int *err, gchar **err_info, gint64 *data_offset) +static bool vwr_read(wtap *wth, wtap_rec *rec, Buffer *buf, + int *err, char **err_info, int64_t *data_offset) { vwr_t *vwr = (vwr_t *)wth->priv; int rec_size = 0, IS_TX = 0, log_mode = 0; /* read the next frame record header in the capture file; if no more frames, return */ if (!vwr_read_rec_header(vwr, wth->fh, &rec_size, &IS_TX, &log_mode, err, err_info)) - return FALSE; /* Read error or EOF */ + return false; /* Read error or EOF */ /* * We're past the header; return the offset of the header, not of @@ -890,26 +890,26 @@ static gboolean vwr_read(wtap *wth, wtap_rec *rec, Buffer *buf, /* got a frame record; read and process it */ if (!vwr_process_rec_data(wth->fh, rec_size, rec, buf, vwr, IS_TX, log_mode, err, err_info)) - return FALSE; + return false; - return TRUE; + return true; } /* read a random record in the middle of a file; the start of the record is @ seek_off */ -static gboolean vwr_seek_read(wtap *wth, gint64 seek_off, - wtap_rec *record, Buffer *buf, int *err, gchar **err_info) +static bool vwr_seek_read(wtap *wth, int64_t seek_off, + wtap_rec *record, Buffer *buf, int *err, char **err_info) { vwr_t *vwr = (vwr_t *)wth->priv; int rec_size, IS_TX = 0, log_mode = 0; /* first seek to the indicated record header */ if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) - return FALSE; + return false; /* read in the record header */ if (!vwr_read_rec_header(vwr, wth->random_fh, &rec_size, &IS_TX, &log_mode, err, err_info)) - return FALSE; /* Read error or EOF */ + return false; /* Read error or EOF */ return vwr_process_rec_data(wth->random_fh, rec_size, record, buf, vwr, IS_TX, log_mode, err, err_info); @@ -917,13 +917,13 @@ static gboolean vwr_seek_read(wtap *wth, gint64 seek_off, /* Scan down in the input capture file to find the next frame header. */ /* Decode and skip over all non-frame messages that are in the way. */ -/* Return TRUE on success, FALSE on EOF or error. */ +/* Return true on success, false on EOF or error. */ /* Also return the frame size in bytes and the "is transmitted frame" flag. */ -static gboolean vwr_read_rec_header(vwr_t *vwr, FILE_T fh, int *rec_size, int *IS_TX, int *log_mode, int *err, gchar **err_info) +static bool vwr_read_rec_header(vwr_t *vwr, FILE_T fh, int *rec_size, int *IS_TX, int *log_mode, int *err, char **err_info) { int f_len, v_type; - guint8 header[VW_RECORD_HEADER_LENGTH]; + uint8_t header[VW_RECORD_HEADER_LENGTH]; *rec_size = 0; @@ -934,7 +934,7 @@ static gboolean vwr_read_rec_header(vwr_t *vwr, FILE_T fh, int *rec_size, int *I /* If we find a frame, we return (with the header in the passed buffer). */ while (1) { if (!wtap_read_bytes_or_eof(fh, header, VW_RECORD_HEADER_LENGTH, err, err_info)) - return FALSE; + return false; /* Got a header; invoke decode-message function to parse and process it. */ /* If the function returns a length, then a frame or variable-length message */ @@ -944,15 +944,15 @@ static gboolean vwr_read_rec_header(vwr_t *vwr, FILE_T fh, int *rec_size, int *I if (f_len > B_SIZE) { *err = WTAP_ERR_BAD_FILE; *err_info = ws_strdup_printf("vwr: Invalid message record length %d", f_len); - return FALSE; + return false; } else if (v_type != VT_FRAME) { if (!wtap_read_bytes(fh, NULL, f_len, err, err_info)) - return FALSE; + return false; } else { *rec_size = f_len; - return TRUE; + return true; } } } @@ -962,22 +962,22 @@ static gboolean vwr_read_rec_header(vwr_t *vwr, FILE_T fh, int *rec_size, int *I /* Return FPGA version if it's a known version, UNKNOWN_FPGA if it's not, */ /* and -1 on an I/O error. */ -static int vwr_get_fpga_version(wtap *wth, int *err, gchar **err_info) +static int vwr_get_fpga_version(wtap *wth, int *err, char **err_info) { - guint8 *rec; /* local buffer (holds input record) */ - guint8 header[VW_RECORD_HEADER_LENGTH]; + uint8_t *rec; /* local buffer (holds input record) */ + uint8_t header[VW_RECORD_HEADER_LENGTH]; int rec_size = 0; - guint8 i; - guint8 *s_510006_ptr = NULL; - guint8 *s_510024_ptr = NULL; - guint8 *s_510012_ptr = NULL; /* stats pointers */ - gint64 filePos = -1; - guint64 bytes_read = 0; - guint32 frame_type = 0; + uint8_t i; + uint8_t *s_510006_ptr = NULL; + uint8_t *s_510024_ptr = NULL; + uint8_t *s_510012_ptr = NULL; /* stats pointers */ + int64_t filePos = -1; + uint64_t bytes_read = 0; + uint32_t frame_type = 0; int f_len, v_type; - guint16 data_length = 0; - guint16 fpga_version; - gboolean valid_but_empty_file = FALSE; + uint16_t data_length = 0; + uint16_t fpga_version; + bool valid_but_empty_file = false; filePos = file_tell(wth->fh); if (filePos == -1) { @@ -986,7 +986,7 @@ static int vwr_get_fpga_version(wtap *wth, int *err, gchar **err_info) } fpga_version = 1000; - rec = (guint8*)g_malloc(B_SIZE); + rec = (uint8_t*)g_malloc(B_SIZE); /* Got a frame record; see if it is vwr */ /* If we don't get it all, then declare an error, we can't process the frame. */ /* Read out the file data in 16-byte messages, stopping either after we find a frame, */ @@ -1014,7 +1014,7 @@ static int vwr_get_fpga_version(wtap *wth, int *err, gchar **err_info) return -1; } else if (v_type == VT_CPMSG) - valid_but_empty_file = TRUE; + valid_but_empty_file = true; } else { rec_size = f_len; @@ -1140,34 +1140,34 @@ static int vwr_get_fpga_version(wtap *wth, int *err, gchar **err_info) /* The packet is constructed as a 38-byte VeriWave metadata header plus the raw */ /* MAC octets. */ -static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, - Buffer *buf, const guint8 *rec, int rec_size, - int *err, gchar **err_info) +static bool vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, + Buffer *buf, const uint8_t *rec, int rec_size, + int *err, char **err_info) { - guint8 *data_ptr; + uint8_t *data_ptr; int bytes_written = 0; /* bytes output to buf so far */ - const guint8 *s_ptr, *m_ptr; /* stats pointer */ - guint16 msdu_length, actual_octets; /* octets in frame */ - guint16 plcp_hdr_len; /* PLCP header length */ - guint16 rflags; - guint8 m_type; /* mod type (CCK-L/CCK-S/OFDM), seqnum */ - guint flow_seq; - guint64 s_time = LL_ZERO, e_time = LL_ZERO; /* start/end */ + const uint8_t *s_ptr, *m_ptr; /* stats pointer */ + uint16_t msdu_length, actual_octets; /* octets in frame */ + uint16_t plcp_hdr_len; /* PLCP header length */ + uint16_t rflags; + uint8_t m_type; /* mod type (CCK-L/CCK-S/OFDM), seqnum */ + unsigned flow_seq; + uint64_t s_time = LL_ZERO, e_time = LL_ZERO; /* start/end */ /* times, nsec */ - guint32 latency; - guint64 start_time, s_sec, s_usec = LL_ZERO; /* start time, sec + usec */ - guint64 end_time; /* end time */ - guint32 info; /* INFO/ERRORS fields in stats blk */ - gint8 rssi; /* RSSI, signed 8-bit number */ + uint32_t latency; + uint64_t start_time, s_sec, s_usec = LL_ZERO; /* start time, sec + usec */ + uint64_t end_time; /* end time */ + uint32_t info; /* INFO/ERRORS fields in stats blk */ + int8_t rssi; /* RSSI, signed 8-bit number */ int f_tx; /* flag: if set, is a TX frame */ - guint8 rate_index; /* pre-HT only */ - guint16 vc_id, ht_len=0; /* VC ID, total ip length */ - guint flow_id; /* flow ID */ - guint32 d_time, errors; /* packet duration & errors */ + uint8_t rate_index; /* pre-HT only */ + uint16_t vc_id, ht_len=0; /* VC ID, total ip length */ + unsigned flow_id; /* flow ID */ + uint32_t d_time, errors; /* packet duration & errors */ int sig_off, pay_off; /* MAC+SNAP header len, signature offset */ - guint64 sig_ts; /* 32 LSBs of timestamp in signature */ - guint16 phyRate; - guint16 vw_flags; /* VeriWave-specific packet flags */ + uint64_t sig_ts; /* 32 LSBs of timestamp in signature */ + uint16_t phyRate; + uint16_t vw_flags; /* VeriWave-specific packet flags */ /* * The record data must be large enough to hold the statistics trailer. @@ -1176,7 +1176,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid record length %d (must be at least %u)", rec_size, v22_W_STATS_LEN); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } /* Calculate the start of the statistics block in the buffer */ @@ -1188,7 +1188,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, vc_id = pntoh16(&s_ptr[v22_W_VCID_OFF]) & v22_E_VCID_MASK; flow_seq = s_ptr[v22_W_FLOWSEQ_OFF]; - latency = (guint32)pcorey48tohll(&s_ptr[v22_W_LATVAL_OFF]); + latency = (uint32_t)pcorey48tohll(&s_ptr[v22_W_LATVAL_OFF]); flow_id = pntoh16(&s_ptr[v22_W_FLOWID_OFF+1]); /* only 16 LSBs kept */ errors = pntoh16(&s_ptr[v22_W_ERRORS_OFF]); @@ -1207,7 +1207,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid data length %u (runs past the end of the record)", actual_octets); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } /* Decode OFDM or CCK PLCP header and determine rate and short preamble flag. */ @@ -1229,7 +1229,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid data length %u (too short to include %u-byte PLCP header)", actual_octets, plcp_hdr_len); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } m_ptr = &rec[plcp_hdr_len]; msdu_length = actual_octets; @@ -1250,7 +1250,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid data length %u (too short to include %u-byte PLCP header and 4 bytes of FCS)", actual_octets, plcp_hdr_len); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } } else { actual_octets -= 4; @@ -1262,7 +1262,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, e_time = pcoreytohll(&s_ptr[v22_W_ENDT_OFF]); /* find the packet duration (difference between start and end times) */ - d_time = (guint32)((e_time - s_time) / NS_IN_US); /* find diff, converting to usec */ + d_time = (uint32_t)((e_time - s_time) / NS_IN_US); /* find diff, converting to usec */ /* also convert the packet start time to seconds and microseconds */ start_time = s_time / NS_IN_US; /* convert to microseconds first */ @@ -1356,7 +1356,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, phtoles(&data_ptr[bytes_written], CHAN_CCK); } bytes_written += 2; - phyRate = (guint16)(get_legacy_rate(rate_index) * 10); + phyRate = (uint16_t)(get_legacy_rate(rate_index) * 10); phtoles(&data_ptr[bytes_written], phyRate); bytes_written += 2; data_ptr[bytes_written] = vVW510021_W_PLCP_LEGACY; /* pre-HT */ @@ -1413,50 +1413,50 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record, */ memcpy(&data_ptr[bytes_written], &rec[plcp_hdr_len], actual_octets); - return TRUE; + return true; } -static gboolean vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record, - Buffer *buf, const guint8 *rec, int rec_size, - int IS_TX, int *err, gchar **err_info) +static bool vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record, + Buffer *buf, const uint8_t *rec, int rec_size, + int IS_TX, int *err, char **err_info) { - guint8 *data_ptr; + uint8_t *data_ptr; int bytes_written = 0; /* bytes output to buf so far */ - const guint8 *s_start_ptr,*s_trail_ptr, *plcp_ptr, *m_ptr; /* stats & MPDU ptr */ - guint32 msdu_length, actual_octets; /* octets in frame */ - guint8 l1p_1, l1p_2, plcp_type, rate_mcs_index, nss; /* mod (CCK-L/CCK-S/OFDM) */ - guint flow_seq; - guint64 s_time = LL_ZERO, e_time = LL_ZERO; /* start/end */ + const uint8_t *s_start_ptr,*s_trail_ptr, *plcp_ptr, *m_ptr; /* stats & MPDU ptr */ + uint32_t msdu_length, actual_octets; /* octets in frame */ + uint8_t l1p_1, l1p_2, plcp_type, rate_mcs_index, nss; /* mod (CCK-L/CCK-S/OFDM) */ + unsigned flow_seq; + uint64_t s_time = LL_ZERO, e_time = LL_ZERO; /* start/end */ /* times, nsec */ - guint64 latency = LL_ZERO; - guint64 start_time, s_sec, s_usec = LL_ZERO; /* start time, sec + usec */ - guint64 end_time; /* end time */ - guint16 info; /* INFO/ERRORS fields in stats blk */ - guint32 errors; - gint8 rssi[] = {0,0,0,0}; /* RSSI, signed 8-bit number */ + uint64_t latency = LL_ZERO; + uint64_t start_time, s_sec, s_usec = LL_ZERO; /* start time, sec + usec */ + uint64_t end_time; /* end time */ + uint16_t info; /* INFO/ERRORS fields in stats blk */ + uint32_t errors; + int8_t rssi[] = {0,0,0,0}; /* RSSI, signed 8-bit number */ int f_tx; /* flag: if set, is a TX frame */ - guint16 vc_id, ht_len=0; /* VC ID , total ip length*/ - guint32 flow_id, d_time; /* flow ID, packet duration*/ + uint16_t vc_id, ht_len=0; /* VC ID , total ip length*/ + uint32_t flow_id, d_time; /* flow ID, packet duration*/ int sig_off, pay_off; /* MAC+SNAP header len, signature offset */ - guint64 sig_ts, tsid; /* 32 LSBs of timestamp in signature */ - guint16 chanflags = 0; /* channel flags for WLAN metadata header */ - guint16 radioflags = 0; /* flags for WLAN metadata header */ - guint64 delta_b; /* Used for calculating latency */ + uint64_t sig_ts, tsid; /* 32 LSBs of timestamp in signature */ + uint16_t chanflags = 0; /* channel flags for WLAN metadata header */ + uint16_t radioflags = 0; /* flags for WLAN metadata header */ + uint64_t delta_b; /* Used for calculating latency */ float rate; - guint16 phyRate; - guint16 vw_flags; /* VeriWave-specific packet flags */ + uint16_t phyRate; + uint16_t vw_flags; /* VeriWave-specific packet flags */ /* * The record data must be large enough to hold the statistics header, * the PLCP, and the statistics trailer. */ - if ((guint)rec_size < vwr->MPDU_OFF + vVW510021_W_STATS_TRAILER_LEN) { + if ((unsigned)rec_size < vwr->MPDU_OFF + vVW510021_W_STATS_TRAILER_LEN) { *err_info = ws_strdup_printf("vwr: Invalid record length %d (must be at least %u)", rec_size, vwr->MPDU_OFF + vVW510021_W_STATS_TRAILER_LEN); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } /* Calculate the start of the statistics blocks in the buffer */ @@ -1505,7 +1505,7 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid data length %u (runs past the end of the record)", actual_octets); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } f_tx = IS_TX; @@ -1615,7 +1615,7 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record, * the PSDU. */ { - guint8 SBW = vVW510021_W_BANDWIDTH_VHT(l1p_2); + uint8_t SBW = vVW510021_W_BANDWIDTH_VHT(l1p_2); rate_mcs_index = vVW510021_W_S2_MCS_INDEX_VHT(l1p_1); radioflags |= FLAGS_CHAN_VHT | ((l1p_1 & vVW510021_W_IS_LONGGI) ? 0 : FLAGS_CHAN_SHORTGI); chanflags |= CHAN_OFDM; @@ -1651,7 +1651,7 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid data length %u (too short to include 4 bytes of FCS)", actual_octets); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } } else { actual_octets -= 4; @@ -1663,7 +1663,7 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record, e_time = pcoreytohll(&s_trail_ptr[vVW510021_W_ENDT_OFF]); /* find the packet duration (difference between start and end times) */ - d_time = (guint32)((e_time - s_time) / NS_IN_US); /* find diff, converting to usec */ + d_time = (uint32_t)((e_time - s_time) / NS_IN_US); /* find diff, converting to usec */ /* also convert the packet start time to seconds and microseconds */ start_time = s_time / NS_IN_US; /* convert to microseconds first */ @@ -1773,7 +1773,7 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record, bytes_written += 2; phtoles(&data_ptr[bytes_written], chanflags); bytes_written += 2; - phyRate = (guint16)(rate * 10); + phyRate = (uint16_t)(rate * 10); phtoles(&data_ptr[bytes_written], phyRate); bytes_written += 2; @@ -1830,51 +1830,51 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record, */ memcpy(&data_ptr[bytes_written], &rec[vwr->MPDU_OFF], actual_octets); - return TRUE; + return true; } -static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, - Buffer *buf, const guint8 *rec, int rec_size, +static bool vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, + Buffer *buf, const uint8_t *rec, int rec_size, int IS_TX, int log_mode, int *err, - gchar **err_info) + char **err_info) { - guint8 *data_ptr; + uint8_t *data_ptr; int bytes_written = 0; /* bytes output to buf so far */ int i; int stats_offset = 0; - const guint8 *s_start_ptr = NULL,*s_trail_ptr = NULL, *plcp_ptr, *m_ptr; /* stats & MPDU ptr */ - guint32 msdu_length = 0, actual_octets = 0; /* octets in frame */ - guint8 l1p_1 = 0,l1p_2 = 0, plcp_type, rate_mcs_index, nss; /* mod (CCK-L/CCK-S/OFDM) */ - guint64 s_time = LL_ZERO, e_time = LL_ZERO; /* start/end */ + const uint8_t *s_start_ptr = NULL,*s_trail_ptr = NULL, *plcp_ptr, *m_ptr; /* stats & MPDU ptr */ + uint32_t msdu_length = 0, actual_octets = 0; /* octets in frame */ + uint8_t l1p_1 = 0,l1p_2 = 0, plcp_type, rate_mcs_index, nss; /* mod (CCK-L/CCK-S/OFDM) */ + uint64_t s_time = LL_ZERO, e_time = LL_ZERO; /* start/end */ /* times, nsec */ - guint64 latency = LL_ZERO; - guint64 start_time = 0, s_sec = 0, s_usec = LL_ZERO; /* start time, sec + usec */ - guint64 end_time = 0; /* end time */ - guint16 info = 0; /* INFO/ERRORS fields in stats blk */ - guint32 errors = 0; - gint8 info_2nd = 0,rssi[] = {0,0,0,0}; /* RSSI, signed 8-bit number */ + uint64_t latency = LL_ZERO; + uint64_t start_time = 0, s_sec = 0, s_usec = LL_ZERO; /* start time, sec + usec */ + uint64_t end_time = 0; /* end time */ + uint16_t info = 0; /* INFO/ERRORS fields in stats blk */ + uint32_t errors = 0; + int8_t info_2nd = 0,rssi[] = {0,0,0,0}; /* RSSI, signed 8-bit number */ int frame_size; - guint32 d_time = 0, flow_id = 0; /* packet duration, Flow Signature ID*/ + uint32_t d_time = 0, flow_id = 0; /* packet duration, Flow Signature ID*/ int sig_off, pay_off; /* MAC+SNAP header len, signature offset */ - guint64 sig_ts = 0, tsid; /* 32 LSBs of timestamp in signature */ - guint64 delta_b; /* Used for calculating latency */ - guint8 L1InfoC = 0, port_type, ver_fpga = 0; - guint8 flow_seq =0,plcp_hdr_flag = 0,rf_id = 0; /* indicates plcp hdr info */ - const guint8 *rf_ptr = NULL; + uint64_t sig_ts = 0, tsid; /* 32 LSBs of timestamp in signature */ + uint64_t delta_b; /* Used for calculating latency */ + uint8_t L1InfoC = 0, port_type, ver_fpga = 0; + uint8_t flow_seq =0,plcp_hdr_flag = 0,rf_id = 0; /* indicates plcp hdr info */ + const uint8_t *rf_ptr = NULL; float rate; - guint16 phyRate; + uint16_t phyRate; /* * The record data must be large enough to hold the statistics header, * the PLCP, and the statistics trailer. */ if (IS_TX == 3) { /*IS_TX =3, i.e., command type is RF Modified*/ - if ((guint)rec_size < OCTO_MODIFIED_RF_LEN) { + if ((unsigned)rec_size < OCTO_MODIFIED_RF_LEN) { *err_info = ws_strdup_printf("vwr: Invalid record length %d (must be at least %u)", rec_size, OCTO_MODIFIED_RF_LEN); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } rf_ptr = &(rec[0]); rf_id = rf_ptr[0]; @@ -1916,12 +1916,12 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, if (IS_TX == 4) /*IS_TX =4, i.e., command type is RF-RX Modified*/ { stats_offset = OCTO_RF_MOD_ACTUAL_LEN; - if ((guint)rec_size < stats_offset + vwr->MPDU_OFF + vVW510021_W_STATS_TRAILER_LEN) { + if ((unsigned)rec_size < stats_offset + vwr->MPDU_OFF + vVW510021_W_STATS_TRAILER_LEN) { *err_info = ws_strdup_printf("vwr: Invalid record length %d (must be at least %u)", rec_size, stats_offset + vwr->MPDU_OFF + vVW510021_W_STATS_TRAILER_LEN); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } rf_ptr = &(rec[0]); rf_id = rf_ptr[0]; @@ -1929,12 +1929,12 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, else { stats_offset = 0; - if ((guint)rec_size < vwr->MPDU_OFF + vVW510021_W_STATS_TRAILER_LEN) { + if ((unsigned)rec_size < vwr->MPDU_OFF + vVW510021_W_STATS_TRAILER_LEN) { *err_info = ws_strdup_printf("vwr: Invalid record length %d (must be at least %u)", rec_size, vwr->MPDU_OFF + vVW510021_W_STATS_TRAILER_LEN); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } } @@ -2022,7 +2022,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid data length %u (runs past the end of the record)", actual_octets); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } flow_seq = s_trail_ptr[vVW510021_W_FLOWSEQ_OFF]; @@ -2065,7 +2065,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, */ { /* set the appropriate flags to indicate HT mode and CB */ - guint16 radioflags = FLAGS_CHAN_HT | ((plcp_ptr[3] & 0x80) ? FLAGS_CHAN_40MHZ : 0) | + uint16_t radioflags = FLAGS_CHAN_HT | ((plcp_ptr[3] & 0x80) ? FLAGS_CHAN_40MHZ : 0) | ((l1p_1 & vVW510021_W_IS_LONGGI) ? 0 : FLAGS_CHAN_SHORTGI); rate = get_ht_rate(rate_mcs_index, radioflags); } @@ -2084,7 +2084,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, */ { /* set the appropriate flags to indicate HT mode and CB */ - guint16 radioflags = FLAGS_CHAN_HT | ((plcp_ptr[0] & 0x80) ? FLAGS_CHAN_40MHZ : 0) | + uint16_t radioflags = FLAGS_CHAN_HT | ((plcp_ptr[0] & 0x80) ? FLAGS_CHAN_40MHZ : 0) | ((l1p_1 & vVW510021_W_IS_LONGGI) ? 0 : FLAGS_CHAN_SHORTGI); rate = get_ht_rate(rate_mcs_index, radioflags); } @@ -2102,8 +2102,8 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, * the PSDU. */ { - guint8 SBW = vVW510021_W_BANDWIDTH_VHT(l1p_2); - guint16 radioflags = FLAGS_CHAN_VHT | ((l1p_1 & vVW510021_W_IS_LONGGI) ? 0 : FLAGS_CHAN_SHORTGI); + uint8_t SBW = vVW510021_W_BANDWIDTH_VHT(l1p_2); + uint16_t radioflags = FLAGS_CHAN_VHT | ((l1p_1 & vVW510021_W_IS_LONGGI) ? 0 : FLAGS_CHAN_SHORTGI); if (SBW == 3) radioflags |= FLAGS_CHAN_40MHZ; else if (SBW == 4) @@ -2116,7 +2116,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, rate = 0.0f; break; } - phyRate = (guint16)(rate * 10); + phyRate = (uint16_t)(rate * 10); /* Calculation of Data rate ends*/ /* 'ver_fpga' is the 2nd Octet of each frame. @@ -2145,7 +2145,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid data length %u (too short to include 4 bytes of FCS)", actual_octets); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } } else { actual_octets -= 4; @@ -2162,7 +2162,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, e_time = pcoreytohll(&s_trail_ptr[vVW510021_W_ENDT_OFF]); /* find the packet duration (difference between start and end times) */ - d_time = (guint32)((e_time - s_time) / NS_IN_US); /* find diff, converting to usec */ + d_time = (uint32_t)((e_time - s_time) / NS_IN_US); /* find diff, converting to usec */ /* also convert the packet start time to seconds and microseconds */ start_time = s_time / NS_IN_US; /* convert to microseconds first */ @@ -2220,7 +2220,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: File has %u-byte packet, bigger than maximum of %u", record->rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } record->ts.secs = (time_t)s_sec; @@ -2545,45 +2545,45 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record, memcpy(&data_ptr[bytes_written], &rec[stats_offset+(vwr->MPDU_OFF)], actual_octets); } - return TRUE; + return true; } /* read an Ethernet packet */ /* Copy the actual packet data from the capture file into the target data block. */ /* The packet is constructed as a 38-byte VeriWave-extended Radiotap header plus the raw */ /* MAC octets. */ -static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, - Buffer *buf, const guint8 *rec, +static bool vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, + Buffer *buf, const uint8_t *rec, int rec_size, int IS_TX, int *err, - gchar **err_info) + char **err_info) { - guint8 *data_ptr; + uint8_t *data_ptr; int bytes_written = 0; /* bytes output to buf so far */ - const guint8 *s_ptr, *m_ptr; /* stats and MPDU pointers */ - guint16 msdu_length, actual_octets; /* octets in frame */ - guint flow_seq; /* seqnum */ - guint64 s_time = LL_ZERO, e_time = LL_ZERO; /* start/end */ + const uint8_t *s_ptr, *m_ptr; /* stats and MPDU pointers */ + uint16_t msdu_length, actual_octets; /* octets in frame */ + unsigned flow_seq; /* seqnum */ + uint64_t s_time = LL_ZERO, e_time = LL_ZERO; /* start/end */ /* times, nsec */ - guint32 latency = 0; - guint64 start_time, s_sec = LL_ZERO, s_usec = LL_ZERO; /* start time, sec + usec */ - guint64 end_time; /* end time */ - guint l4id; - guint16 info, validityBits; /* INFO/ERRORS fields in stats */ - guint32 errors; - guint16 vc_id; /* VC ID, total (incl of aggregates) */ - guint32 flow_id, d_time; /* packet duration */ + uint32_t latency = 0; + uint64_t start_time, s_sec = LL_ZERO, s_usec = LL_ZERO; /* start time, sec + usec */ + uint64_t end_time; /* end time */ + unsigned l4id; + uint16_t info, validityBits; /* INFO/ERRORS fields in stats */ + uint32_t errors; + uint16_t vc_id; /* VC ID, total (incl of aggregates) */ + uint32_t flow_id, d_time; /* packet duration */ int f_flow; /* flags: flow valid */ - guint32 frame_type; /* frame type field */ + uint32_t frame_type; /* frame type field */ int mac_len, sig_off, pay_off; /* MAC header len, signature offset */ /* XXX - the code here fetched tsid, but never used it! */ - guint64 sig_ts/*, tsid*/; /* 32 LSBs of timestamp in signature */ - guint64 delta_b; /* Used for calculating latency */ - guint16 vw_flags; /* VeriWave-specific packet flags */ + uint64_t sig_ts/*, tsid*/; /* 32 LSBs of timestamp in signature */ + uint64_t delta_b; /* Used for calculating latency */ + uint16_t vw_flags; /* VeriWave-specific packet flags */ - if ((guint)rec_size < vwr->STATS_LEN) { + if ((unsigned)rec_size < vwr->STATS_LEN) { *err_info = ws_strdup_printf("vwr: Invalid record length %d (must be at least %u)", rec_size, vwr->STATS_LEN); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } /* Calculate the start of the statistics block in the buffer. */ @@ -2605,7 +2605,7 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid data length %u (runs past the end of the record)", actual_octets); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } vc_id = pntoh16(&s_ptr[vwr->VCID_OFF]) & vwr->VCID_MASK; @@ -2657,7 +2657,7 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, *err_info = ws_strdup_printf("vwr: Invalid data length %u (too short to include 4 bytes of FCS)", actual_octets); *err = WTAP_ERR_BAD_FILE; - return FALSE; + return false; } } else { actual_octets -= 4; @@ -2669,7 +2669,7 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, e_time = pcoreytohll(&s_ptr[vwr->ENDT_OFF]); /* find the packet duration (difference between start and end times) */ - d_time = (guint32)((e_time - s_time)); /* find diff, leaving in nsec for Ethernet */ + d_time = (uint32_t)((e_time - s_time)); /* find diff, leaving in nsec for Ethernet */ /* also convert the packet start time to seconds and microseconds */ start_time = s_time / NS_IN_US; /* convert to microseconds first */ @@ -2709,7 +2709,7 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, /* Set latency based on rx/tx and signature timestamp */ if (!IS_TX) { if (sig_ts < s_time) { - latency = (guint32)(s_time - sig_ts); + latency = (uint32_t)(s_time - sig_ts); } else { /* Account for the rollover case. Since we cannot use 0x100000000 - l_time + s_time */ /* we look for a large difference between l_time and s_time. */ @@ -2717,7 +2717,7 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, if (delta_b > 0x10000000) { latency = 0; } else - latency = (guint32)delta_b; + latency = (uint32_t)delta_b; } } @@ -2740,7 +2740,7 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, record->block = wtap_block_create(WTAP_BLOCK_PACKET); record->presence_flags = WTAP_HAS_TS; - /*etap_hdr.vw_ip_length = (guint16)ip_len;*/ + /*etap_hdr.vw_ip_length = (uint16_t)ip_len;*/ ws_buffer_assure_space(buf, record->rec_header.packet_header.caplen); data_ptr = ws_buffer_start_ptr(buf); @@ -2815,16 +2815,16 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record, */ memcpy(&data_ptr[bytes_written], m_ptr, actual_octets); - return TRUE; + return true; } /*--------------------------------------------------------------------------------------*/ /* utility to split up and decode a 16-byte message record */ -static int decode_msg(vwr_t *vwr, guint8 *rec, int *v_type, int *IS_TX, int *log_mode) +static int decode_msg(vwr_t *vwr, uint8_t *rec, int *v_type, int *IS_TX, int *log_mode) { - guint8 cmd,fpga_log_mode; /* components of message */ - guint32 wd2, wd3; + uint8_t cmd,fpga_log_mode; /* components of message */ + uint32_t wd2, wd3; int v_size; /* size of var-len message */ /* break up the message record into its pieces */ @@ -2919,7 +2919,7 @@ static int decode_msg(vwr_t *vwr, guint8 *rec, int *v_type, int *IS_TX, int *log /* The integer returned by the get_xxx_rate() functions is in units of 0.5 Mb/s. */ /* The string returned by the decode_xxx_rate() functions is 3 characters wide. */ -static guint8 get_ofdm_rate(const guint8 *plcp) +static uint8_t get_ofdm_rate(const uint8_t *plcp) { /* extract the RATE field (LS nibble of first byte) then convert it to the MCS index used by the L1p fields */ switch (plcp[0] & 0x0f) { @@ -2935,7 +2935,7 @@ static guint8 get_ofdm_rate(const guint8 *plcp) } } -static guint8 get_cck_rate(const guint8 *plcp) +static uint8_t get_cck_rate(const uint8_t *plcp) { /* extract rate from the SIGNAL field then convert it to the MCS index used by the L1p fields */ switch (plcp[0]) { @@ -2950,7 +2950,7 @@ static guint8 get_cck_rate(const guint8 *plcp) /*--------------------------------------------------------------------------------------*/ /* utility to set up offsets and bitmasks for decoding the stats blocks */ -static void setup_defaults(vwr_t *vwr, guint16 fpga) +static void setup_defaults(vwr_t *vwr, uint16_t fpga) { switch (fpga) { /* WLAN frames */ @@ -3196,10 +3196,10 @@ static void setup_defaults(vwr_t *vwr, guint16 fpga) /* Utility routine: check that signature is at specified location; scan for it if not. */ /* If we can't find a signature at all, then simply return the originally supplied offset. */ -int find_signature(const guint8 *m_ptr, int rec_size, int pay_off, guint32 flow_id, guint8 flow_seq) +int find_signature(const uint8_t *m_ptr, int rec_size, int pay_off, uint32_t flow_id, uint8_t flow_seq) { int tgt; /* temps */ - guint32 fid; + uint32_t fid; /* initial check is very simple: look for a '0xdd' at the target location */ if (m_ptr[pay_off] == 0xdd) /* if magic byte is present */ @@ -3242,10 +3242,10 @@ int find_signature(const guint8 *m_ptr, int rec_size, int pay_off, guint32 flow_ } /* utility routine: harvest the signature time stamp from the data frame */ -guint64 get_signature_ts(const guint8 *m_ptr,int sig_off, int sig_max) +uint64_t get_signature_ts(const uint8_t *m_ptr,int sig_off, int sig_max) { int ts_offset; - guint64 sig_ts; + uint64_t sig_ts; if (sig_off + 15 >= sig_max) return 0; @@ -3261,7 +3261,7 @@ guint64 get_signature_ts(const guint8 *m_ptr,int sig_off, int sig_max) } static float -get_legacy_rate(guint8 rate_index) +get_legacy_rate(uint8_t rate_index) { /* Rate conversion data */ static const float canonical_rate_legacy[] = {1.0f, 2.0f, 5.5f, 11.0f, 6.0f, 9.0f, 12.0f, 18.0f, 24.0f, 36.0f, 48.0f, 54.0f}; @@ -3275,7 +3275,7 @@ get_legacy_rate(guint8 rate_index) } static float -get_ht_rate(guint8 mcs_index, guint16 rflags) +get_ht_rate(uint8_t mcs_index, uint16_t rflags) { /* Rate conversion data */ static const int canonical_ndbps_20_ht[8] = {26, 52, 78, 104, 156, 208, 234, 260}; @@ -3300,7 +3300,7 @@ get_ht_rate(guint8 mcs_index, guint16 rflags) } static float -get_vht_rate(guint8 mcs_index, guint16 rflags, guint8 nss) +get_vht_rate(uint8_t mcs_index, uint16_t rflags, uint8_t nss) { /* Rate conversion data */ static const int canonical_ndbps_20_vht[9] = {26, 52, 78, 104, 156, 208, 234, 260, 312}; @@ -3344,22 +3344,22 @@ get_vht_rate(guint8 mcs_index, guint16 rflags, guint8 nss) return bitrate; } -static gboolean +static bool vwr_process_rec_data(FILE_T fh, int rec_size, wtap_rec *record, Buffer *buf, vwr_t *vwr, - int IS_TX, int log_mode, int *err, gchar **err_info) + int IS_TX, int log_mode, int *err, char **err_info) { - guint8* rec; /* local buffer (holds input record) */ - gboolean ret = FALSE; + uint8_t* rec; /* local buffer (holds input record) */ + bool ret = false; - rec = (guint8*)g_malloc(B_SIZE); + rec = (uint8_t*)g_malloc(B_SIZE); /* Read over the entire record (frame + trailer) into a local buffer. */ /* If we don't get it all, then declare an error, we can't process the frame. */ if (!wtap_read_bytes(fh, rec, rec_size, err, err_info)) { g_free(rec); - return FALSE; + return false; } /* now format up the frame data */ @@ -3397,7 +3397,7 @@ static const struct supported_block_type vwr_80211_blocks_supported[] = { static const struct file_type_subtype_info vwr_80211_info = { "Ixia IxVeriWave .vwr Raw 802.11 Capture", "vwr80211", "vwr", NULL, - FALSE, BLOCKS_SUPPORTED(vwr_80211_blocks_supported), + false, BLOCKS_SUPPORTED(vwr_80211_blocks_supported), NULL, NULL, NULL }; @@ -3410,7 +3410,7 @@ static const struct supported_block_type vwr_eth_blocks_supported[] = { static const struct file_type_subtype_info vwr_eth_info = { "Ixia IxVeriWave .vwr Raw Ethernet Capture", "vwreth", "vwr", NULL, - FALSE, BLOCKS_SUPPORTED(vwr_eth_blocks_supported), + false, BLOCKS_SUPPORTED(vwr_eth_blocks_supported), NULL, NULL, NULL }; |