Lines Matching refs:data
39 static int send_udp_data(struct sample_data *data);
139 static int send_udp_data(struct sample_data *data) in send_udp_data() argument
144 data->udp.expecting = sys_rand32_get() % ipsum_len; in send_udp_data()
145 } while (data->udp.expecting == 0U || in send_udp_data()
146 data->udp.expecting > data->udp.mtu); in send_udp_data()
148 ret = send(data->udp.sock, lorem_ipsum, data->udp.expecting, 0); in send_udp_data()
151 LOG_DBG("%s UDP: Sent %d bytes", data->proto, data->udp.expecting); in send_udp_data()
154 k_timer_start(&data->udp.ctrl->rx_timer, UDP_WAIT, K_NO_WAIT); in send_udp_data()
159 static int compare_udp_data(struct sample_data *data, const char *buf, uint32_t received) in compare_udp_data() argument
161 if (received != data->udp.expecting) { in compare_udp_data()
162 LOG_ERR("Invalid amount of data received: UDP %s", data->proto); in compare_udp_data()
167 LOG_ERR("Invalid data received: UDP %s", data->proto); in compare_udp_data()
178 struct sample_data *data = (ctrl == conf.ipv4.udp.ctrl) ? &conf.ipv4 : &conf.ipv6; in wait_reply() local
180 LOG_ERR("UDP %s: Data packet not received", data->proto); in wait_reply()
193 static int start_udp_proto(struct sample_data *data, sa_family_t family, in start_udp_proto() argument
200 data->udp.sock = socket(family, SOCK_DGRAM, IPPROTO_DTLS_1_2); in start_udp_proto()
202 data->udp.sock = socket(family, SOCK_DGRAM, IPPROTO_UDP); in start_udp_proto()
204 if (data->udp.sock < 0) { in start_udp_proto()
205 LOG_ERR("Failed to create UDP socket (%s): %d", data->proto, in start_udp_proto()
218 ret = setsockopt(data->udp.sock, SOL_TLS, TLS_SEC_TAG_LIST, in start_udp_proto()
222 data->proto, errno); in start_udp_proto()
226 ret = setsockopt(data->udp.sock, SOL_TLS, TLS_HOSTNAME, in start_udp_proto()
230 data->proto, errno); in start_udp_proto()
238 (void)setsockopt(data->udp.sock, IPPROTO_IPV6, in start_udp_proto()
244 ret = connect(data->udp.sock, addr, addrlen); in start_udp_proto()
246 LOG_ERR("Cannot connect to UDP remote (%s): %d", data->proto, in start_udp_proto()
254 static int process_udp_proto(struct sample_data *data) in process_udp_proto() argument
258 received = recv(data->udp.sock, recv_buf, sizeof(recv_buf), in process_udp_proto()
273 ret = compare_udp_data(data, recv_buf, received); in process_udp_proto()
276 "mismatch", data->proto, received); in process_udp_proto()
283 data->proto, received); in process_udp_proto()
286 if (++data->udp.counter % 1000 == 0U) { in process_udp_proto()
287 LOG_INF("%s UDP: Exchanged %u packets", data->proto, in process_udp_proto()
288 data->udp.counter); in process_udp_proto()
291 k_timer_stop(&data->udp.ctrl->rx_timer); in process_udp_proto()
295 k_timer_start(&data->udp.ctrl->tx_timer, UDP_SLEEP, K_NO_WAIT); in process_udp_proto()
297 k_poll_signal_raise(&data->udp.ctrl->tx_signal, 0); in process_udp_proto()