pmc: Subscribe to port state push notification events when requested.
Allow interactive input like set SUBSCRIBE_EVENTS_NP duration 60 NOTIFY_PORT_STATE on to request push notifications from the ptp4l service. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
e6d52c54e9
commit
1044268e85
25
pmc_common.c
25
pmc_common.c
|
@ -21,6 +21,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "notification.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "tlv.h"
|
#include "tlv.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
|
@ -106,6 +107,7 @@ struct management_id idtab[] = {
|
||||||
{ "PRIMARY_DOMAIN", TLV_PRIMARY_DOMAIN, not_supported },
|
{ "PRIMARY_DOMAIN", TLV_PRIMARY_DOMAIN, not_supported },
|
||||||
{ "TIME_STATUS_NP", TLV_TIME_STATUS_NP, do_get_action },
|
{ "TIME_STATUS_NP", TLV_TIME_STATUS_NP, do_get_action },
|
||||||
{ "GRANDMASTER_SETTINGS_NP", TLV_GRANDMASTER_SETTINGS_NP, do_set_action },
|
{ "GRANDMASTER_SETTINGS_NP", TLV_GRANDMASTER_SETTINGS_NP, do_set_action },
|
||||||
|
{ "SUBSCRIBE_EVENTS_NP", TLV_SUBSCRIBE_EVENTS_NP, do_set_action },
|
||||||
/* Port management ID values */
|
/* Port management ID values */
|
||||||
{ "NULL_MANAGEMENT", TLV_NULL_MANAGEMENT, null_management },
|
{ "NULL_MANAGEMENT", TLV_NULL_MANAGEMENT, null_management },
|
||||||
{ "CLOCK_DESCRIPTION", TLV_CLOCK_DESCRIPTION, do_get_action },
|
{ "CLOCK_DESCRIPTION", TLV_CLOCK_DESCRIPTION, do_get_action },
|
||||||
|
@ -139,12 +141,13 @@ static void do_get_action(struct pmc *pmc, int action, int index, char *str)
|
||||||
|
|
||||||
static void do_set_action(struct pmc *pmc, int action, int index, char *str)
|
static void do_set_action(struct pmc *pmc, int action, int index, char *str)
|
||||||
{
|
{
|
||||||
|
int cnt, code = idtab[index].code, freq_traceable, leap_59, leap_61,
|
||||||
|
ptp_timescale, time_traceable, utc_off_valid;
|
||||||
struct grandmaster_settings_np gsn;
|
struct grandmaster_settings_np gsn;
|
||||||
struct management_tlv_datum mtd;
|
struct management_tlv_datum mtd;
|
||||||
|
struct subscribe_events_np sen;
|
||||||
struct port_ds_np pnp;
|
struct port_ds_np pnp;
|
||||||
int cnt, code = idtab[index].code;
|
char onoff[4] = {0};
|
||||||
int leap_61, leap_59, utc_off_valid;
|
|
||||||
int ptp_timescale, time_traceable, freq_traceable;
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case GET:
|
case GET:
|
||||||
|
@ -215,6 +218,22 @@ static void do_set_action(struct pmc *pmc, int action, int index, char *str)
|
||||||
gsn.time_flags |= FREQ_TRACEABLE;
|
gsn.time_flags |= FREQ_TRACEABLE;
|
||||||
pmc_send_set_action(pmc, code, &gsn, sizeof(gsn));
|
pmc_send_set_action(pmc, code, &gsn, sizeof(gsn));
|
||||||
break;
|
break;
|
||||||
|
case TLV_SUBSCRIBE_EVENTS_NP:
|
||||||
|
memset(&sen, 0, sizeof(sen));
|
||||||
|
cnt = sscanf(str, " %*s %*s "
|
||||||
|
"duration %hu "
|
||||||
|
"NOTIFY_PORT_STATE %3s ",
|
||||||
|
&sen.duration, onoff);
|
||||||
|
if (cnt != 2) {
|
||||||
|
fprintf(stderr, "%s SET needs 2 values\n",
|
||||||
|
idtab[index].name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!strcasecmp(onoff, "on")) {
|
||||||
|
sen.bitmask[0] = 1 << NOTIFY_PORT_STATE;
|
||||||
|
}
|
||||||
|
pmc_send_set_action(pmc, code, &sen, sizeof(sen));
|
||||||
|
break;
|
||||||
case TLV_PORT_DATA_SET_NP:
|
case TLV_PORT_DATA_SET_NP:
|
||||||
cnt = sscanf(str, " %*s %*s "
|
cnt = sscanf(str, " %*s %*s "
|
||||||
"neighborPropDelayThresh %u "
|
"neighborPropDelayThresh %u "
|
||||||
|
|
Loading…
Reference in New Issue