NetSim Source Code Help
Loading...
Searching...
No Matches
NetSim_utility.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "stdarg.h"
#include "Linux.h"
#include <time.h>
#include <stdint.h>
Include dependency graph for NetSim_utility.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  stru_pcap_writer
 
struct  stru_wireshark_trace
 

Macros

#define _CRT_SECURE_NO_DEPRECATE
 
#define _CRT_SECURE_NO_WARNINGS
 
#define NETSIM_UTILITY_EXPORT   extern
 
#define SET_BIT(val, bitIndex)   ((val) |= (1 << (bitIndex)))
 
#define SET_BIT_64(val, bitIndex)   ((val) |= (1i64 << (bitIndex)))
 
#define CLEAR_BIT(val, bitIndex)   ((val) &= ~(1 << (bitIndex)))
 
#define CLEAR_BIT_64(val, bitIndex)   ((val) &= ~(1i64 << (bitIndex)))
 
#define TOGGLE_BIT(val, bitIndex)   ((val) ^= (1 << (bitIndex)))
 
#define TOGGLE_BIT_64(val, bitIndex)   ((val) ^= (1i64 << (bitIndex)))
 
#define BIT_IS_SET(val, bitIndex)   ((val) & (1 << (bitIndex)))
 
#define BIT_IS_SET_64(val, bitIndex)   ((val) & (1i64 << (bitIndex)))
 
#define LSHIFTCHAR(x, eposition)   ((UINT8)(x << (8 - eposition)))
 
#define RSHIFTCHAR(x, eposition)   ((UINT8)(x >> (8 - eposition)))
 
#define htonll(x)   ((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
 

Typedefs

typedef struct stru_pcap_writer PCAP_WRITER
 
typedef struct stru_pcap_writerPPCAP_WRITER
 
typedef struct stru_wireshark_trace WIRESHARKTRACE
 
typedef struct stru_wireshark_tracePWIRESHARKTRACE
 

Functions

void fnGetFilePath (char *name, char *path)
 
int fnParseOption (int count, char *arg[], char *opt)
 
void GetTimeStr (char *date, int len)
 
FILE * open_log_file (char *filename, char *mode)
 
int close_log_file (FILE *fp)
 
int ReportLog (FILE *fp, const char *msg,...)
 
char * rstrip (char *s)
 
char * lskip (const char *s)
 
char * find_char_or_comment (const char *s, char c)
 
char * strncpy0 (char *dest, const char *src, size_t size)
 
char * find_word (char **s)
 
bool startsWith (const char *str, const char *pre)
 
void init_time ()
 
uint64_t em_current_time ()
 
void em_init_time (void)
 
struct tm get_start_time ()
 
void usleep (__int64 usec)
 
char * get_filename_without_extension (char *filename)
 
void create_wireshark_filter (__out char *filter, __in int len, __in char *src_ip, __in char *dst_ip)
 
void call_wireshark (int duration, char *filter_string)
 
void * open_pcap_file (const char *filename, char *pipename, uint32_t network)
 
void write_to_pcap (void *handle, unsigned char *packet, unsigned int len, double *dTime)
 
void close_pcap_file (void *pcap_handle)
 
int isBitSet (unsigned int num, int index)
 
unsigned int setBit (unsigned int num, int index)
 
unsigned int unsetBit (unsigned int num, int index)
 
UINT64 hex_to_decimal (char hex[])
 
char * hex_to_binary (char *hex, char *bin)
 
void binary_to_hex (char *bin, char *hex)
 
UINT64 binary_to_decimal (char bin[])
 
UINT8 maskChar (UINT8 sposition, UINT8 eposition)
 
bool find_interaction (double arg1[2], double arg2[2], double intersection[2])
 
void netsim_matlab_interface_configure (char *appPath)
 
void netsim_matlab_interface_close ()
 
void netsim_matlab_send_command (void *command, int len)
 
void netsim_matlab_send_ascii_command (char *format,...)
 
bool netsim_matlab_get_value (char *out, int outLen, char *name, char *type)
 

Variables

NETSIM_UTILITY_EXPORT WIRESHARKTRACE wireshark_trace
 

Macro Definition Documentation

◆ _CRT_SECURE_NO_DEPRECATE

#define _CRT_SECURE_NO_DEPRECATE

Definition at line 30 of file NetSim_utility.h.

◆ _CRT_SECURE_NO_WARNINGS

#define _CRT_SECURE_NO_WARNINGS

Definition at line 33 of file NetSim_utility.h.

◆ BIT_IS_SET

#define BIT_IS_SET (   val,
  bitIndex 
)    ((val) & (1 << (bitIndex)))

Definition at line 160 of file NetSim_utility.h.

◆ BIT_IS_SET_64

#define BIT_IS_SET_64 (   val,
  bitIndex 
)    ((val) & (1i64 << (bitIndex)))

Definition at line 161 of file NetSim_utility.h.

◆ CLEAR_BIT

#define CLEAR_BIT (   val,
  bitIndex 
)    ((val) &= ~(1 << (bitIndex)))

Definition at line 156 of file NetSim_utility.h.

◆ CLEAR_BIT_64

#define CLEAR_BIT_64 (   val,
  bitIndex 
)    ((val) &= ~(1i64 << (bitIndex)))

Definition at line 157 of file NetSim_utility.h.

◆ htonll

#define htonll (   x)    ((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))

Definition at line 165 of file NetSim_utility.h.

◆ LSHIFTCHAR

