Move more Netflix BBLog stuff out of common wiretap code and headers.

Remove Netflix BBLog stuff from wtap_custom_block_header.  Put it in the
custom block mandatory data.

Remove proto_bblog from epan/dissectors/packet-frame.c - it's not used
there.

No need to include wiretap/pcapng-netflix-custom.h in epan/packet.c

Move NFLX_BLOCK_TYPE_EVENT and NFLX_BLOCK_TYPE_SKIP to
wiretap/pcapng-netflix-custom.h.  Now that they're public, there's no
need to map them to BBLOG_TYPE_EVENT_BLOCK and BBLOG_TYPE_SKIPPED_BLOCK,
so get rid of the latter.

No need to include pcapng-netflix-custom.h in wiretap/wtap_opttypes.c.

This eliminates two enums provided to Lua programs,
BBLOG_TYPE_EVENT_BLOCK and BBLOG_TYPE_SKIPPED_BLOCK; those are the only
two defines for Netflix BBLog blocks and options, so it's not clear how
much use they would provide to Lua scripts.
This commit is contained in:
Guy Harris 2025-06-06 19:15:15 -07:00
parent 195acd3fff
commit c22f2b9999
9 changed files with 51 additions and 38 deletions

View File

@ -487,18 +487,22 @@ dissect_bblog_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d
static int
dissect_bblog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
wtapng_nflx_custom_mandatory_t *bblog_cb_mand;
bblog_cb_mand = (wtapng_nflx_custom_mandatory_t *)wtap_block_get_mandatory_data(pinfo->rec->block);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BBLog");
switch (pinfo->rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.type) {
case BBLOG_TYPE_SKIPPED_BLOCK:
switch (bblog_cb_mand->type) {
case NFLX_BLOCK_TYPE_SKIP:
col_add_fstr(pinfo->cinfo, COL_INFO, "Number of skipped events: %u",
pinfo->rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.skipped);
bblog_cb_mand->skipped);
break;
case BBLOG_TYPE_EVENT_BLOCK:
case NFLX_BLOCK_TYPE_EVENT:
dissect_bblog_event(tvb, pinfo, tree, data);
break;
default:
col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown type: %u",
pinfo->rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.type);
bblog_cb_mand->type);
break;
}
return tvb_captured_length(tvb);

View File

@ -45,7 +45,6 @@ void proto_reg_handoff_frame(void);
static int proto_frame;
static int proto_pkt_comment;
static int proto_syscall;
static int proto_bblog;
static int hf_frame_arrival_time_local;
static int hf_frame_arrival_time_utc;
@ -1592,7 +1591,6 @@ proto_register_frame(void)
proto_register_alias(proto_pkt_comment, "pkt_comment");
}
proto_syscall = proto_register_protocol("System Call", "Syscall", "syscall");
proto_bblog = proto_get_id_by_filter_name("bblog");
proto_register_field_array(proto_frame, hf, array_length(hf));
proto_register_field_array(proto_frame, &hf_encap, 1);

View File

@ -40,8 +40,6 @@
#include <epan/prefs.h>
#include <epan/range.h>
#include <wiretap/pcapng-netflix-custom.h>
#include <wsutil/str_util.h>
#include <wsutil/wslog.h>
#include <wsutil/ws_assert.h>

View File

@ -2078,8 +2078,6 @@
["ATM_NO_HEC"] = 2,
["ATM_RAW_CELL"] = 1,
["ATM_REASSEMBLY_ERROR"] = 8,
["BBLOG_TYPE_EVENT_BLOCK"] = 1,
["BBLOG_TYPE_SKIPPED_BLOCK"] = 2,
["BLOCK_NOT_SUPPORTED"] = 0,
["BTHCI_CHANNEL_ACL"] = 2,
["BTHCI_CHANNEL_COMMAND"] = 1,

View File

