Haka: include/haka/alert.h File Reference

Haka

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Enumerations | Functions
alert.h File Reference
`#include <haka/types.h>`
`#include <haka/time.h>`
`#include <haka/container/list.h>`

Go to the source code of this file.

## Data Structures
struct | alert_node
struct | alert
struct | alerter

## Macros
#define | ALERT(name, nsrc, ntgt)
#define | ENDALERT };
#define | ALERT_NODE(alert, name, index, type, ...)
#define | ALERT_REF(alert, count, ...)
#define | ALERT_METHOD_REF(alert, ...)

## Enumerations

## Functions
uint64 | alert (const struct alert *alert)
bool | alert_update (uint64 id, const struct alert *alert)
const char * | alert_level_to_str (alert_level level)
const char * | alert_completion_to_str (alert_completion completion)
const char * | alert_node_to_str (alert_node_type type)
const char * | alert_tostring (uint64 id, const struct time *time, const struct alert *alert, const char *header, const char *indent, bool color)
void | enable_stdout_alert (bool enable)
bool | add_alerter (struct alerter *alerter)
bool | remove_alerter (struct alerter *alerter)
void | remove_all_alerter ()

## Detailed Description

Security alerts.

## Macro Definition Documentation

#define ALERT | ( |  | name,
|  |  | nsrc,
|  |  | ntgt
| ) |  |

Value:
struct alert_node *_sources[nsrc+1] = {0}; \
struct alert_node *_targets[ntgt+1] = {0}; \
struct alert name = { \
sources: nsrc==0 ? NULL : _sources, \
targets: ntgt==0 ? NULL : _targets,
alert
Definition: alert.h:63
alert_node
Definition: alert.h:55

Utility macro to create a new alert.

Parameters

  name | Name of the variable that will be created.
  nsrc | Number of sources.
  ntgt | Number of targets.

#define ALERT_METHOD_REF | ( |  | alert,
|  |  | ...
| ) |  |

Value:
char *_method_ref[] = { __VA_ARGS__, NULL }; \
alert.method_ref = _method_ref
alert
uint64 alert(const struct alert *alert)
Definition: alert.c:142

Add method references.

Parameters

  alert | Alert name.
  ... | List of strings.

#define ALERT_NODE | ( |  | alert,
|  |  | name,
|  |  | index,
|  |  | type,
|  |  | ...
| ) |  |

Value:
struct alert_node _node##name##index = { type }; \
alert.name[index] = &_node##name##index; \
char *_node##name##index_list[] = { __VA_ARGS__, NULL }; \
_node##name##index.list = _node##name##index_list
alert_node::type
alert_node_type type
Definition: alert.h:56
alert
uint64 alert(const struct alert *alert)
Definition: alert.c:142
alert_node::list
char ** list
Definition: alert.h:57
alert_node
Definition: alert.h:55

Create an alert node.

Parameters

  alert | Alert name.
  name | `sources` or `target`.
  index | Index of the node.
  type | Type of node (see :c:type:`alert_node_type`).
  ... | List of strings.

#define ALERT_REF | ( |  | alert,
|  |  | count,
|  |  | ...
| ) |  |

Value:
uint64 _alert_ref[count] = { __VA_ARGS__ }; \
alert.alert_ref_count = count; \
alert.alert_ref = _alert_ref
alert
uint64 alert(const struct alert *alert)
Definition: alert.c:142
uint64
unsigned HAKA_64BIT_TYPE uint64
Definition: types.h:30

Add alert references.

Parameters

  alert | Alert name.
  count | Number of references.
  ... | List of alert ids.

#define ENDALERT };

Finish the alert creation.

## Enumeration Type Documentation

enum alert_completion

Alert completion.

Enumerator
HAKA_ALERT_COMPLETION_NONE | Unset value.
HAKA_ALERT_FAILED | The attack failed.
HAKA_ALERT_SUCCESSFUL | The attach was successful.
HAKA_ALERT_COMPLETION_LAST | Last alert completion value.

enum alert_level

Alert level.

Enumerator
HAKA_ALERT_LEVEL_NONE | Unset value.
HAKA_ALERT_LOW | Low level.
HAKA_ALERT_MEDIUM | Medium level.
HAKA_ALERT_HIGH | High level.
HAKA_ALERT_NUMERIC | Numeric level stored in the alert structure.
HAKA_ALERT_LEVEL_LAST | Last alert level.

enum alert_node_type

Alert node type.

Enumerator
HAKA_ALERT_NODE_ADDRESS | Address node.
HAKA_ALERT_NODE_SERVICE | Service node.
HAKA_ALERT_NODE_LAST | Last alert node type.

## Function Documentation

bool add_alerter | ( | struct alerter * | alerter | ) |

Add an alert listener.

uint64 alert | ( | const struct alert * | alert | ) |

Raise a new alert.

Returns
  The alert unique id.

const char* alert_completion_to_str | ( | alert_completion | completion | ) |

Convert alert completion to human readable string.

const char* alert_level_to_str | ( | alert_level | level | ) |

Convert alert level to human readable string.

const char* alert_node_to_str | ( | alert_node_type | type | ) |

Convert alert node to human readable string.

const char* alert_tostring | ( | uint64 | id,
|  | const struct time * | time,
|  | const struct alert * | alert,
|  | const char * | header,
|  | const char * | indent,
|  | bool | color
| ) |  |

Convert an alert to a string.

bool alert_update | ( | uint64 | id,
|  | const struct alert * | alert
| ) |  |

Update an existing alert.

void enable_stdout_alert | ( | bool | enable | ) |

Enable display of alerts on stdout.

bool remove_alerter | ( | struct alerter * | alerter | ) |

Remove an alert listener.

void remove_all_alerter | ( |  | ) |

Remove all alert listener.