Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Functions
randpkt_core.h File Reference
#include <glib.h>
#include "wiretap/wtap.h"

Go to the source code of this file.

Classes

struct  randpkt_example
 

Functions

unsigned randpkt_example_count (void)
 Return the count of active examples.
 
void randpkt_example_list (char ***abbrev_list, char ***longname_list)
 Returns the list of active examples, including their abbreviations and long names.
 
int randpkt_parse_type (char *string)
 Parse command-line option "type" and return enum type.
 
randpkt_examplerandpkt_find_example (int type)
 Find pkt_example record and return pointer to it.
 
int randpkt_example_init (randpkt_example *example, char *produce_filename, int produce_max_bytes, int file_type_subtype)
 Initializes a random packet example with parameters for packet production.
 
void randpkt_loop (randpkt_example *example, uint64_t produce_count, uint64_t packet_delay_ms)
 Loops to produce a specified number of random packets with a given delay.
 
bool randpkt_example_close (randpkt_example *example)
 Closes a random packet example.
 

Detailed Description

randpkt_core.h

Creates random packet traces. Useful for debugging sniffers by testing assumptions about the veracity of the data found in the packet.

Copyright (C) 1999 by Gilbert Ramirez gram@.nosp@m.alum.nosp@m.ni.ri.nosp@m.ce.e.nosp@m.du

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

Function Documentation

◆ randpkt_example_close()

bool randpkt_example_close ( randpkt_example example)

Closes a random packet example.

This function closes the specified random packet example, ensuring all resources are properly released.

Parameters
examplePointer to the randpkt_example structure to be closed.
Returns
true if the close operation was successful, false otherwise.

◆ randpkt_example_count()

unsigned randpkt_example_count ( void  )

Return the count of active examples.

Returns
The number of active examples.

◆ randpkt_example_init()

int randpkt_example_init ( randpkt_example example,
char *  produce_filename,
int  produce_max_bytes,
int  file_type_subtype 
)

Initializes a random packet example with parameters for packet production.

This function initializes the necessary structures and opens the file or standard output to begin producing random packets.

Parameters
examplePointer to the randpkt_example structure to be initialized.
produce_filenameThe filename where packets will be written, or "-" for stdout.
produce_max_bytesThe maximum number of bytes per packet.
file_type_subtypeThe type and subtype of the file format.
Returns
0 on success, non-zero on failure.

◆ randpkt_example_list()

void randpkt_example_list ( char ***  abbrev_list,
char ***  longname_list 
)

Returns the list of active examples, including their abbreviations and long names.

Parameters
abbrev_listPointer to a list where the abbreviations of the examples will be stored.
longname_listPointer to a list where the long names of the examples will be stored.

◆ randpkt_find_example()

randpkt_example * randpkt_find_example ( int  type)

Find pkt_example record and return pointer to it.

Parameters
typeThe type of the example to find.
Returns
randpkt_example* A pointer to the found pkt_example record, or NULL if not found.

◆ randpkt_loop()

void randpkt_loop ( randpkt_example example,
uint64_t  produce_count,
uint64_t  packet_delay_ms 
)

Loops to produce a specified number of random packets with a given delay.

This function generates and sends a series of random packets, each delayed by a specified amount of time.

Parameters
examplePointer to the randpkt_example structure containing configuration and state information.
produce_countThe number of packets to generate and send.
packet_delay_msThe delay in milliseconds between sending each packet.

◆ randpkt_parse_type()

int randpkt_parse_type ( char *  string)

Parse command-line option "type" and return enum type.

Parameters
stringThe string to parse, which may be NULL or empty to indicate a random type.
Returns
The enum type corresponding to the string, or a random type if the string is NULL or empty. Returns -1 if the type is not known.