pcapng: process uint32 options like uint64 options.
Move the extraction of the option value from the option content from the callers of pcapng_process_uint32_option() to pcapng_process_uint32_option() itself.
This commit is contained in:
parent
0e3782831a
commit
4b7bfe35c5
|
@ -519,16 +519,58 @@ pcapng_process_uint8_option(wtapng_block_t *wblock,
|
||||||
|
|
||||||
void
|
void
|
||||||
pcapng_process_uint32_option(wtapng_block_t *wblock,
|
pcapng_process_uint32_option(wtapng_block_t *wblock,
|
||||||
|
const section_info_t *section_info,
|
||||||
|
pcapng_opt_byte_order_e byte_order,
|
||||||
guint16 option_code, guint16 option_length,
|
guint16 option_code, guint16 option_length,
|
||||||
guint32 option_content)
|
const guint8 *option_content)
|
||||||
{
|
{
|
||||||
|
guint32 uint32;
|
||||||
|
|
||||||
if (option_length == 4) {
|
if (option_length == 4) {
|
||||||
|
/* Don't cast a guint8 * into a guint32 *--the
|
||||||
|
* guint8 * may not point to something that's
|
||||||
|
* aligned correctly.
|
||||||
|
*
|
||||||
|
* XXX - options are aligned on 32-bit boundaries, so, while
|
||||||
|
* it may be true that 64-bit options aren't guaranteed to be
|
||||||
|
* aligned on 64-bit bounaries, it shouldn't be true that 32-bit
|
||||||
|
* options aren't guaranteed to be aligned on 32-bit boundaries.
|
||||||
|
*/
|
||||||
|
memcpy(&uint32, option_content, sizeof(guint32));
|
||||||
|
switch (byte_order) {
|
||||||
|
|
||||||
|
case OPT_SECTION_BYTE_ORDER:
|
||||||
|
if (section_info->byte_swapped) {
|
||||||
|
uint32 = GUINT32_SWAP_LE_BE(uint32);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPT_BIG_ENDIAN:
|
||||||
|
uint32 = GUINT32_FROM_BE(uint32);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPT_LITTLE_ENDIAN:
|
||||||
|
uint32 = GUINT32_FROM_LE(uint32);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/*
|
||||||
|
* This should not happen - this is called by pcapng_process_options(),
|
||||||
|
* which returns an error for an invalid byte_order argument, and
|
||||||
|
* otherwise passes the known-to-be-valid byte_order argument to
|
||||||
|
* us.
|
||||||
|
*
|
||||||
|
* Just ignore the option.
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this option can appear only once in a block, this call
|
* If this option can appear only once in a block, this call
|
||||||
* will fail on the second and later occurrences of the option;
|
* will fail on the second and later occurrences of the option;
|
||||||
* we silently ignore the failure.
|
* we silently ignore the failure.
|
||||||
*/
|
*/
|
||||||
wtap_block_add_uint32_option(wblock->block, option_code, option_content);
|
wtap_block_add_uint32_option(wblock->block, option_code, uint32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1597,7 +1639,6 @@ pcapng_process_packet_block_option(wtapng_block_t *wblock,
|
||||||
const guint8 *option_content,
|
const guint8 *option_content,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
guint32 tmp32;
|
|
||||||
guint64 tmp64;
|
guint64 tmp64;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1626,15 +1667,10 @@ pcapng_process_packet_block_option(wtapng_block_t *wblock,
|
||||||
/* XXX - free anything? */
|
/* XXX - free anything? */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* Don't cast a guint8 * into a guint32 *--the
|
pcapng_process_uint32_option(wblock, section_info,
|
||||||
* guint8 * may not point to something that's
|
OPT_SECTION_BYTE_ORDER,
|
||||||
* aligned correctly.
|
option_code, option_length,
|
||||||
*/
|
option_content);
|
||||||
memcpy(&tmp32, option_content, sizeof(guint32));
|
|
||||||
if (section_info->byte_swapped)
|
|
||||||
tmp32 = GUINT32_SWAP_LE_BE(tmp32);
|
|
||||||
pcapng_process_uint32_option(wblock, option_code, option_length, tmp32);
|
|
||||||
ws_debug("pack_flags 0x%08x", tmp32);
|
|
||||||
break;
|
break;
|
||||||
case(OPT_EPB_HASH):
|
case(OPT_EPB_HASH):
|
||||||
ws_debug("epb_hash %u currently not handled - ignoring %u bytes",
|
ws_debug("epb_hash %u currently not handled - ignoring %u bytes",
|
||||||
|
@ -1674,15 +1710,10 @@ pcapng_process_packet_block_option(wtapng_block_t *wblock,
|
||||||
/* XXX - free anything? */
|
/* XXX - free anything? */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* Don't cast a guint8 * into a guint32 *--the
|
pcapng_process_uint32_option(wblock, section_info,
|
||||||
* guint8 * may not point to something that's
|
OPT_SECTION_BYTE_ORDER,
|
||||||
* aligned correctly.
|
option_code, option_length,
|
||||||
*/
|
option_content);
|
||||||
memcpy(&tmp32, option_content, sizeof(guint32));
|
|
||||||
if (section_info->byte_swapped)
|
|
||||||
tmp32 = GUINT32_SWAP_LE_BE(tmp32);
|
|
||||||
pcapng_process_uint32_option(wblock, option_code, option_length, tmp32);
|
|
||||||
ws_debug("queue %u", tmp32);
|
|
||||||
break;
|
break;
|
||||||
case(OPT_EPB_VERDICT):
|
case(OPT_EPB_VERDICT):
|
||||||
if (option_length < 1) {
|
if (option_length < 1) {
|
||||||
|
|
|
@ -156,8 +156,10 @@ void pcapng_process_uint8_option(wtapng_block_t *wblock,
|
||||||
|
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
void pcapng_process_uint32_option(wtapng_block_t *wblock,
|
void pcapng_process_uint32_option(wtapng_block_t *wblock,
|
||||||
|
const section_info_t *section_info,
|
||||||
|
pcapng_opt_byte_order_e byte_order,
|
||||||
guint16 option_code, guint16 option_length,
|
guint16 option_code, guint16 option_length,
|
||||||
guint32 option_content);
|
const guint8 *option_content);
|
||||||
|
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
void pcapng_process_timestamp_option(wtapng_block_t *wblock,
|
void pcapng_process_timestamp_option(wtapng_block_t *wblock,
|
||||||
|
|
Loading…
Reference in New Issue