Flowgrind
Advanced TCP traffic generator
fg_error.h File Reference

Error-reporting routines used by Flowgrind. More...

#include "config.h"
#include <errno.h>

Go to the source code of this file.

Macros

#define crit(...)   (error(ERR_CRIT, errno, __VA_ARGS__))
 To report an critical error w/ the corresponding system error message. More...
 
#define critc(code, ...)   (error(ERR_CRIT, code, __VA_ARGS__))
 To report an critical error w/ the system error message 'code'. More...
 
#define critx(...)   (error(ERR_CRIT, 0, __VA_ARGS__))
 To report an critical error w/o a system error message. More...
 
#define err(...)   (error(ERR_ERROR, errno, __VA_ARGS__))
 To report an error w/ the corresponding system error message. More...
 
#define errc(code, ...)   (error(ERR_ERROR, code, __VA_ARGS__))
 To report an error w/ the system error message 'code'. More...
 
#define errx(...)   (error(ERR_ERROR, 0, __VA_ARGS__))
 To report an error w/o a system error message. More...
 
#define warn(...)   (error(ERR_WARNING, errno, __VA_ARGS__))
 To report a warning w/ the corresponding system error message. More...
 
#define warnc(code, ...)   (error(ERR_WARNING, code, __VA_ARGS__))
 To report a warning w/ the system error message 'code'. More...
 
#define warnx(...)   (error(ERR_WARNING, 0, __VA_ARGS__))
 To report a warning w/ a system error message. More...
 

Enumerations

enum  error_levels { ERR_WARNING = 0, ERR_ERROR, ERR_CRIT }
 Error level, in order of increasing importance. More...
 

Functions

void error (enum error_levels level, int errnum, const char *fmt,...) __attribute__((format(printf
 General error-reporting function. More...
 

Detailed Description

Error-reporting routines used by Flowgrind.

Definition in file fg_error.h.

Macro Definition Documentation

◆ crit

#define crit (   ...)    (error(ERR_CRIT, errno, __VA_ARGS__))

To report an critical error w/ the corresponding system error message.

Definition at line 36 of file fg_error.h.

◆ critc

#define critc (   code,
  ... 
)    (error(ERR_CRIT, code, __VA_ARGS__))

To report an critical error w/ the system error message 'code'.

Definition at line 38 of file fg_error.h.

◆ critx

#define critx (   ...)    (error(ERR_CRIT, 0, __VA_ARGS__))

To report an critical error w/o a system error message.

Definition at line 40 of file fg_error.h.

◆ err

#define err (   ...)    (error(ERR_ERROR, errno, __VA_ARGS__))

To report an error w/ the corresponding system error message.

Definition at line 43 of file fg_error.h.

◆ errc

#define errc (   code,
  ... 
)    (error(ERR_ERROR, code, __VA_ARGS__))

To report an error w/ the system error message 'code'.

Definition at line 45 of file fg_error.h.

◆ errx

#define errx (   ...)    (error(ERR_ERROR, 0, __VA_ARGS__))

To report an error w/o a system error message.

Definition at line 47 of file fg_error.h.

◆ warn

#define warn (   ...)    (error(ERR_WARNING, errno, __VA_ARGS__))

To report a warning w/ the corresponding system error message.

Definition at line 50 of file fg_error.h.

◆ warnc

#define warnc (   code,
  ... 
)    (error(ERR_WARNING, code, __VA_ARGS__))

To report a warning w/ the system error message 'code'.

Definition at line 52 of file fg_error.h.

◆ warnx

#define warnx (   ...)    (error(ERR_WARNING, 0, __VA_ARGS__))

To report a warning w/ a system error message.

Definition at line 54 of file fg_error.h.

Enumeration Type Documentation

◆ error_levels

Error level, in order of increasing importance.

Enumerator
ERR_WARNING 

Warning conditions.

ERR_ERROR 

Error conditions.

ERR_CRIT 

Critical conditions.

Definition at line 57 of file fg_error.h.

57  {
59  ERR_WARNING = 0,
61  ERR_ERROR,
63  ERR_CRIT,
64 };

Function Documentation

◆ error()

void error ( enum error_levels  level,
int  errnum,
const char *  fmt,
  ... 
)

General error-reporting function.

It outputs to stderr the program name, a colon and a space, a fixed error message based on the error level, and a second colon and a space followed by the error message. If errnum is nonzero, a third colon and a space followed by the string given by strerror(errnum) is printed.

Parameters
[in]levelerror level. An error level higher then ERR_ERROR calls exit() to terminate using given status
[in]errnumerror number. If nonzero the corresponding system error message is printed
[in]fmterror message in printf-style format with optional args
ERR_CRIT
@ ERR_CRIT
Critical conditions.
Definition: fg_error.h:63
ERR_WARNING
@ ERR_WARNING
Warning conditions.
Definition: fg_error.h:59
ERR_ERROR
@ ERR_ERROR
Error conditions.
Definition: fg_error.h:61