Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
/builds/wireshark/wireshark/extcap_parser.h File Reference
#include <stdio.h>
#include <glib.h>
#include <string.h>
#include "ui/iface_toolbar.h"

Go to the source code of this file.

Classes

struct  _extcap_value
 A single selectable value option associated with a selector, radio, or multicheck argument. More...
 
struct  _extcap_complex
 A typed scalar value used to represent argument defaults and range bounds. More...
 
struct  _extcap_arg
 A fully parsed extcap argument sentence with all its associated options. More...
 
struct  _extcap_interface
 Describes a single capture interface advertised by an extcap binary. More...
 
struct  _extcap_dlt
 Describes a data link type (DLT) supported by an extcap interface. More...
 
struct  _extcap_token_sentence
 A single tokenized extcap output sentence with its key/value parameter map. More...
 

Macros

#define ENUM_KEY(s)   GUINT_TO_POINTER((unsigned)s)
 Casts an extcap_sentence_type or extcap_param_type to a GHashTable-compatible pointer key.
 
#define EXTCAP_PARAM_REQUIRED_SUFFICIENT   "sufficient"
 Special string for the required= parameter indicating the argument is sufficient (not strictly required).
 

Typedefs

typedef struct _extcap_value extcap_value
 A single selectable value option associated with a selector, radio, or multicheck argument.
 
typedef struct _extcap_complex extcap_complex
 A typed scalar value used to represent argument defaults and range bounds.
 
typedef struct _extcap_arg extcap_arg
 A fully parsed extcap argument sentence with all its associated options.
 
typedef struct _extcap_interface extcap_interface
 Describes a single capture interface advertised by an extcap binary.
 
typedef struct _extcap_dlt extcap_dlt
 Describes a data link type (DLT) supported by an extcap interface.
 
typedef struct _extcap_token_sentence extcap_token_sentence
 A single tokenized extcap output sentence with its key/value parameter map.
 

Enumerations

enum  extcap_sentence_type {
  EXTCAP_SENTENCE_UNKNOWN , EXTCAP_SENTENCE_ARG , EXTCAP_SENTENCE_VALUE , EXTCAP_SENTENCE_EXTCAP ,
  EXTCAP_SENTENCE_INTERFACE , EXTCAP_SENTENCE_DLT , EXTCAP_SENTENCE_CONTROL
}
 Identifies the type of a parsed extcap output sentence. More...
 
enum  extcap_arg_type {
  EXTCAP_ARG_UNKNOWN , EXTCAP_ARG_INTEGER , EXTCAP_ARG_UNSIGNED , EXTCAP_ARG_LONG ,
  EXTCAP_ARG_DOUBLE , EXTCAP_ARG_BOOLEAN , EXTCAP_ARG_BOOLFLAG , EXTCAP_ARG_STRING ,
  EXTCAP_ARG_PASSWORD , EXTCAP_ARG_SELECTOR , EXTCAP_ARG_EDIT_SELECTOR , EXTCAP_ARG_RADIO ,
  EXTCAP_ARG_MULTICHECK , EXTCAP_ARG_TABLE , EXTCAP_ARG_FILESELECT , EXTCAP_ARG_TIMESTAMP
}
 Data type of an extcap argument, controlling its GUI widget and value parsing. More...
 
enum  extcap_param_type {
  EXTCAP_PARAM_UNKNOWN , EXTCAP_PARAM_ARGNUM , EXTCAP_PARAM_CALL , EXTCAP_PARAM_DISPLAY ,
  EXTCAP_PARAM_TYPE , EXTCAP_PARAM_ARG , EXTCAP_PARAM_DEFAULT , EXTCAP_PARAM_VALUE ,
  EXTCAP_PARAM_RANGE , EXTCAP_PARAM_TOOLTIP , EXTCAP_PARAM_PLACEHOLDER , EXTCAP_PARAM_NAME ,
  EXTCAP_PARAM_ENABLED , EXTCAP_PARAM_FILE_MUSTEXIST , EXTCAP_PARAM_FILE_EXTENSION , EXTCAP_PARAM_GROUP ,
  EXTCAP_PARAM_PARENT , EXTCAP_PARAM_REQUIRED , EXTCAP_PARAM_RELOAD , EXTCAP_PARAM_CONFIGURABLE ,
  EXTCAP_PARAM_PREFIX , EXTCAP_PARAM_SAVE , EXTCAP_PARAM_VALIDATION , EXTCAP_PARAM_VERSION ,
  EXTCAP_PARAM_HELP , EXTCAP_PARAM_CONTROL , EXTCAP_PARAM_ROLE
}
 Token keys for key/value pairs within a parsed extcap sentence. More...
 

