Lines Matching +full:sample +full:- +full:clk

4  * SPDX-License-Identifier: Apache-2.0
44 const struct device *clk; member
51 .sock = -1,
138 socklen_t addr_len = data->peer_addr_len; in rx()
142 len += recvfrom(data->sock, recv_buf, sizeof(recv_buf), 0, in rx()
181 msg.msg_name = &data->peer; in tx()
182 msg.msg_namelen = data->peer_addr_len; in tx()
185 cmsg->cmsg_len = CMSG_LEN(sizeof(txtime)); in tx()
186 cmsg->cmsg_level = SOL_SOCKET; in tx()
187 cmsg->cmsg_type = SCM_TXTIME; in tx()
191 ptp_clock_get(data->clk, &time); in tx()
195 sizeof(txtime_str) - print_offset, "%"PRIx64, (uint64_t)txtime); in tx()
201 ret = sendmsg(data->sock, &msg, 0); in tx()
204 LOG_DBG("Message send failed (%d)", -errno); in tx()
212 sizeof(txtime_str) - print_offset, "%"PRIx64, (uint64_t)txtime); in tx()
223 if (peer->sa_family != AF_INET6) { in get_local_ipv6()
227 addr = net_if_ipv6_select_src_addr(iface, &net_sin6(peer)->sin6_addr); in get_local_ipv6()
230 return -EINVAL; in get_local_ipv6()
233 memcpy(&net_sin6(local)->sin6_addr, addr, sizeof(*addr)); in get_local_ipv6()
234 local->sa_family = AF_INET6; in get_local_ipv6()
245 if (peer->sa_family != AF_INET) { in get_local_ipv4()
249 addr = net_if_ipv4_select_src_addr(iface, &net_sin(peer)->sin_addr); in get_local_ipv4()
252 return -EINVAL; in get_local_ipv4()
255 memcpy(&net_sin(local)->sin_addr, addr, sizeof(*addr)); in get_local_ipv4()
256 local->sa_family = AF_INET; in get_local_ipv4()
279 -errno); in create_socket()
280 return -errno; in create_socket()
284 addr->sll_ifindex = net_if_get_by_iface(net_if_get_default()); in create_socket()
285 addr->sll_family = AF_PACKET; in create_socket()
288 LOG_DBG("Binding to interface %d (%p)", addr->sll_ifindex, in create_socket()
289 net_if_get_by_index(addr->sll_ifindex)); in create_socket()
295 sock = socket(peer->sa_family, SOCK_DGRAM, IPPROTO_UDP); in create_socket()
297 LOG_ERR("Cannot create %s socket (%d)", "UDP", -errno); in create_socket()
298 return -errno; in create_socket()
302 peer->sa_family == AF_INET6) { in create_socket()
308 net_addr_ntop(AF_INET6, &net_sin6(&local)->sin6_addr, in create_socket()
311 peer->sa_family == AF_INET) { in create_socket()
317 net_addr_ntop(AF_INET, &net_sin(&local)->sin_addr, in create_socket()
320 LOG_ERR("Invalid socket family %d", peer->sa_family); in create_socket()
321 return -EINVAL; in create_socket()
329 LOG_ERR("Cannot bind socket (%d)", -errno); in create_socket()
330 return -errno; in create_socket()
336 LOG_ERR("Cannot set SO_TXTIME (%d)", -errno); in create_socket()
337 return -errno; in create_socket()
344 LOG_ERR("Cannot set SO_PRIORITY (%d)", -errno); in create_socket()
345 return -errno; in create_socket()
361 return -EINVAL; in get_peer_address()
364 if (net_sin(&peer_data.peer)->sin_port == 0) { in get_peer_address()
365 net_sin(&peer_data.peer)->sin_port = htons(4242); in get_peer_address()
371 &net_sin6(&peer_data.peer)->sin6_addr); in get_peer_address()
374 &net_sin6(&peer_data.peer)->sin6_addr, addr_str, in get_peer_address()
381 &net_sin(&peer_data.peer)->sin_addr); in get_peer_address()
384 &net_sin(&peer_data.peer)->sin_addr, addr_str, in get_peer_address()
514 "Quit the sample application\n",
519 SHELL_CMD_REGISTER(sample, &sample_commands,
520 "Sample application commands", NULL);
568 addr->sll_ifindex = net_if_get_by_iface(net_if_get_default()); in main()
569 addr->sll_family = AF_PACKET; in main()
571 iface = net_if_get_by_index(addr->sll_ifindex); in main()
592 peer_data.clk = net_eth_get_ptp_clock_by_index(if_index); in main()
593 if (!peer_data.clk) { in main()
610 LOG_INF("Socket SO_TXTIME sample to %s port %d using " in main()
613 ntohs(net_sin(&peer_data.peer)->sin_port), in main()
614 if_index, iface, peer_data.clk); in main()
618 LOG_INF("Socket SO_TXTIME sample using AF_PACKET and " in main()
620 if_index, iface, peer_data.clk); in main()