Lines Matching refs:data
50 static int send_tcp_data(struct sample_data *data) in send_tcp_data() argument
55 data->tcp.expecting = sys_rand32_get() % ipsum_len; in send_tcp_data()
56 } while (data->tcp.expecting == 0U); in send_tcp_data()
58 data->tcp.received = 0U; in send_tcp_data()
60 ret = sendall(data->tcp.sock, lorem_ipsum, data->tcp.expecting); in send_tcp_data()
63 LOG_ERR("%s TCP: Failed to send data, errno %d", data->proto, in send_tcp_data()
67 LOG_DBG("%s TCP: Sent %d bytes", data->proto, in send_tcp_data()
68 data->tcp.expecting); in send_tcp_data()
75 static int compare_tcp_data(struct sample_data *data, const char *buf, uint32_t received) in compare_tcp_data() argument
77 if (data->tcp.received + received > data->tcp.expecting) { in compare_tcp_data()
78 LOG_ERR("Too much data received: TCP %s", data->proto); in compare_tcp_data()
82 if (memcmp(buf, lorem_ipsum + data->tcp.received, received) != 0) { in compare_tcp_data()
83 LOG_ERR("Invalid data received: TCP %s", data->proto); in compare_tcp_data()
90 static int start_tcp_proto(struct sample_data *data, sa_family_t family, in start_tcp_proto() argument
97 data->tcp.sock = socket(family, SOCK_STREAM, IPPROTO_TLS_1_2); in start_tcp_proto()
99 data->tcp.sock = socket(family, SOCK_STREAM, IPPROTO_TCP); in start_tcp_proto()
101 if (data->tcp.sock < 0) { in start_tcp_proto()
102 LOG_ERR("Failed to create TCP socket (%s): %d", data->proto, in start_tcp_proto()
133 ret = setsockopt(data->tcp.sock, SOL_SOCKET, SO_SOCKS5, in start_tcp_proto()
148 ret = setsockopt(data->tcp.sock, SOL_TLS, TLS_SEC_TAG_LIST, in start_tcp_proto()
152 data->proto, errno); in start_tcp_proto()
156 ret = setsockopt(data->tcp.sock, SOL_TLS, TLS_HOSTNAME, in start_tcp_proto()
160 data->proto, errno); in start_tcp_proto()
168 (void)setsockopt(data->tcp.sock, IPPROTO_IPV6, in start_tcp_proto()
173 ret = connect(data->tcp.sock, addr, addrlen); in start_tcp_proto()
175 LOG_ERR("Cannot connect to TCP remote (%s): %d", data->proto, in start_tcp_proto()
183 static int process_tcp_proto(struct sample_data *data) in process_tcp_proto() argument
189 received = recv(data->tcp.sock, buf, sizeof(buf), MSG_DONTWAIT); in process_tcp_proto()
204 ret = compare_tcp_data(data, buf, received); in process_tcp_proto()
210 data->tcp.received += received; in process_tcp_proto()
211 if (data->tcp.received < data->tcp.expecting) { in process_tcp_proto()
218 data->proto, data->tcp.received); in process_tcp_proto()
221 if (++data->tcp.counter % 1000 == 0U) { in process_tcp_proto()
222 LOG_INF("%s TCP: Exchanged %u packets", data->proto, in process_tcp_proto()
223 data->tcp.counter); in process_tcp_proto()
226 ret = send_tcp_data(data); in process_tcp_proto()