Add network statistics to ddsrt
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
f9808c7656
commit
ecb77d481c
6 changed files with 483 additions and 1 deletions
73
src/ddsrt/include/dds/ddsrt/netstat.h
Normal file
73
src/ddsrt/include/dds/ddsrt/netstat.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright(c) 2019 ADLINK Technology Limited and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef DDSRT_NETSTAT_H
|
||||
#define DDSRT_NETSTAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
|
||||
#if defined (__linux) || defined (__APPLE__) || defined (_WIN32)
|
||||
#define DDSRT_HAVE_NETSTAT (1)
|
||||
#else
|
||||
#define DDSRT_HAVE_NETSTAT (0)
|
||||
#endif
|
||||
|
||||
#if DDSRT_HAVE_NETSTAT
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsrt_netstat {
|
||||
uint64_t ipkt;
|
||||
uint64_t opkt;
|
||||
uint64_t ibytes;
|
||||
uint64_t obytes;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Platform dependent control structure for network statistics
|
||||
*/
|
||||
struct ddsrt_netstat_control;
|
||||
|
||||
/**
|
||||
* @brief Prepare for gathering network statistics for specified interface.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
ddsrt_netstat_new (
|
||||
struct ddsrt_netstat_control **control,
|
||||
const char *device);
|
||||
|
||||
/**
|
||||
* @brief Release resources for gathering network statistics.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
ddsrt_netstat_free (
|
||||
struct ddsrt_netstat_control *control);
|
||||
|
||||
/**
|
||||
* @brief Get network statistics.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
ddsrt_netstat_get (
|
||||
struct ddsrt_netstat_control *control,
|
||||
struct ddsrt_netstat *stats);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_HAVE_NETSTAT */
|
||||
|
||||
#endif /* DDSRT_NETSTAT_H */
|
Loading…
Add table
Add a link
Reference in a new issue