snmp4lptp: Added function for data collection from ptp4l program.
General function to use for sending signals for data collection from ptp4l program. Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>master
parent
68dcd10673
commit
1d0832b2f5
37
snmp4lptp.c
37
snmp4lptp.c
|
@ -17,6 +17,9 @@
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
#include <errno.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
#include <net-snmp/net-snmp-config.h>
|
#include <net-snmp/net-snmp-config.h>
|
||||||
#include <net-snmp/net-snmp-includes.h>
|
#include <net-snmp/net-snmp-includes.h>
|
||||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||||
|
@ -24,10 +27,44 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "pmc_common.h"
|
#include "pmc_common.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
|
#include "snmp4lptp_mib.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#define SNMP_NFD 1
|
||||||
static struct pmc *pmc;
|
static struct pmc *pmc;
|
||||||
|
|
||||||
|
struct ptp_message* snmp4lptp_run_pmc(char *cmd)
|
||||||
|
{
|
||||||
|
struct pollfd pollfd[SNMP_NFD];
|
||||||
|
int cnt, tmo = 100;
|
||||||
|
|
||||||
|
pollfd[0].fd = pmc_get_transport_fd(pmc);
|
||||||
|
pollfd[0].events = POLLIN | POLLPRI;
|
||||||
|
|
||||||
|
if (cmd && pmc_do_command(pmc, cmd)) {
|
||||||
|
pr_err("bad command: %s", cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (is_running()) {
|
||||||
|
cnt = poll(pollfd, SNMP_NFD, tmo);
|
||||||
|
if (cnt < 0) {
|
||||||
|
if (EINTR == errno) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
pr_emerg("poll failed");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (!cnt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pollfd[0].revents & (POLLIN|POLLPRI)) {
|
||||||
|
return pmc_recv(pmc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static int open_pmc(struct config *cfg)
|
static int open_pmc(struct config *cfg)
|
||||||
{
|
{
|
||||||
char uds_local[MAX_IFNAME_SIZE + 1];
|
char uds_local[MAX_IFNAME_SIZE + 1];
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/**
|
||||||
|
* @file snmp4lptp_mib.h
|
||||||
|
* @brief Common header file for all supported mibs in linuxptp
|
||||||
|
* @note Copyright (C) 2018 Anders Selhammer <anders.selhammer@est.tech>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_SNMP4LPTP_MIB_H
|
||||||
|
#define HAVE_SNMP4LPTP_MIB_H
|
||||||
|
|
||||||
|
#include "msg.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* function declarations
|
||||||
|
*/
|
||||||
|
struct ptp_message* snmp4lptp_run_pmc(char *cmd);
|
||||||
|
|
||||||
|
#endif /* HAVE_SNMP4LPTP_MIB_H */
|
Loading…
Reference in New Issue