Permalink
Browse files

Begin alarm support: lost sync, lost delay, domain mismatch + alarm d…

…efinitions
  • Loading branch information...
wowczarek committed Dec 11, 2015
1 parent 1c0124e commit 0d76afb2ffc6f4f3c5f6a73f10cbc2506a4bc4dc
Showing with 236 additions and 34 deletions.
  1. +1 −1 .gitignore
  2. +2 −0 src/Makefile.am
  3. +2 −0 src/constants.h
  4. +2 −0 src/datatypes.h
  5. +51 −0 src/dep/alarms.c
  6. +89 −0 src/dep/alarms.h
  7. +0 −27 src/dep/datatypes_dep.h
  8. +9 −3 src/dep/snmp.c
  9. +75 −2 src/protocol.c
  10. +2 −0 src/ptp_timers.c
  11. +2 −0 src/ptp_timers.h
  12. +0 −1 src/ptpd.c
  13. +1 −0 src/ptpd.h
View
@@ -9,7 +9,7 @@ Makefile
/autoscan-*.log
/aclocal.m4
/compile
/config.h.in
/config.h.in*
/configure
/configure.scan
/depcomp
View
@@ -59,6 +59,8 @@ ptpd2_SOURCES = \
dep/ntpengine/ntpdcontrol.h \
timingdomain.h \
timingdomain.c \
dep/alarms.h \
dep/alarms.c \
ptpd.c \
ptpd.h \
$(NULL)
View
@@ -460,6 +460,8 @@ enum {
"\x13\x1b\x5e\x11\x1b\x5d\x59\x59"\
"\x59\x59\x58\x58\x58\x58"
#define MISSED_MESSAGES_MAX 20 /* how long we wait to trigger a [sync/delay] receipt alarm */
/* constants used for unicast grant processing */
#define UNICAST_GRANT_REFRESH_INTERVAL 1
#define GRANT_NOT_FOUND -1
View
@@ -729,6 +729,8 @@ typedef struct {
UInteger8 domainNumber;
Boolean slaveOnly;
/* domain mismatch detection */
UInteger8 lastDomainSeen;
/* Current data set */
View
@@ -0,0 +1,51 @@
/*-
* Copyright (c) 2015 Wojciech Owczarek
*
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file alarms.c
* @authors Wojciech Owczarek
* @date Wed Dec 9 19:13:10 2015
* This souece file contains the implementations of functions
* handling raising and clearing alarms.
*/
#include "../ptpd.h"
AlarmEntry * getAlarms() {
static AlarmEntry alarms[] = {
{ "STATE", "PORT_STATE", "Port state different to expected value", { ALRM_PORT_STATE }},
{ "OFS", "OFM_THRESHOLD", "Offset From Master outside threshold", { ALRM_OFM_THRESHOLD }},
{ "OFSL", "OFM_SECONDS", "Offset From Master above 1 second", { ALRM_OFM_SECONDS }},
{ "STEP", "CLOCK_STEP", "Clock was stepped", { ALRM_CLOCK_STEP}}
};
return alarms;
}
View
@@ -0,0 +1,89 @@
#ifndef PTPDALARMS_H_
#define PTPDALARMS_H_
/*-
* Copyright (c) 2015 Wojciech Owczarek,
*
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file alarms.h
* @authors Wojciech Owczarek
* @date Wed Dec 9 19:13:10 2015
* Data type and function definitions related to
* handling raising and clearing alarms.
*/
typedef struct {
} PtpEventData;
typedef enum {
ALRM_PORT_STATE,
ALRM_OFM_THRESHOLD,
ALRM_OFM_SECONDS,
ALRM_CLOCK_STEP,
ALRM_NO_SYNC,
ALRM_NO_DELAY,
ALRM_MASTER_CHANGE,
ALRM_NETWORK_FLT,
ALRM_FAST_ADJ,
ALRM_TIMEPROP_CHANGE,
ALRM_DOMAIN_MISMATCH,
ALRM_MAX
} AlarmType;
typedef enum {
ALARM_UNSET = 0, /* idle */
ALARM_SET, /* condition has been triggerd */
ALARM_CLEARED /* condition has cleared */
} AlarmState;
typedef struct {
uint8_t id; /* alarm ID */
uint32_t age; /* age of alarm in current state (seconds) */
AlarmState state; /* state of the alarm */
Boolean condition; /* is the alarm condition met? (so we can check conditions and set alarms separately */
TimeInternal timeSet; /* time when set */
TimeInternal timeCleared; /* time when cleared */
Boolean eventOnly; /* this is only an event - don't manage state, just dispatch/inform when condition is met */
Boolean internalOnly; /* do not display in status file / indicate that the alarm is internal only */
PtpEventData eventData; /* the event data union - so we can capture any data we need without the need to capture a whole PtpClock */
} AlarmData;
typedef struct {
char shortName[5]; /* short code i.e. OFS, DLY, SYN, FLT etc. */
char name[31]; /* full name i.e. OFFSET_THRESHOLD, NO_DELAY, NO_SYNC etc. */
char description[101]; /* text description */
/* char *userHandle; */ /* pointer to user data associated with the alarm */
/* char userData[200]; */ /* or maybe some space to contain the data taken there and then */
AlarmData data; /* alarm data container (so it's easier to do a static initialisation */
} AlarmEntry;
AlarmEntry * getAlarms();
#endif /*PTPDALARMS_H_*/
View
@@ -84,33 +84,6 @@ typedef struct {
int ifIndex;
} InterfaceInfo;
typedef enum {
ALARM_UNSET,
ALARM_SET,
ALARM_CLEARED
} AlarmState;
typedef struct {
uint8_t id; /* alarm ID */
uint32_t age; /* age of alarm in current state (seconds) */
AlarmState state; /* state of the alarm */
Boolean condition; /* is the alarm condition met? (so we can check conditions and set alarms separately */
TimeInternal timeSet; /* time when set */
TimeInternal timeCleared; /* time when cleared */
Boolean eventOnly; /* this is only an event - don't manage state, just inform when condition is met */
} AlarmData;
typedef struct {
char shortName[5]; /* short code i.e. OFS, DLY, SYN, FLT etc. */
char name[31]; /* full name i.e. OFFSET_THRESHOLD, NO_DELAY, NO_SYNC etc. */
char description[101]; /* text description */
/* char *userHandle; */ /* pointer to user data associated with the alarm */
/* char userData[200]; */ /* or maybe some space to contain the data taken there and then */
AlarmData data; /* alarm data container (so it's easier to do a static initialisation */
} AlarmEntry;
/**
* \brief Struct describing network transport data
*/
View
@@ -254,7 +254,9 @@ enum {
PTPBASE_NOTIFS_FREQADJ_NORMAL,
PTPBASE_NOTIFS_OFFSET_SECONDS,
PTPBASE_NOTIFS_OFFSET_SUB_SECONDS,
PTPBASE_NOTIFS_TIMEPROPERTIESDS_CHANGE
PTPBASE_NOTIFS_TIMEPROPERTIESDS_CHANGE,
PTPBASE_NOTIFS_DOMAIN_MISMATCH,
PTPBASE_NOTIFS_DOMAIN_OK,
};
#define SNMP_PTP_ORDINARY_CLOCK 1
@@ -1769,7 +1771,7 @@ snmpLogCallback(int major, int minor,
return SNMP_ERR_NOERROR;
}
static const int
static int
getNotifIndex(int eventType) {
switch (eventType) {
@@ -1807,6 +1809,10 @@ getNotifIndex(int eventType) {
return 16;
case PTPBASE_NOTIFS_TIMEPROPERTIESDS_CHANGE:
return 17;
case PTPBASE_NOTIFS_DOMAIN_MISMATCH:
return 18;
case PTPBASE_NOTIFS_DOMAIN_OK:
return 18;
default:
return 0;
}
@@ -1887,7 +1893,7 @@ populateNotif (netsnmp_variable_list** varBinds, int eventType) {
ASN_INTEGER, (u_char *) &addrType, sizeof(addrType));
snmp_varlist_add_variable(varBinds, portAddrOid, OID_LENGTH(portAddrOid),
ASN_OCTET_STR, (u_char *) &snmpPtpClock->bestMaster->sourceAddr, sizeof(snmpPtpClock->bestMaster->sourceAddr));
ASN_OCTET_STR, (u_char *) &sa, sizeof(sa));
snmp_varlist_add_variable(varBinds, gmClockIdOid, OID_LENGTH(gmClockIdOid),
ASN_OCTET_STR, (u_char *) &snmpPtpClock->grandmasterIdentity, sizeof(ClockIdentity));
Oops, something went wrong.

0 comments on commit 0d76afb

Please sign in to comment.