Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions
/builds/wireshark/wireshark/sharkd.h File Reference
#include <file.h>
#include <wiretap/wtap_opttypes.h>

Go to the source code of this file.

Macros

#define SHARKD_DISSECT_FLAG_NULL   0x00u
 
#define SHARKD_DISSECT_FLAG_BYTES   0x01u
 
#define SHARKD_DISSECT_FLAG_COLUMNS   0x02u
 
#define SHARKD_DISSECT_FLAG_PROTO_TREE   0x04u
 
#define SHARKD_DISSECT_FLAG_COLOR   0x08u
 
#define SHARKD_MODE_CLASSIC_CONSOLE   1
 
#define SHARKD_MODE_CLASSIC_DAEMON   2
 
#define SHARKD_MODE_GOLD_CONSOLE   3
 
#define SHARKD_MODE_GOLD_DAEMON   4
 
#define LONGOPT_FOREGROUND   4000
 

Typedefs

typedef void(* sharkd_dissect_func_t) (epan_dissect_t *edt, proto_tree *tree, struct epan_column_info *cinfo, const GSList *data_src, void *data)
 

Enumerations

enum  dissect_request_status { DISSECT_REQUEST_SUCCESS , DISSECT_REQUEST_NO_SUCH_FRAME , DISSECT_REQUEST_READ_ERROR }
 Return status for a frame dissection request. More...
 

Functions

cf_status_t sharkd_cf_open (const char *fname, unsigned int type, bool is_tempfile, int *err)
 Open a capture file.
 
int sharkd_load_cap_file (void)
 Load a capture file without any limits.
 
int sharkd_load_cap_file_with_limits (int max_packet_count, int64_t max_byte_count)
 Load a capture file with specified limits.
 
int sharkd_retap (void)
 Retaps all packets in the current capture file.
 
int sharkd_filter (const char *dftext, uint8_t **result)
 Apply a display filter to the current capture file and return the results.
 
frame_datasharkd_get_frame (uint32_t framenum)
 Get a frame by its number.
 
enum dissect_request_status sharkd_dissect_request (uint32_t framenum, uint32_t frame_ref_num, uint32_t prev_dis_num, wtap_rec *rec, column_info *cinfo, uint32_t dissect_flags, sharkd_dissect_func_t cb, void *data, int *err, char **err_info)
 Dissects a request for packet data.
 
wtap_block_t sharkd_get_modified_block (const frame_data *fd)
 Get the modified packet block for a given frame, if available.
 
wtap_block_t sharkd_get_packet_block (const frame_data *fd)
 Get the packet block for a given frame.
 
int sharkd_set_modified_block (frame_data *fd, wtap_block_t new_block)
 Set a modified block for a frame.
 
const char * sharkd_version (void)
 Retrieves the version of the SharkD server.
 
const struct ws_optionsharkd_long_options (void)
 Get the long options for the sharkd daemon.
 
const char * sharkd_optstring (void)
 Get the string of valid options for the sharkd daemon.
 
int sharkd_init (int argc, char **argv)
 Initialize the sharkd server.
 
int sharkd_loop (int argc _U_, char *argv[] _U_)
 Main loop for the sharkd daemon.
 
int sharkd_session_main (int mode_setting)
 Main function for handling sharkd sessions.
 

Detailed Description

Copyright (C) 2016 Jakub Zawadzki

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

◆ dissect_request_status

Return status for a frame dissection request.

Enumerator
DISSECT_REQUEST_SUCCESS 

The requested frame was found and successfully dissected

DISSECT_REQUEST_NO_SUCH_FRAME 

The requested frame number does not exist in the capture

DISSECT_REQUEST_READ_ERROR 

The frame data could not be read due to an I/O error

Function Documentation

◆ sharkd_cf_open()

cf_status_t sharkd_cf_open ( const char *  fname,
unsigned int  type,
bool  is_tempfile,
int *  err 
)

Open a capture file.

Parameters
fnameThe filename of the capture file to open.
typeThe type of the capture file.
is_tempfileTrue if the file is a temporary file.
errPointer to an integer where error information will be stored.
Returns
cf_status_t The status of the operation.

◆ sharkd_dissect_request()

enum dissect_request_status sharkd_dissect_request ( uint32_t  framenum,
uint32_t  frame_ref_num,
uint32_t  prev_dis_num,
wtap_rec rec,
column_info cinfo,
uint32_t  dissect_flags,
sharkd_dissect_func_t  cb,
void *  data,
int *  err,
char **  err_info 
)

