Add callback that will act on signaling messages.
Signed-off-by: Maciek Machnikowski <[email protected]>
---
phc2sys.c | 4 ++--
pmc_agent.c | 17 ++++++++++++++++-
pmc_agent.h | 7 +++++--
ts2phc.c | 2 +-
4 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/phc2sys.c b/phc2sys.c
index 19e8012..16fd335 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1329,7 +1329,7 @@ int main(int argc, char *argv[])
if (autocfg) {
if (init_pmc_node(cfg, priv.agent, uds_local,
- phc2sys_recv_subscribed, &priv))
+ phc2sys_recv_subscribed, &priv, NULL, NULL))
goto end;
if (auto_init_ports(&priv, rt) < 0)
goto end;
@@ -1346,7 +1346,7 @@ int main(int argc, char *argv[])
if (wait_sync) {
if (init_pmc_node(cfg, priv.agent, uds_local,
- phc2sys_recv_subscribed, &priv))
+ phc2sys_recv_subscribed, &priv, NULL, NULL))
goto end;
while (is_running()) {
diff --git a/pmc_agent.c b/pmc_agent.c
index 62d1a86..b9e3371 100644
--- a/pmc_agent.c
+++ b/pmc_agent.c
@@ -49,6 +49,10 @@ struct pmc_agent {
/* Callback on message reception */
pmc_node_recv_subscribed_t *recv_subscribed;
void *recv_context;
+
+ /* Callback on signaling message reception */
+ pmc_node_recv_subscribed_t *recv_signaling;
+ void *signaling_context;
};
static void send_subscription(struct pmc_agent *node)
@@ -178,6 +182,12 @@ static int run_pmc(struct pmc_agent *node, int timeout,
int ds_id,
node->pmc_ds_requested = 0;
return RUN_PMC_NODEV;
}
+
+ if (msg_type(*msg) == SIGNALING && node->recv_signaling) {
+ node->recv_signaling(node->signaling_context, *msg,
+ ds_id);
+ }
+
if (res <= 0 ||
node->recv_subscribed(node->recv_context, *msg, ds_id) ||
management_tlv_id(*msg) != ds_id) {
@@ -230,7 +240,9 @@ int run_pmc_wait_sync(struct pmc_agent *node, int timeout)
}
int init_pmc_node(struct config *cfg, struct pmc_agent *node, const char *uds,
- pmc_node_recv_subscribed_t *recv_subscribed, void *context)
+ pmc_node_recv_subscribed_t *recv_subscribed, void *context,
+ pmc_node_recv_subscribed_t *signaling_subscribed,
+ void *signaling_context)
{
node->pmc = pmc_create(cfg, TRANS_UDS, uds, 0,
config_get_int(cfg, NULL, "domainNumber"),
@@ -242,6 +254,9 @@ int init_pmc_node(struct config *cfg, struct pmc_agent
*node, const char *uds,
node->recv_subscribed = recv_subscribed;
node->recv_context = context;
+ node->recv_signaling = signaling_subscribed;
+ node->signaling_context = signaling_context;
+
return 0;
}
diff --git a/pmc_agent.h b/pmc_agent.h
index 2fb1cc8..8a418ef 100644
--- a/pmc_agent.h
+++ b/pmc_agent.h
@@ -32,8 +32,11 @@ struct pmc_agent;
typedef int pmc_node_recv_subscribed_t(void *context, struct ptp_message *msg,
int excluded);
-int init_pmc_node(struct config *cfg, struct pmc_agent *agent, const char *uds,
- pmc_node_recv_subscribed_t *recv_subscribed, void *context);
+int init_pmc_node(struct config *cfg, struct pmc_agent *node, const char *uds,
+ pmc_node_recv_subscribed_t *recv_subscribed, void *context,
+ pmc_node_recv_subscribed_t *signaling_subscribed,
+ void *signaling_context);
+
int run_pmc_wait_sync(struct pmc_agent *agent, int timeout);
/**
diff --git a/ts2phc.c b/ts2phc.c
index 4393059..b83ba3a 100644
--- a/ts2phc.c
+++ b/ts2phc.c
@@ -668,7 +668,7 @@ int main(int argc, char *argv[])
if (autocfg) {
err = init_pmc_node(cfg, priv.agent, uds_local,
- ts2phc_recv_subscribed, &priv);
+ ts2phc_recv_subscribed, &priv, NULL, NULL);
if (err) {
ts2phc_cleanup(&priv);
return -1;
--
2.30.2
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel