From: Vincent Cheng <[email protected]>
Signed-off-by: Vincent Cheng <[email protected]>
---
unicast_client.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
unicast_client.h | 8 ++++++++
2 files changed, 58 insertions(+)
diff --git a/unicast_client.c b/unicast_client.c
index 4d6386e..7688814 100644
--- a/unicast_client.c
+++ b/unicast_client.c
@@ -64,6 +64,23 @@ static int attach_request(struct ptp_message *msg, int
log_period,
return 0;
}
+static int attach_cancel(struct ptp_message *msg, uint8_t message_type)
+{
+ struct cancel_unicast_xmit_tlv *req;
+ struct tlv_extra *extra;
+
+ extra = msg_tlv_append(msg, sizeof(*req));
+ if (!extra) {
+ return -1;
+ }
+ req = (struct cancel_unicast_xmit_tlv *) extra->tlv;
+ req->type = TLV_CANCEL_UNICAST_TRANSMISSION;
+ req->length = sizeof(*req) - sizeof(req->type) - sizeof(req->length);
+ req->message_type_flags = message_type << 4;
+
+ return 0;
+}
+
static int unicast_client_announce(struct port *p,
struct unicast_master_address *dst)
{
@@ -563,3 +580,36 @@ int unicast_client_unicast_master_table_received(struct
port *p, struct ptp_mess
return ucma ? 1 : 0;
}
+int unicast_client_tx_cancel(struct port *p,
+ struct unicast_master_address *dst)
+{
+ struct ptp_message *msg;
+ int err;
+
+ msg = port_signaling_uc_construct(p, &dst->address, &dst->portIdentity);
+ if (!msg) {
+ return -1;
+ }
+ err = attach_cancel(msg, ANNOUNCE);
+ if (err) {
+ goto out;
+ }
+ err = attach_cancel(msg, SYNC);
+ if (err) {
+ goto out;
+ }
+ if (p->delayMechanism != DM_P2P) {
+ err = attach_cancel(msg, DELAY_RESP);
+ if (err) {
+ goto out;
+ }
+ }
+
+ err = port_prepare_and_send(p, msg, TRANS_GENERAL);
+ if (err) {
+ pr_err("%s: signaling message failed", p->log_name);
+ }
+out:
+ msg_put(msg);
+ return err;
+}
diff --git a/unicast_client.h b/unicast_client.h
index b24c4eb..bb0f80a 100644
--- a/unicast_client.h
+++ b/unicast_client.h
@@ -93,4 +93,12 @@ int unicast_client_timer(struct port *p);
int unicast_client_unicast_master_table_received(struct port *p,
struct ptp_message *m);
+/**
+ * Transmit CANCEL_UNICAST_TRANSMISSION TLV to destination address.
+ * @param p The port in question.
+ * @param dst The destination address.
+ * @return Zero on success, non-zero otherwise.
+ */
+int unicast_client_tx_cancel(struct port *p,
+ struct unicast_master_address *dst);
#endif
--
2.34.1
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel