Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
capture_opts.h File Reference
#include <sys/types.h>
#include <capture/capture_ifinfo.h>
#include <wsutil/wslog.h>
#include <wsutil/filter_files.h>

Go to the source code of this file.

Classes

struct  interface_tag
 
struct  link_row_tag
 
struct  interface_options_tag
 
struct  capture_options_tag
 

Macros

#define LONGOPT_LIST_TSTAMP_TYPES   LONGOPT_BASE_CAPTURE+1
 
#define LONGOPT_SET_TSTAMP_TYPE   LONGOPT_BASE_CAPTURE+2
 
#define LONGOPT_COMPRESS_TYPE   LONGOPT_BASE_CAPTURE+3
 
#define LONGOPT_CAPTURE_TMPDIR   LONGOPT_BASE_CAPTURE+4
 
#define LONGOPT_UPDATE_INTERVAL   LONGOPT_BASE_CAPTURE+5
 
#define LONGOPT_NO_OPTIMIZE   LONGOPT_BASE_CAPTURE+6
 
#define OPTSTRING_A
 
#define OPTSTRING_B   "B:"
 
#define OPTSTRING_I   "I"
 
#define LONGOPT_CAPTURE_COMMON
 
#define OPTSTRING_CAPTURE_COMMON    "a:" OPTSTRING_A "b:" OPTSTRING_B "c:Df:F:i:" OPTSTRING_I "Lps:y:"
 
#define DEFAULT_CAPTURE_BUFFER_SIZE   2
 

Typedefs

typedef struct interface_tag interface_t
 
typedef struct link_row_tag link_row
 
typedef struct interface_options_tag interface_options
 
typedef struct capture_options_tag capture_options
 

Enumerations

enum  caps_query { CAPS_QUERY_LINK_TYPES = 0x1 , CAPS_QUERY_TIMESTAMP_TYPES = 0x2 }
 Bitmask flags selecting which interface capability sets to query from a capture device. More...
 

Functions

void capture_opts_init (capture_options *capture_opts, const char *app_name, GList *(*get_iface_list)(int *, char **))
 
void capture_opts_cleanup (capture_options *capture_opts)
 Clean up capture options.
 
int capture_opts_add_opt (const char *app_env_var_prefix, capture_options *capture_opts, int opt, const char *ws_optarg)
 Set a command line option value.
 
void capture_opts_log (const char *domain, enum ws_log_level level, capture_options *capture_opts)
 Log the content of capture_opts.
 
void capture_opts_list_file_types (void)
 Lists available file types for capture options.
 
int capture_opts_print_if_capabilities (if_capabilities_t *caps, const interface_options *interface_opts, int queries)
 Prints the capabilities of a network interface.
 
void capture_opts_print_interfaces (GList *if_list)
 Prints a list of available network interfaces.
 
void capture_opts_trim_snaplen (capture_options *capture_opts, int snaplen_min)
 Trims the snapshot length of a capture options structure to ensure it meets a minimum value.
 
void capture_opts_trim_ring_num_files (capture_options *capture_opts)
 Trims the number of ring buffer files to a valid range.
 
int capture_opts_default_iface_if_necessary (capture_options *capture_opts, const char *capture_device)
 Set the default capture interface if necessary.
 
void capture_opts_del_iface (capture_options *capture_opts, unsigned if_index)
 Deletes an interface from the capture options.
 
void interface_opts_free (interface_options *interface_opts)
 Free memory allocated for interface options.
 
interface_optionsinterface_opts_from_if_info (capture_options *capture_opts, const if_info_t *if_info)
 Collects network interfaces based on the provided capture options.
 
void collect_ifaces (capture_options *capture_opts)
 Collects network interfaces based on the provided capture options.
 
void capture_opts_free_link_row (void *elem)
 Frees a link row element.
 
void capture_opts_free_interface_t (interface_t *device)
 Frees an interface_t element.
 

Detailed Description

Capture options (all parameters needed to do the actual capture)

Macro Definition Documentation

◆ LONGOPT_CAPTURE_COMMON

#define LONGOPT_CAPTURE_COMMON
Value:
{"autostop", ws_required_argument, NULL, 'a'}, \
{"ring-buffer", ws_required_argument, NULL, 'b'}, \
{"buffer-size", ws_required_argument, NULL, 'B'}, \
{"list-interfaces", ws_no_argument, NULL, 'D'}, \
{"list-sources", ws_no_argument, NULL, 'D'}, \
{"interface", ws_required_argument, NULL, 'i'}, \
{"source", ws_required_argument, NULL, 'i'}, \
{"monitor-mode", ws_no_argument, NULL, 'I'}, \
{"list-data-link-types", ws_no_argument, NULL, 'L'}, \
{"no-promiscuous-mode", ws_no_argument, NULL, 'p'}, \
{"snapshot-length", ws_required_argument, NULL, 's'}, \
{"linktype", ws_required_argument, NULL, 'y'}, \
{"list-time-stamp-types", ws_no_argument, NULL, LONGOPT_LIST_TSTAMP_TYPES}, \
{"no-optimize", ws_no_argument, NULL, LONGOPT_NO_OPTIMIZE}, \
{"time-stamp-type", ws_required_argument, NULL, LONGOPT_SET_TSTAMP_TYPE}, \
{"compress-type", ws_required_argument, NULL, LONGOPT_COMPRESS_TYPE}, \
{"temp-dir", ws_required_argument, NULL, LONGOPT_CAPTURE_TMPDIR},\
{"update-interval", ws_required_argument, NULL, LONGOPT_UPDATE_INTERVAL},

