Lines Matching +full:cm +full:- +full:poll +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0
7 * connected hosts, one instance in transmit mode and the other in receive
8 * mode using the '-r' option. Receiver will compare arrival timestamps to
10 * queue. The streams can differ due to out-of-order delivery and drops.
34 #include <poll.h>
78 struct cmsghdr *cm; in do_send_one() local
82 iov.iov_base = &ts->data; in do_send_one()
90 if (ts->delay_us >= 0) { in do_send_one()
95 tdeliver = glob_tstart + ts->delay_us * 1000; in do_send_one()
99 cm = CMSG_FIRSTHDR(&msg); in do_send_one()
100 cm->cmsg_level = SOL_SOCKET; in do_send_one()
101 cm->cmsg_type = SCM_TXTIME; in do_send_one()
102 cm->cmsg_len = CMSG_LEN(sizeof(tdeliver)); in do_send_one()
103 memcpy(CMSG_DATA(cm), &tdeliver, sizeof(tdeliver)); in do_send_one()
107 if (ret == -1) in do_send_one()
121 if (ret == -1 && errno == EAGAIN) in do_recv_one()
123 if (ret == -1) in do_recv_one()
128 tstop = (gettime_ns(cfg_clockid) - glob_tstart) / 1000; in do_recv_one()
129 texpect = ts->delay_us >= 0 ? ts->delay_us : 0; in do_recv_one()
134 if (rbuf[0] != ts->data) in do_recv_one()
135 error(1, 0, "payload mismatch. expected %c", ts->data); in do_recv_one()
137 if (llabs(tstop - texpect) > cfg_variance_us) { in do_recv_one()
150 if (ret != -1 || errno != EAGAIN) in do_recv_verify_empty()
164 struct cmsghdr *cm; in do_recv_errqueue_timeout() local
180 if (ret == -1 && errno == EAGAIN) in do_recv_errqueue_timeout()
182 if (ret == -1) in do_recv_errqueue_timeout()
187 cm = CMSG_FIRSTHDR(&msg); in do_recv_errqueue_timeout()
188 if (cm->cmsg_level != cfg_errq_level || in do_recv_errqueue_timeout()
189 cm->cmsg_type != cfg_errq_type) in do_recv_errqueue_timeout()
191 cm->cmsg_level, cm->cmsg_type); in do_recv_errqueue_timeout()
193 err = (struct sock_extended_err *)CMSG_DATA(cm); in do_recv_errqueue_timeout()
194 if (err->ee_origin != SO_EE_ORIGIN_TXTIME) in do_recv_errqueue_timeout()
195 error(1, 0, "errqueue: origin 0x%x\n", err->ee_origin); in do_recv_errqueue_timeout()
197 switch (err->ee_errno) { in do_recv_errqueue_timeout()
199 if (err->ee_code != SO_EE_CODE_TXTIME_MISSED) in do_recv_errqueue_timeout()
201 err->ee_code); in do_recv_errqueue_timeout()
205 if (err->ee_code != SO_EE_CODE_TXTIME_INVALID_PARAM) in do_recv_errqueue_timeout()
207 err->ee_code); in do_recv_errqueue_timeout()
212 err->ee_errno, err->ee_code); in do_recv_errqueue_timeout()
215 tstamp = ((int64_t) err->ee_data) << 32 | err->ee_info; in do_recv_errqueue_timeout()
216 tstamp -= (int64_t) glob_tstart; in do_recv_errqueue_timeout()
219 data[ret - 1], tstamp, reason); in do_recv_errqueue_timeout()
236 ret = poll(&pfd, 1, timeout_ms); in recv_errqueue_msgs()
237 if (ret == -1) in recv_errqueue_msgs()
238 error(1, errno, "poll"); in recv_errqueue_msgs()
261 err = usleep((cfg_start_time_ns - now) / 1000); in start_time_wait()
291 fd = socket(addr->sa_family, SOCK_DGRAM, 0); in setup_tx()
292 if (fd == -1) in setup_tx()
312 fd = socket(addr->sa_family, SOCK_DGRAM, 0); in setup_rx()
313 if (fd == -1) in setup_rx()
330 addr->sa_family == PF_INET ? '4' : '6', in do_test_tx()
374 addr4->sin_family = AF_INET; in setup_sockaddr()
375 addr4->sin_port = htons(cfg_port); in setup_sockaddr()
377 inet_pton(AF_INET, str_addr, &(addr4->sin_addr)) != 1) in setup_sockaddr()
382 addr6->sin6_family = AF_INET6; in setup_sockaddr()
383 addr6->sin6_port = htons(cfg_port); in setup_sockaddr()
385 inet_pton(AF_INET6, str_addr, &(addr6->sin6_addr)) != 1) in setup_sockaddr()
401 arg = NULL; /* only pass non-zero on first call */ in parse_io()
407 array->delay_us = strtol(tok, NULL, 0) * 1000; in parse_io()
410 array->data = tok[0]; in parse_io()
425 " -4 only IPv4\n" in usage()
426 " -6 only IPv6\n" in usage()
427 " -c <clock> monotonic or tai (default)\n" in usage()
428 " -D <addr> destination IP address (server)\n" in usage()
429 " -S <addr> source IP address (client)\n" in usage()
430 " -r run rx mode\n" in usage()
431 " -t <nsec> start time (UTC nanoseconds)\n" in usage()
432 " -m <mark> socket mark\n" in usage()
444 while ((c = getopt(argc, argv, "46c:S:D:rt:m:")) != -1) { in parse_opts()
448 error(1, 0, "Pass one of -4 or -6"); in parse_opts()
456 error(1, 0, "Pass one of -4 or -6"); in parse_opts()
491 if (argc - optind != 1) in parse_opts()
495 error(1, 0, "Pass one of -4 or -6"); in parse_opts()
497 error(1, 0, "-D <server addr> required\n"); in parse_opts()
499 error(1, 0, "-S <client addr> required\n"); in parse_opts()