Lines Matching +full:family +full:- +full:id

4  * SPDX-License-Identifier: Apache-2.0
67 stat_hdr->flags = htonl(stat->flags); in build_reply()
68 stat_hdr->total_len1 = htonl(stat->total_len1); in build_reply()
69 stat_hdr->total_len2 = htonl(stat->total_len2); in build_reply()
70 stat_hdr->stop_sec = htonl(stat->stop_sec); in build_reply()
71 stat_hdr->stop_usec = htonl(stat->stop_usec); in build_reply()
72 stat_hdr->error_cnt = htonl(stat->error_cnt); in build_reply()
73 stat_hdr->outorder_cnt = htonl(stat->outorder_cnt); in build_reply()
74 stat_hdr->datagrams = htonl(stat->datagrams); in build_reply()
75 stat_hdr->jitter1 = htonl(stat->jitter1); in build_reply()
76 stat_hdr->jitter2 = htonl(stat->jitter2); in build_reply()
93 addr->sa_family == AF_INET6 ? in zperf_receiver_send_stat()
110 int32_t id; in udp_received() local
126 id = ntohl(hdr->id); in udp_received()
128 switch (session->state) { in udp_received()
131 if (id < 0) { in udp_received()
136 &session->stat) < 0) { in udp_received()
141 session->state = STATE_ONGOING; in udp_received()
142 session->start_time = time; in udp_received()
152 if (id < 0) { /* Negative id means session end. */ in udp_received()
156 duration = k_ticks_to_us_ceil64(time - in udp_received()
157 session->start_time); in udp_received()
160 session->state = STATE_COMPLETED; in udp_received()
163 session->stat.flags = 0x80000000; in udp_received()
164 session->stat.total_len1 = session->length >> 32; in udp_received()
165 session->stat.total_len2 = in udp_received()
166 session->length % 0xFFFFFFFF; in udp_received()
167 session->stat.stop_sec = duration / USEC_PER_SEC; in udp_received()
168 session->stat.stop_usec = duration % USEC_PER_SEC; in udp_received()
169 session->stat.error_cnt = session->error; in udp_received()
170 session->stat.outorder_cnt = session->outorder; in udp_received()
171 session->stat.datagrams = session->counter; in udp_received()
172 session->stat.jitter1 = 0; in udp_received()
173 session->stat.jitter2 = session->jitter; in udp_received()
176 &session->stat) < 0) { in udp_received()
180 results.nb_packets_rcvd = session->counter; in udp_received()
181 results.nb_packets_lost = session->error; in udp_received()
182 results.nb_packets_outorder = session->outorder; in udp_received()
183 results.total_len = session->length; in udp_received()
185 results.jitter_in_us = session->jitter; in udp_received()
186 results.packet_size = session->length / session->counter; in udp_received()
194 session->counter++; in udp_received()
195 session->length += datalen; in udp_received()
200 ntohl(hdr->tv_sec) * USEC_PER_SEC + in udp_received()
201 ntohl(hdr->tv_usec)); in udp_received()
202 if (session->last_transit_time != 0) { in udp_received()
203 int32_t delta_transit = transit_time - in udp_received()
204 session->last_transit_time; in udp_received()
208 -delta_transit : delta_transit; in udp_received()
210 session->jitter += in udp_received()
211 (delta_transit - session->jitter) / 16; in udp_received()
214 session->last_transit_time = transit_time; in udp_received()
216 /* Check header id */ in udp_received()
217 if (id != session->next_id) { in udp_received()
218 if (id < session->next_id) { in udp_received()
219 session->outorder++; in udp_received()
221 session->error += id - session->next_id; in udp_received()
222 session->next_id = id + 1; in udp_received()
225 session->next_id++; in udp_received()
281 if (net_ipv4_is_addr_mcast(&addr4->sin_addr)) { in zperf_udp_leave_mcast()
282 net_ipv4_igmp_leave(iface, &addr4->sin_addr); in zperf_udp_leave_mcast()
289 if (net_ipv6_is_addr_mcast(&addr6->sin6_addr)) { in zperf_udp_leave_mcast()
290 net_ipv6_mld_leave(iface, &addr6->sin6_addr); in zperf_udp_leave_mcast()
305 fds[i].fd = -1; in udp_receiver_cleanup()
319 int family, sock_error; in udp_recv_data() local
325 return -ENOENT; in udp_recv_data()
328 if ((pev->event.revents & ZSOCK_POLLERR) || in udp_recv_data()
329 (pev->event.revents & ZSOCK_POLLNVAL)) { in udp_recv_data()
330 (void)zsock_getsockopt(pev->event.fd, SOL_SOCKET, in udp_recv_data()
331 SO_DOMAIN, &family, &optlen); in udp_recv_data()
332 (void)zsock_getsockopt(pev->event.fd, SOL_SOCKET, in udp_recv_data()
335 family == AF_INET ? 4 : 6, sock_error); in udp_recv_data()
336 ret = -sock_error; in udp_recv_data()
340 if (!(pev->event.revents & ZSOCK_POLLIN)) { in udp_recv_data()
344 ret = zsock_recvfrom(pev->event.fd, buf, sizeof(buf), 0, in udp_recv_data()
347 ret = -errno; in udp_recv_data()
348 (void)zsock_getsockopt(pev->event.fd, SOL_SOCKET, in udp_recv_data()
349 SO_DOMAIN, &family, &optlen); in udp_recv_data()
351 family == AF_INET ? 4 : 6, -ret); in udp_recv_data()
355 udp_received(pev->event.fd, &addr, buf, ret); in udp_recv_data()
380 int family; in zperf_udp_receiver_init() local
383 fds[i].fd = -1; in zperf_udp_receiver_init()
386 family = udp_server_addr.sa_family; in zperf_udp_receiver_init()
388 if (IS_ENABLED(CONFIG_NET_IPV4) && (family == AF_INET || family == AF_UNSPEC)) { in zperf_udp_receiver_init()
396 ret = -errno; in zperf_udp_receiver_init()
401 in4_addr = &net_sin(&udp_server_addr)->sin_addr; in zperf_udp_receiver_init()
404 memcpy(&in4_addr_my->sin_addr, in4_addr, in zperf_udp_receiver_init()
409 &in4_addr_my->sin_addr); in zperf_udp_receiver_init()
416 in4_addr_my->sin_addr.s_addr = INADDR_ANY; in zperf_udp_receiver_init()
419 if (net_ipv4_is_addr_mcast(&in4_addr_my->sin_addr)) { in zperf_udp_receiver_init()
421 &in4_addr_my->sin_addr); in zperf_udp_receiver_init()
425 net_sprint_ipv4_addr(&in4_addr_my->sin_addr)); in zperf_udp_receiver_init()
427 in4_addr_my->sin_port = htons(udp_server_port); in zperf_udp_receiver_init()
434 ntohs(in4_addr_my->sin_port), in zperf_udp_receiver_init()
442 if (IS_ENABLED(CONFIG_NET_IPV6) && (family == AF_INET6 || family == AF_UNSPEC)) { in zperf_udp_receiver_init()
450 ret = -errno; in zperf_udp_receiver_init()
455 in6_addr = &net_sin6(&udp_server_addr)->sin6_addr; in zperf_udp_receiver_init()
458 memcpy(&in6_addr_my->sin6_addr, in6_addr, in zperf_udp_receiver_init()
464 &in6_addr_my->sin6_addr); in zperf_udp_receiver_init()
471 memcpy(&in6_addr_my->sin6_addr, in zperf_udp_receiver_init()
476 if (net_ipv6_is_addr_mcast(&in6_addr_my->sin6_addr)) { in zperf_udp_receiver_init()
478 &in6_addr_my->sin6_addr); in zperf_udp_receiver_init()
482 net_sprint_ipv6_addr(&in6_addr_my->sin6_addr)); in zperf_udp_receiver_init()
484 in6_addr_my->sin6_port = htons(udp_server_port); in zperf_udp_receiver_init()
491 ntohs(in6_addr_my->sin6_port), in zperf_udp_receiver_init()
518 return -EINVAL; in zperf_udp_download()
522 return -EALREADY; in zperf_udp_download()
527 udp_server_port = param->port; in zperf_udp_download()
528 memcpy(&udp_server_addr, &param->addr, sizeof(struct sockaddr)); in zperf_udp_download()
530 if (param->if_name[0]) { in zperf_udp_download()
536 strncpy(udp_server_iface_name, param->if_name, IFNAMSIZ); in zperf_udp_download()
537 udp_server_iface_name[IFNAMSIZ - 1] = 0; in zperf_udp_download()
556 return -EALREADY; in zperf_udp_download_stop()