Dissects a request for packet data.

Parameters
framenumThe frame number to dissect.
frame_ref_numReference number of the frame.
prev_dis_numPrevious dissection number.
recPointer to the wtap_rec structure.
cinfoPointer to the column_info structure.
dissect_flagsFlags indicating how to perform the dissection.
cbCallback function for handling the dissection result.
dataUser data passed to the callback function.
errError code if an error occurs.
err_infoError information if an error occurs.
Returns
The status of the dissection request.

◆ sharkd_filter()

int sharkd_filter ( const char *  dftext,
uint8_t **  result 
)

Apply a display filter to the current capture file and return the results.

This function compiles the provided display filter text and applies it to all frames in the currently loaded capture file, returning a bit array indicating which frames match the filter.

Parameters
dftextThe display filter text to compile and apply.
resultPointer to a uint8_t array where the results will be stored. The caller is responsible for freeing this array. Each bit in the array corresponds to a frame, with a value of 1 indicating a match and 0 indicating no match.
Returns
The number of frames processed, or -1 if an error occurred during filter compilation or application.

◆ sharkd_get_frame()

frame_data * sharkd_get_frame ( uint32_t  framenum)

Get a frame by its number.

Parameters
framenumThe number of the frame to retrieve.
Returns
A pointer to the frame data if found, NULL otherwise.

◆ sharkd_get_modified_block()

wtap_block_t sharkd_get_modified_block ( const frame_data fd)

Get the modified packet block for a given frame, if available.

Parameters
fdPointer to the frame data structure.
Returns
The modified packet block, or NULL if no modification is available.

◆ sharkd_get_packet_block()

wtap_block_t sharkd_get_packet_block ( const frame_data fd)

Get the packet block for a given frame.

Parameters
fdPointer to the frame data structure.
Returns
The packet block, or NULL if an error occurred.

◆ sharkd_init()

int sharkd_init ( int  argc,
char **  argv 
)

Initialize the sharkd server.

This function initializes the sharkd server with command-line arguments.

Parameters
argcNumber of command-line arguments.
argvArray of command-line argument strings.
Returns
0 on success, -1 on failure.

◆ sharkd_load_cap_file()

int sharkd_load_cap_file ( void  )

Load a capture file without any limits.

This function loads a capture file into the current session without applying any packet or byte count limits.

Returns
0 on success, non-zero on failure.

◆ sharkd_load_cap_file_with_limits()

int sharkd_load_cap_file_with_limits ( int  max_packet_count,
int64_t  max_byte_count 
)

Load a capture file with specified limits.

This function loads a capture file into the current session with the specified packet and byte count limits.

Parameters
max_packet_countThe maximum number of packets to load.
max_byte_countThe maximum number of bytes to load.
Returns
0 on success, non-zero on failure.

◆ sharkd_long_options()

const struct ws_option * sharkd_long_options ( void  )

Get the long options for the sharkd daemon.

Returns
const struct ws_option* - An array of ws_option structures representing the long options for the sharkd daemon.

◆ sharkd_loop()

int sharkd_loop ( int argc  _U_,
char *argv[]  _U_ 
)

Main loop for the sharkd daemon.

This function runs the main loop for the sharkd daemon, processing incoming requests.

Parameters
argcNumber of command-line arguments.
argvArray of command-line argument strings.
Returns
int Return code indicating success or failure of the daemon.

◆ sharkd_optstring()

const char * sharkd_optstring ( void  )

Get the string of valid options for the sharkd daemon.

Returns
const char* - The string containing valid options.

◆ sharkd_retap()

int sharkd_retap ( void  )

Retaps all packets in the current capture file.

This function triggers a re-dissection of all packets in the currently loaded capture file, applying any active filters and taps.

Returns
0 on success, non-zero on failure.

◆ sharkd_session_main()

int sharkd_session_main ( int  mode_setting)

Main function for handling sharkd sessions.

This function initializes the session with a given mode setting and processes commands received from stdin.

Parameters
mode_settingThe mode in which the session should operate.
Returns
0 on success, non-zero for failure.

◆ sharkd_set_modified_block()

int sharkd_set_modified_block ( frame_data fd,
wtap_block_t  new_block 
)

Set a modified block for a frame.

Parameters
fdPointer to the frame data structure.
new_blockThe new block to set.
Returns
0 on success, -1 on failure.

◆ sharkd_version()

const char * sharkd_version ( void  )

Retrieves the version of the SharkD server.

Returns
A string representing the version of the SharkD server.