network_monitor.h File Reference

mptcpd network device monitoring. More...

`#include <mptcpd/export.h>`
`#include <net/if.h>`
Include dependency graph for network_monitor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes

struct | mptcpd_interface
| Network interface-specific information. More...
struct | mptcpd_nm_ops
| Network monitor event tracking operations. More...

## Typedefs

typedef void(* | mptcpd_nm_callback) (struct mptcpd_interface const *interface, void *callback_data)
| Network monitor iteration function type. More...

## Functions

MPTCPD_API struct mptcpd_nm * | mptcpd_nm_create (uint32_t flags)
| Create a network monitor. More...
MPTCPD_API void | mptcpd_nm_destroy (struct mptcpd_nm *nm)
| Destroy a network monitor. More...
MPTCPD_API void | mptcpd_nm_foreach_interface (struct mptcpd_nm const *nm, mptcpd_nm_callback callback, void *data)
| Iterate over all monitored network interfaces. More...
MPTCPD_API bool | mptcpd_nm_register_ops (struct mptcpd_nm *nm, struct mptcpd_nm_ops const *ops, void *user_data)
| Subscribe to mptcpd network monitor events. More...

## Detailed Description

mptcpd network device monitoring.

Copyright (c) 2017-2020, Intel Corporation

## Typedef Documentation

## mptcpd_nm_callback

typedef void(* mptcpd_nm_callback) (struct mptcpd_interface const *interface, void *callback_data)

Network monitor iteration function type.

The mptcpd network monitor will call a function of this type when iterating over the network interfaces via `mptcpd_nm_foreach_interface()`.

Parameters

  [in] | interface | Network interface information.
  [in,out] | callback_data | Data provided by the caller of `mptcpd_nm_foreach_interface()`.

## Function Documentation

## mptcpd_nm_create()

MPTCPD_API struct mptcpd_nm* mptcpd_nm_create | ( | uint32_t | flags | ) |

Create a network monitor.

Parameters

  [in] | flags | flags controlling address notification, any of: MPTCPD_NOTIFY_FLAG_EXISTING,, MPTCPD_NOTIFY_FLAG_SKIP_LL, MPTCPD_NOTIFY_FLAG_SKIP_HOST

Todo:
  As currently implemented, one could create multiple network monitors. Is that useful?

Returns
  Pointer to new network monitor on success. `NULL` on failure.

Get network interface information.

Note
  We force the second rtnetlink command, RTM_GETADDR, to be sent after this one completes by doing so in the destroy callback for this command. That guarantees that the potential multipart message response from this dump is fully read prior to sending the second command. This works around an issue in ELL where it was possible that the second command would be sent prior to receiving all of the parts of the multipart `RTM_GETLINK` response, which resulted in an EBUSY error.

## mptcpd_nm_destroy()

MPTCPD_API void mptcpd_nm_destroy | ( | struct mptcpd_nm * | nm | ) |

Destroy a network monitor.

Parameters

  [in,out] | nm | Network monitor to be destroyed.

## mptcpd_nm_foreach_interface()

MPTCPD_API void mptcpd_nm_foreach_interface | ( | struct mptcpd_nm const * | nm,
|  | mptcpd_nm_callback | callback,
|  | void * | data
| ) |  |

Iterate over all monitored network interfaces.

Parameters

  [in] | nm | Pointer to the mptcpd network monitor object.
  [in] | callback | Function to be called during each network interface iteration.
  [in] | data | Data to pass to the callback function during each iteration.

## mptcpd_nm_register_ops()

MPTCPD_API bool mptcpd_nm_register_ops | ( | struct mptcpd_nm * | nm,
|  | struct mptcpd_nm_ops const * | ops,
|  | void * | user_data
| ) |  |

Subscribe to mptcpd network monitor events.

Register a set of operations that will be called on a corresponding mptcpd network monitoring event, e.g. network interface or address addition, update, or removal.

Parameters

  [in,out] | nm | Pointer to the mptcpd network monitor object.
  [in] | ops | Set of network monitoring event handling functions.
  [in] | user_data | Data to be passed to the network event tracking operations.

Return values

  true | Registration succeeded.
  false | Registration failed.