From b5199726a77402f1a3976053586dee5798022399 Mon Sep 17 00:00:00 2001 From: Casper Andersson Date: Sat, 20 Jan 2024 10:31:34 +0100 Subject: [PATCH] check: Cleanup and corrections Signed-off-by: Casper Andersson --- include/pkt.h | 2 -- src/check.c | 95 +++++++++++++++++---------------------------------- 2 files changed, 31 insertions(+), 66 deletions(-) diff --git a/include/pkt.h b/include/pkt.h index 45f5874..1b34464 100644 --- a/include/pkt.h +++ b/include/pkt.h @@ -6,12 +6,10 @@ struct pkt_cfg { //int so_timestamping_flags; int transportSpecific; int twoStepFlag_set; - int onestep_listen; int nonstop_flag; int twoStepFlag; int tstamp_all; int auto_fup; - int onestep; int rx_only; int version; int listen; diff --git a/src/check.c b/src/check.c index 899ee61..686e3bd 100644 --- a/src/check.c +++ b/src/check.c @@ -113,34 +113,26 @@ int check_software_timestamp(struct pkt_cfg *cfg, char *tx_iface, char *rx_iface int64_t ns; int err; - cfg->transportSpecific = 0; - cfg->onestep = 0; - cfg->version = 2 | (1 << 4); - cfg->domain = 0; cfg->tstype = TS_SOFTWARE; - cfg->seq = 0; - cfg->listen = 1; - cfg->twoStepFlag = 1; - /*str2mac("ff:ff:ff:ff:ff:ff", cfg->mac);*/ - str2mac("01:1B:19:00:00:00", cfg->mac); - /*str2mac("01:80:c2:00:00:0E", cfg->mac);*/ - /*memcpy(cfg->mac, buf, ETH_ALEN);*/ err = setup_sockets(cfg, tx_iface, rx_iface, &txsock, &rxsock); if (err) return err; - err = 0; + str2mac("01:1B:19:00:00:00", cfg->mac); err |= check_type(cfg, txsock, rxsock, SYNC, 1, 1); err |= check_type(cfg, txsock, rxsock, DELAY_REQ, 1, 1); - err |= check_type(cfg, txsock, rxsock, PDELAY_REQ, 1, 1); - err |= check_type(cfg, txsock, rxsock, PDELAY_RESP, 1, 1); err |= check_type(cfg, txsock, rxsock, FOLLOW_UP, 1, 1); err |= check_type(cfg, txsock, rxsock, DELAY_RESP, 1, 1); err |= check_type(cfg, txsock, rxsock, ANNOUNCE, 1, 1); err |= check_type(cfg, txsock, rxsock, SIGNALING, 1, 1); err |= check_type(cfg, txsock, rxsock, MANAGEMENT, 1, 1); + str2mac("01:80:c2:00:00:0E", cfg->mac); + err |= check_type(cfg, txsock, rxsock, PDELAY_REQ, 1, 1); + err |= check_type(cfg, txsock, rxsock, PDELAY_RESP, 1, 1); + err |= check_type(cfg, txsock, rxsock, PDELAY_RESP_FUP, 1, 1); + print_result(err); return err; } @@ -150,35 +142,26 @@ int check_hardware_timestamp(struct pkt_cfg *cfg, char *tx_iface, char *rx_iface int64_t ns; int err; - cfg->transportSpecific = 0; - cfg->onestep = 0; - cfg->version = 2 | (1 << 4); - cfg->domain = 0; cfg->tstype = TS_HARDWARE; - cfg->seq = 0; - cfg->listen = 1; - cfg->twoStepFlag = 1; - /*str2mac("ff:ff:ff:ff:ff:ff", cfg->mac);*/ - str2mac("01:1B:19:00:00:00", cfg->mac); - /*str2mac("01:80:c2:00:00:0E", cfg->mac);*/ - /*memcpy(cfg->mac, buf, ETH_ALEN);*/ err = setup_sockets(cfg, tx_iface, rx_iface, &txsock, &rxsock); if (err) return err; - err = 0; + str2mac("01:1B:19:00:00:00", cfg->mac); err |= check_type(cfg, txsock, rxsock, SYNC, 1, 1); err |= check_type(cfg, txsock, rxsock, DELAY_REQ, 1, 1); - err |= check_type(cfg, txsock, rxsock, PDELAY_REQ, 1, 1); - err |= check_type(cfg, txsock, rxsock, PDELAY_RESP, 1, 1); err |= check_type(cfg, txsock, rxsock, FOLLOW_UP, 0, 0); err |= check_type(cfg, txsock, rxsock, DELAY_RESP, 0, 0); - err |= check_type(cfg, txsock, rxsock, PDELAY_RESP_FUP, 0, 0); err |= check_type(cfg, txsock, rxsock, ANNOUNCE, 0, 0); err |= check_type(cfg, txsock, rxsock, SIGNALING, 0, 0); err |= check_type(cfg, txsock, rxsock, MANAGEMENT, 0, 0); + str2mac("01:80:c2:00:00:0E", cfg->mac); + err |= check_type(cfg, txsock, rxsock, PDELAY_REQ, 1, 1); + err |= check_type(cfg, txsock, rxsock, PDELAY_RESP, 1, 1); + err |= check_type(cfg, txsock, rxsock, PDELAY_RESP_FUP, 0, 0); + print_result(err); return err; } @@ -188,37 +171,26 @@ int check_onestep_timestamp(struct pkt_cfg *cfg, char *tx_iface, char *rx_iface) int64_t ns; int err; - cfg->transportSpecific = 0; - cfg->onestep = 1; - cfg->version = 2 | (1 << 4); - cfg->domain = 0; cfg->tstype = TS_ONESTEP; - cfg->seq = 0; - cfg->listen = 1; - /*cfg->twoStepFlag = 1;*/ - /*str2mac("ff:ff:ff:ff:ff:ff", cfg->mac);*/ - str2mac("01:1B:19:00:00:00", cfg->mac); - /*str2mac("01:80:c2:00:00:0E", cfg->mac);*/ - /*memcpy(cfg->mac, buf, ETH_ALEN);*/ err = setup_sockets(cfg, tx_iface, rx_iface, &txsock, &rxsock); if (err) return err; - err = 0; - cfg->twoStepFlag = 0; + str2mac("01:1B:19:00:00:00", cfg->mac); err |= check_type(cfg, txsock, rxsock, SYNC, 0, 1); - cfg->twoStepFlag = 1; err |= check_type(cfg, txsock, rxsock, DELAY_REQ, 1, 1); - err |= check_type(cfg, txsock, rxsock, PDELAY_REQ, 1, 1); - err |= check_type(cfg, txsock, rxsock, PDELAY_RESP, 1, 1); err |= check_type(cfg, txsock, rxsock, FOLLOW_UP, 0, 0); err |= check_type(cfg, txsock, rxsock, DELAY_RESP, 0, 0); - err |= check_type(cfg, txsock, rxsock, PDELAY_RESP_FUP, 0, 0); err |= check_type(cfg, txsock, rxsock, ANNOUNCE, 0, 0); err |= check_type(cfg, txsock, rxsock, SIGNALING, 0, 0); err |= check_type(cfg, txsock, rxsock, MANAGEMENT, 0, 0); + str2mac("01:80:c2:00:00:0E", cfg->mac); + err |= check_type(cfg, txsock, rxsock, PDELAY_REQ, 1, 1); + err |= check_type(cfg, txsock, rxsock, PDELAY_RESP, 1, 1); + err |= check_type(cfg, txsock, rxsock, PDELAY_RESP_FUP, 0, 0); + print_result(err); return err; } @@ -228,36 +200,25 @@ int check_p2p1step_timestamp(struct pkt_cfg *cfg, char *tx_iface, char *rx_iface int64_t ns; int err; - cfg->transportSpecific = 0; - cfg->onestep = 1; - cfg->version = 2 | (1 << 4); - cfg->domain = 0; - cfg->tstype = TS_ONESTEP; - cfg->seq = 0; - cfg->listen = 1; - /*cfg->twoStepFlag = 1;*/ - /*str2mac("ff:ff:ff:ff:ff:ff", cfg->mac);*/ - str2mac("01:1B:19:00:00:00", cfg->mac); - /*str2mac("01:80:c2:00:00:0E", cfg->mac);*/ - /*memcpy(cfg->mac, buf, ETH_ALEN);*/ - + cfg->tstype = TS_P2P1STEP; err = setup_sockets(cfg, tx_iface, rx_iface, &txsock, &rxsock); if (err) return err; - err = 0; - cfg->twoStepFlag = 0; + str2mac("01:1B:19:00:00:00", cfg->mac); err |= check_type(cfg, txsock, rxsock, SYNC, 0, 1); /*err |= check_type(cfg, txsock, rxsock, DELAY_REQ, 1, 1);*/ - err |= check_type(cfg, txsock, rxsock, PDELAY_REQ, 1, 1); - err |= check_type(cfg, txsock, rxsock, PDELAY_RESP, 0, 1); err |= check_type(cfg, txsock, rxsock, FOLLOW_UP, 0, 0); err |= check_type(cfg, txsock, rxsock, DELAY_RESP, 0, 0); - err |= check_type(cfg, txsock, rxsock, PDELAY_RESP_FUP, 0, 0); err |= check_type(cfg, txsock, rxsock, ANNOUNCE, 0, 0); err |= check_type(cfg, txsock, rxsock, SIGNALING, 0, 0); err |= check_type(cfg, txsock, rxsock, MANAGEMENT, 0, 0); + str2mac("01:80:c2:00:00:0E", cfg->mac); + err |= check_type(cfg, txsock, rxsock, PDELAY_REQ, 1, 1); + err |= check_type(cfg, txsock, rxsock, PDELAY_RESP, 0, 1); + err |= check_type(cfg, txsock, rxsock, PDELAY_RESP_FUP, 0, 0); + print_result(err); return err; } @@ -266,6 +227,12 @@ int run_check_mode(int argc, char **argv) { struct pkt_cfg cfg = { 0 }; + cfg.transportSpecific = 0; + cfg.version = 2 | (1 << 4); + cfg.domain = 0; + cfg.seq = 0; + cfg.listen = 1; + return check_software_timestamp(&cfg, "veth1", "veth2"); }