@ -37,8 +37,6 @@ static ws_enum_t const all_enums[] = {
ENUM(ATM_NO_HEC),
ENUM(ATM_RAW_CELL),
ENUM(ATM_REASSEMBLY_ERROR),
ENUM(BBLOG_TYPE_EVENT_BLOCK),
ENUM(BBLOG_TYPE_SKIPPED_BLOCK),
ENUM(BLOCK_NOT_SUPPORTED),
ENUM(BTHCI_CHANNEL_ACL),
ENUM(BTHCI_CHANNEL_COMMAND),

View File

@ -14,9 +14,6 @@
#include "pcapng_module.h"
#include "pcapng-netflix-custom.h"
#define NFLX_BLOCK_TYPE_EVENT 1
#define NFLX_BLOCK_TYPE_SKIP 2
/*
* Per-section information managed and used for Netflix BBLog blocks
* and options.
@ -249,6 +246,7 @@ pcapng_read_nflx_custom_block(FILE_T fh, section_info_t *section_info,
pcapng_nflx_custom_block_t nflx_cb;
unsigned opt_cont_buf_len;
uint32_t type, skipped;
wtapng_nflx_custom_mandatory_t *mandatory_data;
/*
* Set the record type name for this particular type of custom
@ -268,7 +266,14 @@ pcapng_read_nflx_custom_block(FILE_T fh, section_info_t *section_info,
ws_debug("Failed to read nflx type");
return false;
}
/*
* Allocate mandatory data.
*/
wblock->block->mandatory_data = g_new0(wtapng_nflx_custom_mandatory_t, 1);
mandatory_data = (wtapng_nflx_custom_mandatory_t *)wblock->block->mandatory_data;
type = GUINT32_FROM_LE(nflx_cb.nflx_type);
mandatory_data->type = type;
ws_debug("BBLog type: %u", type);
switch (type) {
case NFLX_BLOCK_TYPE_EVENT:
@ -276,7 +281,6 @@ pcapng_read_nflx_custom_block(FILE_T fh, section_info_t *section_info,
* The fixed-length portion is MIN_NFLX_CB_SIZE bytes.
* We already know we have that much data in the block.
*/
wblock->rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.type = BBLOG_TYPE_EVENT_BLOCK;
opt_cont_buf_len = wblock->rec->rec_header.custom_block_header.length - MIN_NFLX_CB_SIZE;
ws_debug("event");
break;
@ -300,14 +304,15 @@ pcapng_read_nflx_custom_block(FILE_T fh, section_info_t *section_info,
}
wblock->rec->presence_flags = 0;
wblock->rec->rec_header.custom_block_header.length = 4;
wblock->rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.type = BBLOG_TYPE_SKIPPED_BLOCK;
wblock->rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.skipped = GUINT32_FROM_LE(skipped);
mandatory_data->skipped = GUINT32_FROM_LE(skipped);
wblock->internal = false;
opt_cont_buf_len = wblock->rec->rec_header.custom_block_header.length - MIN_NFLX_CB_SIZE - sizeof(uint32_t);
ws_debug("skipped: %u", wblock->rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.skipped);
ws_debug("skipped: %u", mandatory_data->skipped);
break;
default:
ws_debug("Unknown type %u", type);
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("pcapng Netflix BBLog block: unknown type %u", type);
return false;
}
@ -365,6 +370,11 @@ pcapng_process_nflx_custom_option(wtapng_block_t *wblock,
case NFLX_OPT_TYPE_TCPINFO:
ws_debug("BBLog tcpinfo of length: %u", length);
if (wblock->type == BLOCK_TYPE_CB_COPY) {
/*
* This is in a BBlog custom block; we append the option's
* value to the data of the block, and use times from
* the option to set the time stamp.
*/
ws_buffer_assure_space(&wblock->rec->data, length);
wblock->rec->rec_header.custom_block_header.length = length + 4;
memcpy(ws_buffer_start_ptr(&wblock->rec->data), value, length);
@ -424,6 +434,7 @@ pcapng_write_nflx_custom_block(wtap_dumper *wdh, const wtap_rec *rec, int *err,
pcapng_block_header_t bh;
uint32_t options_size = 0;
uint32_t pen, skipped, type;
wtapng_nflx_custom_mandatory_t *mandatory_data;
/*
* Compute size of all the options.
@ -433,14 +444,16 @@ pcapng_write_nflx_custom_block(wtap_dumper *wdh, const wtap_rec *rec, int *err,
*/
options_size = pcapng_compute_options_size(rec->block, NULL);
mandatory_data = (wtapng_nflx_custom_mandatory_t *)rec->block->mandatory_data;
/* write block header */
bh.block_type = BLOCK_TYPE_CB_COPY;
bh.block_total_length = (uint32_t)(sizeof(bh) + sizeof(uint32_t) + sizeof(uint32_t) + options_size + 4);
if (rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.type == BBLOG_TYPE_SKIPPED_BLOCK) {
if (mandatory_data->type == NFLX_BLOCK_TYPE_SKIP) {
bh.block_total_length += (uint32_t)sizeof(uint32_t);
}
ws_debug("writing %u bytes, type %u",
bh.block_total_length, rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.type);
bh.block_total_length, mandatory_data->type);
if (!wtap_dump_file_write(wdh, &bh, sizeof(bh), err)) {
return false;
}
@ -453,18 +466,18 @@ pcapng_write_nflx_custom_block(wtap_dumper *wdh, const wtap_rec *rec, int *err,
ws_debug("wrote PEN = %u", pen);
/* write type */
type = GUINT32_TO_LE(rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.type);
type = GUINT32_TO_LE(mandatory_data->type);
if (!wtap_dump_file_write(wdh, &type, sizeof(uint32_t), err)) {
return false;
}
ws_debug("wrote type = %u", rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.type);
ws_debug("wrote type = %u", mandatory_data->type);
if (rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.type == BBLOG_TYPE_SKIPPED_BLOCK) {
skipped = GUINT32_TO_LE(rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.skipped);
if (mandatory_data->type == NFLX_BLOCK_TYPE_SKIP) {
skipped = GUINT32_TO_LE(mandatory_data->skipped);
if (!wtap_dump_file_write(wdh, &skipped, sizeof(uint32_t), err)) {
return false;
}
ws_debug("wrote skipped = %u", rec->rec_header.custom_block_header.custom_data_header.nflx_custom_data_header.skipped);
ws_debug("wrote skipped = %u", mandatory_data->skipped);
}
/* Write options, if we have any */

View File

@ -21,6 +21,20 @@ extern "C" {
*/
#define PEN_NFLX 10949
/*
* Netflix BBLog custom block types.
*/
#define NFLX_BLOCK_TYPE_EVENT 1
#define NFLX_BLOCK_TYPE_SKIP 2
/*
* Mandatory data for a Netflix WTAP_BLOCK_CUSTOM.
*/
typedef struct nflx {
uint32_t type; /* block type */
uint32_t skipped; /* Used if type == NFLX_BLOCK_TYPE_SKIP */
} wtapng_nflx_custom_mandatory_t;
#define NFLX_OPT_TYPE_VERSION 1
#define NFLX_OPT_TYPE_TCPINFO 2
#define NFLX_OPT_TYPE_DUMPINFO 4

View File

@ -1396,17 +1396,8 @@ typedef struct {
uint32_t pen; /* private enterprise number */
uint32_t length; /* length of the Custom Data plus options */
bool copy_allowed; /* CB can be written */
union {
struct nflx {
uint32_t type; /* block type */
uint32_t skipped; /* Used if type == BBLOG_TYPE_SKIPPED_BLOCK */
} nflx_custom_data_header;
} custom_data_header;
} wtap_custom_block_header;
#define BBLOG_TYPE_EVENT_BLOCK 1
#define BBLOG_TYPE_SKIPPED_BLOCK 2
/*
* The largest nstime.secs value that can be put into an unsigned
* 32-bit quantity.
@ -1452,7 +1443,7 @@ typedef struct wtap_rec {
* XXX - some if not all of the rec_header information may belong
* here, or may already be here. Eliminating rec_header in favor
* of this might simplify the process of adding new record/block
* types.
* types. For example, some of it might belong in block->mandaory_data.
*
* It also has a type field that's somewhat equivalent to rec_type.
*

View File

@ -17,7 +17,6 @@
#include "wtap.h"
#include "wtap-int.h"
#include "pcapng_module.h"
#include "pcapng-netflix-custom.h"
#include <wsutil/ws_assert.h>
#include <wsutil/glib-compat.h>