#define LSHIFTCHAR (   x,
  eposition 
)    ((UINT8)(x << (8 - eposition)))

Definition at line 162 of file NetSim_utility.h.

◆ NETSIM_UTILITY_EXPORT

#define NETSIM_UTILITY_EXPORT   extern

Definition at line 63 of file NetSim_utility.h.

◆ RSHIFTCHAR

#define RSHIFTCHAR (   x,
  eposition 
)    ((UINT8)(x >> (8 - eposition)))

Definition at line 163 of file NetSim_utility.h.

◆ SET_BIT

#define SET_BIT (   val,
  bitIndex 
)    ((val) |= (1 << (bitIndex)))

Definition at line 154 of file NetSim_utility.h.

◆ SET_BIT_64

#define SET_BIT_64 (   val,
  bitIndex 
)    ((val) |= (1i64 << (bitIndex)))

Definition at line 155 of file NetSim_utility.h.

◆ TOGGLE_BIT

#define TOGGLE_BIT (   val,
  bitIndex 
)    ((val) ^= (1 << (bitIndex)))

Definition at line 158 of file NetSim_utility.h.

◆ TOGGLE_BIT_64

#define TOGGLE_BIT_64 (   val,
  bitIndex 
)    ((val) ^= (1i64 << (bitIndex)))

Definition at line 159 of file NetSim_utility.h.

Typedef Documentation

◆ PCAP_WRITER

typedef struct stru_pcap_writer PCAP_WRITER

◆ PPCAP_WRITER

typedef struct stru_pcap_writer* PPCAP_WRITER

◆ PWIRESHARKTRACE

◆ WIRESHARKTRACE

Function Documentation

◆ binary_to_decimal()

UINT64 binary_to_decimal ( char  bin[])
Here is the caller graph for this function:

◆ binary_to_hex()

void binary_to_hex ( char *  bin,
char *  hex 
)

◆ call_wireshark()

void call_wireshark ( int  duration,
char *  filter_string 
)

◆ close_log_file()

int close_log_file ( FILE *  fp)

◆ close_pcap_file()

void close_pcap_file ( void *  pcap_handle)

◆ create_wireshark_filter()

void create_wireshark_filter ( __out char *  filter,
__in int  len,
__in char *  src_ip,
__in char *  dst_ip 
)

◆ em_current_time()

uint64_t em_current_time ( )

◆ em_init_time()

void em_init_time ( void  )

◆ find_char_or_comment()

char * find_char_or_comment ( const char *  s,
char  c 
)

◆ find_interaction()

bool find_interaction ( double  arg1[2],
double  arg2[2],
double  intersection[2] 
)

◆ find_word()

char * find_word ( char **  s)
Here is the caller graph for this function:

◆ fnGetFilePath()

void fnGetFilePath ( char *  name,
char *  path 
)

◆ fnParseOption()

int fnParseOption ( int  count,
char *  arg[],
char *  opt 
)

◆ get_filename_without_extension()

char * get_filename_without_extension ( char *  filename)

◆ get_start_time()

struct tm get_start_time ( )

◆ GetTimeStr()

void GetTimeStr ( char *  date,
int  len 
)

◆ hex_to_binary()

char * hex_to_binary ( char *  hex,
char *  bin 
)

◆ hex_to_decimal()

UINT64 hex_to_decimal ( char  hex[])

◆ init_time()

void init_time ( )

◆ isBitSet()

int isBitSet ( unsigned int  num,
int  index 
)
Here is the caller graph for this function:

◆ lskip()

char * lskip ( const char *  s)
Here is the caller graph for this function:

◆ maskChar()

UINT8 maskChar ( UINT8  sposition,
UINT8  eposition 
)
Here is the caller graph for this function:

◆ netsim_matlab_get_value()

bool netsim_matlab_get_value ( char *  out,
int  outLen,
char *  name,
char *  type 
)
Here is the caller graph for this function:

◆ netsim_matlab_interface_close()

void netsim_matlab_interface_close ( )
Here is the caller graph for this function:

◆ netsim_matlab_interface_configure()

void netsim_matlab_interface_configure ( char *  appPath)

◆ netsim_matlab_send_ascii_command()

void netsim_matlab_send_ascii_command ( char *  format,
  ... 
)
Here is the caller graph for this function:

◆ netsim_matlab_send_command()

void netsim_matlab_send_command ( void *  command,
int  len 
)

◆ open_log_file()

FILE * open_log_file ( char *  filename,
char *  mode 
)

◆ open_pcap_file()

void * open_pcap_file ( const char *  filename,
char *  pipename,
uint32_t  network 
)

◆ ReportLog()

int ReportLog ( FILE *  fp,
const char *  msg,
  ... 
)

◆ rstrip()

char * rstrip ( char *  s)
Here is the caller graph for this function:

◆ setBit()

unsigned int setBit ( unsigned int  num,
int  index 
)

◆ startsWith()

bool startsWith ( const char *  str,
const char *  pre 
)

◆ strncpy0()

char * strncpy0 ( char *  dest,
const char *  src,
size_t  size 
)

◆ unsetBit()

unsigned int unsetBit ( unsigned int  num,
int  index 
)

◆ usleep()

void usleep ( __int64  usec)

◆ write_to_pcap()

void write_to_pcap ( void *  handle,
unsigned char *  packet,
unsigned int  len,
double *  dTime 
)

Variable Documentation

◆ wireshark_trace

Definition at line 82 of file NetSim_utility.h.