Functions

extcap_complexextcap_parse_complex (extcap_arg_type complex_type, const char *data)
 Parse a complex value from a string.
 
void extcap_free_complex (extcap_complex *comp)
 Free a complex value.
 
void extcap_printf_complex (extcap_complex *comp)
 Prints a complex type using its string representation.
 
char * extcap_get_complex_as_string (extcap_complex *comp)
 Get a string representation of a complex type.
 
int extcap_complex_get_int (extcap_complex *comp)
 Retrieves an integer value from an extcap complex structure.
 
unsigned extcap_complex_get_uint (extcap_complex *comp)
 Retrieves an unsigned integer value from an extcap complex structure.
 
int64_t extcap_complex_get_long (extcap_complex *comp)
 Retrieves a long value from an extcap complex structure.
 
double extcap_complex_get_double (extcap_complex *comp)
 Retrieves the double value from an extcap_complex structure.
 
bool extcap_complex_get_bool (extcap_complex *comp)
 Retrieves the boolean value from an extcap complex structure.
 
char * extcap_complex_get_string (extcap_complex *comp)
 Get the string value from an extcap complex structure.
 
bool extcap_compare_is_default (extcap_arg *element, extcap_complex *test)
 Compares an argument's default complex value with a test complex value.
 
void extcap_free_arg (extcap_arg *a)
 Free a single argument.
 
void extcap_free_toolbar_control (iface_toolbar_control *control)
 Free entire toolbar control structure.
 
void extcap_free_arg_list (GList *a)
 Free an entire arg list.
 
GList * extcap_parse_args (char *output)
 Parses arguments from extcap output.
 
GList * extcap_parse_values (char *output)
 Parse all sentences for values.
 
GList * extcap_parse_interfaces (char *output, GList **control_items)
 Parse all sentences for interfaces.
 
GList * extcap_parse_dlts (char *output)
 Parse all sentences for DLT (Data Link Type) information.
 

Detailed Description

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

Enumeration Type Documentation

◆ extcap_arg_type

Data type of an extcap argument, controlling its GUI widget and value parsing.

Enumerator
EXTCAP_ARG_UNKNOWN 

Unrecognized argument type

EXTCAP_ARG_INTEGER 

Signed integer value

EXTCAP_ARG_UNSIGNED 

Unsigned integer value

EXTCAP_ARG_LONG 

Long signed integer value

EXTCAP_ARG_DOUBLE 

Double-precision floating-point value

EXTCAP_ARG_BOOLEAN 

Boolean value rendered as a checkbox with an explicit true/false argument

EXTCAP_ARG_BOOLFLAG 

Boolean flag; the argument is omitted entirely when false

EXTCAP_ARG_STRING 

Free-form string value

EXTCAP_ARG_PASSWORD 

Sensitive string value; masked in the GUI and never saved to disk

EXTCAP_ARG_SELECTOR 

Drop-down selector populated from accompanying value sentences

EXTCAP_ARG_EDIT_SELECTOR 

Editable drop-down selector populated from accompanying value sentences

EXTCAP_ARG_RADIO 

Radio-button group populated from accompanying value sentences

EXTCAP_ARG_MULTICHECK 

Multi-select checkbox group populated from accompanying value sentences

EXTCAP_ARG_TABLE 

Tabular multi-row input populated from accompanying value sentences

EXTCAP_ARG_FILESELECT 

File path selector with an optional extension filter and existence check

EXTCAP_ARG_TIMESTAMP 

Date/time timestamp picker

◆ extcap_param_type

Token keys for key/value pairs within a parsed extcap sentence.

Enumerator
EXTCAP_PARAM_UNKNOWN 

Unrecognized parameter key

EXTCAP_PARAM_ARGNUM 

Argument number linking a value sentence to its parent arg sentence

EXTCAP_PARAM_CALL 

CLI flag name passed to the extcap binary

EXTCAP_PARAM_DISPLAY 

Human-readable label shown in the GUI

EXTCAP_PARAM_TYPE 

Argument type token (maps to extcap_arg_type)

EXTCAP_PARAM_ARG 

Argument number reference within a value or control sentence

EXTCAP_PARAM_DEFAULT 

Default value for the argument

EXTCAP_PARAM_VALUE 

Value payload for a value sentence

EXTCAP_PARAM_RANGE 

Valid numeric range for the argument (min,max)

EXTCAP_PARAM_TOOLTIP 

Tooltip text shown on hover in the GUI

EXTCAP_PARAM_PLACEHOLDER 

Placeholder text shown in an empty input widget

EXTCAP_PARAM_NAME 

Name of the extcap or interface

EXTCAP_PARAM_ENABLED 

Whether a value option is selectable in the GUI

EXTCAP_PARAM_FILE_MUSTEXIST 

If set, the selected file must already exist on disk

EXTCAP_PARAM_FILE_EXTENSION 

Comma-separated list of accepted file extensions for file selectors

EXTCAP_PARAM_GROUP 

GUI grouping label used to visually cluster related arguments

EXTCAP_PARAM_PARENT 

Parent argument call name for hierarchical value relationships

EXTCAP_PARAM_REQUIRED 

Whether the argument must be provided before capture can start

EXTCAP_PARAM_RELOAD 

If set, changing this argument triggers a reload of dependent arguments

EXTCAP_PARAM_CONFIGURABLE 

Whether the argument can be reconfigured during an active capture

EXTCAP_PARAM_PREFIX 

Optional prefix string prepended to the argument value on the CLI

EXTCAP_PARAM_SAVE 

Whether the argument value is persisted across capture sessions

EXTCAP_PARAM_VALIDATION 

Regular expression used to validate the argument's string value

EXTCAP_PARAM_VERSION 

Version string of the extcap binary

EXTCAP_PARAM_HELP 

URL or text pointing to help documentation for the extcap

EXTCAP_PARAM_CONTROL 

Control number linking a control sentence to toolbar actions

EXTCAP_PARAM_ROLE 

Role of a toolbar control (e.g., logger, message)

◆ extcap_sentence_type

Identifies the type of a parsed extcap output sentence.

Enumerator
EXTCAP_SENTENCE_UNKNOWN 

Unrecognized or malformed sentence

EXTCAP_SENTENCE_ARG 

Argument definition sentence

EXTCAP_SENTENCE_VALUE 

Value option sentence for a preceding argument

EXTCAP_SENTENCE_EXTCAP 

Top-level extcap metadata sentence (version, help)

EXTCAP_SENTENCE_INTERFACE 

Interface advertisement sentence

EXTCAP_SENTENCE_DLT 

Data link type (DLT) advertisement sentence

EXTCAP_SENTENCE_CONTROL 

Toolbar control definition sentence

Function Documentation

◆ extcap_compare_is_default()

bool extcap_compare_is_default ( extcap_arg element,
extcap_complex test 
)

Compares an argument's default complex value with a test complex value.

Parameters
elementThe extcap_arg structure containing the default complex value.
testThe extcap_complex structure to compare against the default.
Returns
true if the default complex value matches the test value, false otherwise.

◆ extcap_complex_get_bool()

bool extcap_complex_get_bool ( extcap_complex comp)

Retrieves the boolean value from an extcap complex structure.

Parameters
compPointer to the extcap_complex structure.
Returns
true if the value is valid andmatches a boolean regex, false otherwise.

◆ extcap_complex_get_double()

double extcap_complex_get_double ( extcap_complex comp)

Retrieves the double value from an extcap_complex structure.