Typedef Documentation

◆ capture_options

Capture options coming from user interface

Enumeration Type Documentation

◆ caps_query

enum caps_query

Bitmask flags selecting which interface capability sets to query from a capture device.

Enumerator
CAPS_QUERY_LINK_TYPES 

Query the set of supported data link types (DLTs)

CAPS_QUERY_TIMESTAMP_TYPES 

Query the set of supported timestamp types

Function Documentation

◆ capture_opts_add_opt()

int capture_opts_add_opt ( const char *  app_env_var_prefix,
capture_options capture_opts,
int  opt,
const char *  ws_optarg 
)
extern

Set a command line option value.

Parameters
app_env_var_prefixThe prefix for the application environment variables.
capture_optsPointer to the capture options structure.
optThe option to set.
ws_optargThe argument for the option.
Returns
0 on success, non-zero on failure.

◆ capture_opts_cleanup()

void capture_opts_cleanup ( capture_options capture_opts)
extern

Clean up capture options.

Parameters
capture_optsPointer to the capture options structure to clean up.

◆ capture_opts_default_iface_if_necessary()

int capture_opts_default_iface_if_necessary ( capture_options capture_opts,
const char *  capture_device 
)
extern

Set the default capture interface if necessary.

Parameters
capture_optsPointer to the capture options structure.
capture_deviceThe name of the capture device to use.
Returns
0 if the default interface was set successfully, non-zero otherwise.

◆ capture_opts_del_iface()

void capture_opts_del_iface ( capture_options capture_opts,
unsigned  if_index 
)
extern

Deletes an interface from the capture options.

Parameters
capture_optsPointer to the capture options structure.
if_indexIndex of the interface to be deleted.

◆ capture_opts_free_interface_t()

void capture_opts_free_interface_t ( interface_t device)
extern

Frees an interface_t element.

Parameters
devicePointer to the interface_t element to be freed.

◆ capture_opts_free_link_row()

void capture_opts_free_link_row ( void *  elem)
extern

Frees a link row element.

Parameters
elemPointer to the link_row element to be freed.

◆ capture_opts_init()

void capture_opts_init ( capture_options capture_opts,
const char *  app_name,
GList *(*)(int *, char **)  get_iface_list 
)
extern

Initialize the capture_options with some reasonable values, and provide a routine it can use to fetch a list of capture options if it needs it.

(Getting that list might involve running dumpcap, so we don't want to waste time doing that if we don't have to.)

Parameters
capture_optsPointer to the capture options structure to initialize.
app_nameThe application name that will be passed to dumpcap.
get_iface_listA function pointer to a routine that can be called to get the list of capture interfaces. This routine should return a GList of interface options and set the provided error parameters if it fails.

◆ capture_opts_list_file_types()

void capture_opts_list_file_types ( void  )
extern

Lists available file types for capture options.

List supported file types for capturing. This is intentionally smaller than the list supported by libwiretap (and dumpcap isn't linked with libwiretap.)

◆ capture_opts_log()

void capture_opts_log ( const char *  domain,
enum ws_log_level  level,
capture_options capture_opts 
)
extern

Log the content of capture_opts.

Parameters
domainThe logging domain.
levelThe logging level.
capture_optsPointer to the capture options structure to log.

◆ capture_opts_print_if_capabilities()

int capture_opts_print_if_capabilities ( if_capabilities_t caps,
const interface_options interface_opts,
int  queries 
)
extern

Prints the capabilities of a network interface.

Parameters
capsPointer to the interface capabilities structure.
interface_optsPointer to the interface options structure.
queriesNumber of queries related to the interface.
Returns
The number of capabilities printed.

◆ capture_opts_print_interfaces()

void capture_opts_print_interfaces ( GList *  if_list)
extern

Prints a list of available network interfaces.

Parameters
if_listA GList containing interface options to be printed.

◆ capture_opts_trim_ring_num_files()

void capture_opts_trim_ring_num_files ( capture_options capture_opts)
extern

Trims the number of ring buffer files to a valid range.

Parameters
capture_optsPointer to the capture options structure.

◆ capture_opts_trim_snaplen()

void capture_opts_trim_snaplen ( capture_options capture_opts,
int  snaplen_min 
)
extern

Trims the snapshot length of a capture options structure to ensure it meets a minimum value.

Parameters
capture_optsPointer to the capture options structure to be trimmed.
snaplen_minThe minimum allowed snapshot length.

◆ collect_ifaces()

void collect_ifaces ( capture_options capture_opts)
extern

Collects network interfaces based on the provided capture options.

Parameters
capture_optsPointer to the capture options structure.

◆ interface_opts_free()

void interface_opts_free ( interface_options interface_opts)
extern

Free memory allocated for interface options.

Parameters
interface_optsPointer to the interface options structure to be freed.

◆ interface_opts_from_if_info()

interface_options * interface_opts_from_if_info ( capture_options capture_opts,
const if_info_t if_info 
)
extern

Collects network interfaces based on the provided capture options.

Parameters
capture_optsPointer to the capture options structure.
if_infoPointer to the interface information structure.
Returns
A pointer to the interface options structure created from the provided interface information.