msg: Introduce a helper to test for unicast messages.
With increasing unicast support, the code needs to identify unicast messages more often. This patch replaces the open coded bit field tests with a more readable in line helper function call. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
28ddb51567
commit
ccfeb3b092
2
e2e_tc.c
2
e2e_tc.c
|
@ -147,7 +147,7 @@ enum fsm_event e2e_event(struct port *p, int fd_index)
|
||||||
if (msg_sots_valid(msg)) {
|
if (msg_sots_valid(msg)) {
|
||||||
ts_add(&msg->hwts.ts, -p->rx_timestamp_offset);
|
ts_add(&msg->hwts.ts, -p->rx_timestamp_offset);
|
||||||
}
|
}
|
||||||
if (msg->header.flagField[0] & UNICAST) {
|
if (msg_unicast(msg)) {
|
||||||
pl_warning(600, "cannot handle unicast messages!");
|
pl_warning(600, "cannot handle unicast messages!");
|
||||||
msg_put(msg);
|
msg_put(msg);
|
||||||
return EV_NONE;
|
return EV_NONE;
|
||||||
|
|
10
msg.h
10
msg.h
|
@ -394,6 +394,16 @@ static inline int msg_sots_valid(struct ptp_message *m)
|
||||||
return !tmv_is_zero(m->hwts.ts);
|
return !tmv_is_zero(m->hwts.ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether a message is a unicast message.
|
||||||
|
* @param m Message to test.
|
||||||
|
* @return One if the message is unicast, zero otherwise.
|
||||||
|
*/
|
||||||
|
static inline Boolean msg_unicast(struct ptp_message *m)
|
||||||
|
{
|
||||||
|
return field_is_set(m, 0, UNICAST);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Work around buggy 802.1AS switches.
|
* Work around buggy 802.1AS switches.
|
||||||
*/
|
*/
|
||||||
|
|
2
nsm.c
2
nsm.c
|
@ -138,7 +138,7 @@ static void nsm_handle_msg(struct nsm *nsm, struct ptp_message *msg, FILE *fp)
|
||||||
ntohs(nsm->nsm_delay_req->header.sequenceId)) {
|
ntohs(nsm->nsm_delay_req->header.sequenceId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(msg->header.flagField[0] & UNICAST)) {
|
if (!msg_unicast(msg)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
p2p_tc.c
2
p2p_tc.c
|
@ -150,7 +150,7 @@ enum fsm_event p2p_event(struct port *p, int fd_index)
|
||||||
if (msg_sots_valid(msg)) {
|
if (msg_sots_valid(msg)) {
|
||||||
ts_add(&msg->hwts.ts, -p->rx_timestamp_offset);
|
ts_add(&msg->hwts.ts, -p->rx_timestamp_offset);
|
||||||
}
|
}
|
||||||
if (msg->header.flagField[0] & UNICAST) {
|
if (msg_unicast(msg)) {
|
||||||
pl_warning(600, "cannot switch unicast messages!");
|
pl_warning(600, "cannot switch unicast messages!");
|
||||||
msg_put(msg);
|
msg_put(msg);
|
||||||
return EV_NONE;
|
return EV_NONE;
|
||||||
|
|
8
port.c
8
port.c
|
@ -697,7 +697,7 @@ static int port_nsm_reply(struct port *p, struct ptp_message *m)
|
||||||
if (!p->hybrid_e2e) {
|
if (!p->hybrid_e2e) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!(m->header.flagField[0] & UNICAST)) {
|
if (!msg_unicast(m)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
TAILQ_FOREACH(extra, &m->tlv_list, list) {
|
TAILQ_FOREACH(extra, &m->tlv_list, list) {
|
||||||
|
@ -1753,7 +1753,7 @@ static int process_delay_req(struct port *p, struct ptp_message *m)
|
||||||
|
|
||||||
msg->delay_resp.requestingPortIdentity = m->header.sourcePortIdentity;
|
msg->delay_resp.requestingPortIdentity = m->header.sourcePortIdentity;
|
||||||
|
|
||||||
if (p->hybrid_e2e && m->header.flagField[0] & UNICAST) {
|
if (p->hybrid_e2e && msg_unicast(m)) {
|
||||||
msg->address = m->address;
|
msg->address = m->address;
|
||||||
msg->header.flagField[0] |= UNICAST;
|
msg->header.flagField[0] |= UNICAST;
|
||||||
msg->header.logMessageInterval = 0x7f;
|
msg->header.logMessageInterval = 0x7f;
|
||||||
|
@ -1819,7 +1819,7 @@ void process_delay_resp(struct port *p, struct ptp_message *m)
|
||||||
if (p->logMinDelayReqInterval == rsp->hdr.logMessageInterval) {
|
if (p->logMinDelayReqInterval == rsp->hdr.logMessageInterval) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m->header.flagField[0] & UNICAST) {
|
if (msg_unicast(m)) {
|
||||||
/* Unicast responses have logMinDelayReqInterval set to 0x7F. */
|
/* Unicast responses have logMinDelayReqInterval set to 0x7F. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2563,7 +2563,7 @@ int port_prepare_and_send(struct port *p, struct ptp_message *msg,
|
||||||
if (msg_pre_send(msg)) {
|
if (msg_pre_send(msg)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (msg->header.flagField[0] & UNICAST) {
|
if (msg_unicast(msg)) {
|
||||||
cnt = transport_sendto(p->trp, &p->fda, event, msg);
|
cnt = transport_sendto(p->trp, &p->fda, event, msg);
|
||||||
} else {
|
} else {
|
||||||
cnt = transport_send(p->trp, &p->fda, event, msg);
|
cnt = transport_send(p->trp, &p->fda, event, msg);
|
||||||
|
|
Loading…
Reference in New Issue