Parameters
compPointer to the extcap_complex structure.
Returns
The double value, or 0 if the input is invalid.

◆ extcap_complex_get_int()

int extcap_complex_get_int ( extcap_complex comp)

Retrieves an integer value from an extcap complex structure.

Parameters
compPointer to the extcap_complex structure.
Returns
The integer value, or 0 if the input is invalid.

◆ extcap_complex_get_long()

int64_t extcap_complex_get_long ( extcap_complex comp)

Retrieves a long value from an extcap complex structure.

Parameters
compPointer to the extcap_complex structure.
Returns
The long value, or 0 if the input is invalid.

◆ extcap_complex_get_string()

char * extcap_complex_get_string ( extcap_complex comp)

Get the string value from an extcap complex structure.

Parameters
compPointer to the extcap_complex structure.
Returns
char* The string value, or NULL if the input is NULL.

◆ extcap_complex_get_uint()

unsigned extcap_complex_get_uint ( extcap_complex comp)

Retrieves an unsigned integer value from an extcap complex structure.

Parameters
compPointer to the extcap_complex structure.
Returns
The unsigned integer value, or 0 if the input is invalid.

◆ extcap_free_arg()

void extcap_free_arg ( extcap_arg a)

Free a single argument.

This function releases all resources associated with an extcap_arg structure, including freeing memory for its various fields and nested structures.

Parameters
aPointer to the extcap_arg structure to be freed.

◆ extcap_free_arg_list()

void extcap_free_arg_list ( GList *  a)

Free an entire arg list.

This function frees a GList containing extcap_arg structures, calling extcap_free_arg on each element.

Parameters
aThe GList to be freed.

◆ extcap_free_complex()

void extcap_free_complex ( extcap_complex comp)

Free a complex value.

Parameters
compPointer to the extcap_complex structure to be freed.

◆ extcap_free_toolbar_control()

void extcap_free_toolbar_control ( iface_toolbar_control control)

Free entire toolbar control structure.

Parameters
controlPointer to the toolbar control structure to be freed.

◆ extcap_get_complex_as_string()

char * extcap_get_complex_as_string ( extcap_complex comp)

Get a string representation of a complex type.

Returns
a string representation of a complex type
Note
Caller is responsible for calling g_free on the returned string

◆ extcap_parse_args()

GList * extcap_parse_args ( char *  output)

Parses arguments from extcap output.

Parser for extcap data

Parameters
outputThe output string to parse.
Returns
A GList of parsed extcap_args.

◆ extcap_parse_complex()

extcap_complex * extcap_parse_complex ( extcap_arg_type  complex_type,
const char *  data 
)

Parse a complex value from a string.

Parameters
complex_typeThe type of the complex value.
dataThe string representation of the complex value.
Returns
extcap_complex* A pointer to the newly created complex value, or NULL on failure.

◆ extcap_parse_dlts()

GList * extcap_parse_dlts ( char *  output)

Parse all sentences for DLT (Data Link Type) information.

This function tokenizes the input output into sentences and then parses each sentence to extract DLT information. It returns a GList containing parsed extcap_dlt structures.

Parameters
outputThe input string containing DLT information.
Returns
A GList of extcap_dlt structures representing the parsed DLTs, or NULL if parsing fails.

◆ extcap_parse_interfaces()

GList * extcap_parse_interfaces ( char *  output,
GList **  control_items 
)

Parse all sentences for interfaces.

This function parses the interfaces section of extcap output and returns a list of interface objects.

Parameters
outputThe extcap output string to parse.
control_itemsPointer to a GList containing control items for parsing.
Returns
A GList of parsed extcap_interface objects, or NULL if parsing fails.

◆ extcap_parse_values()

GList * extcap_parse_values ( char *  output)

Parse all sentences for values.

Parameters
outputThe output string containing sentences to parse.
Returns
GList* A list of parsed extcap_value structures.

◆ extcap_printf_complex()

void extcap_printf_complex ( extcap_complex comp)

Prints a complex type using its string representation.

Parameters
compPointer to the extcap_complex structure to be printed.