Lines Matching refs:th

126 static void handle_client_test(sa_family_t af, struct tcphdr *th);
127 static void handle_server_test(sa_family_t af, struct tcphdr *th);
129 static void handle_syn_rst_ack(sa_family_t af, struct tcphdr *th);
130 static void handle_client_fin_wait_2_test(sa_family_t af, struct tcphdr *th);
131 static void handle_client_fin_wait_2_failure_test(sa_family_t af, struct tcphdr *th);
132 static void handle_client_closing_test(sa_family_t af, struct tcphdr *th);
133 static void handle_client_closing_failure_test(sa_family_t af, struct tcphdr *th);
134 static void handle_data_fin1_test(sa_family_t af, struct tcphdr *th);
135 static void handle_data_during_fin1_test(sa_family_t af, struct tcphdr *th);
137 static void handle_server_rst_on_closed_port(sa_family_t af, struct tcphdr *th);
138 static void handle_server_rst_on_listening_port(sa_family_t af, struct tcphdr *th);
139 static void handle_syn_invalid_ack(sa_family_t af, struct tcphdr *th);
140 static void handle_client_fin_ack_with_data_test(sa_family_t af, struct tcphdr *th);
142 static void verify_flags(struct tcphdr *th, uint8_t flags, in verify_flags() argument
145 if (!(th && FL(&th->th_flags, ==, flags))) { in verify_flags()
148 fun, line, th->th_flags, flags); in verify_flags()
247 struct tcphdr *th; in tester_prepare_tcp_pkt() local
277 th = (struct tcphdr *)net_pkt_get_data(pkt, &tcp_access); in tester_prepare_tcp_pkt()
278 if (!th) { in tester_prepare_tcp_pkt()
282 memset(th, 0U, sizeof(struct tcphdr)); in tester_prepare_tcp_pkt()
284 th->th_sport = src_port; in tester_prepare_tcp_pkt()
285 th->th_dport = dst_port; in tester_prepare_tcp_pkt()
288 th->th_off = 10U; in tester_prepare_tcp_pkt()
290 th->th_off = 5U; in tester_prepare_tcp_pkt()
293 th->th_flags = flags; in tester_prepare_tcp_pkt()
294 th->th_win = NET_IPV6_MTU; in tester_prepare_tcp_pkt()
295 th->th_seq = htonl(seq); in tester_prepare_tcp_pkt()
298 th->th_ack = htonl(ack); in tester_prepare_tcp_pkt()
404 static int read_tcp_header(struct net_pkt *pkt, struct tcphdr *th) in read_tcp_header() argument
417 ret = net_pkt_read(pkt, th, sizeof(struct tcphdr)); in read_tcp_header()
431 struct tcphdr th; in tester_send() local
439 ret = read_tcp_header(pkt, &th); in tester_send()
447 handle_client_test(net_pkt_family(pkt), &th); in tester_send()
452 handle_server_test(net_pkt_family(pkt), &th); in tester_send()
458 handle_client_fin_wait_2_test(net_pkt_family(pkt), &th); in tester_send()
461 handle_client_closing_test(net_pkt_family(pkt), &th); in tester_send()
467 handle_data_fin1_test(net_pkt_family(pkt), &th); in tester_send()
470 handle_data_during_fin1_test(net_pkt_family(pkt), &th); in tester_send()
473 handle_syn_rst_ack(net_pkt_family(pkt), &th); in tester_send()
476 handle_server_rst_on_closed_port(net_pkt_family(pkt), &th); in tester_send()
479 handle_server_rst_on_listening_port(net_pkt_family(pkt), &th); in tester_send()
482 handle_syn_invalid_ack(net_pkt_family(pkt), &th); in tester_send()
485 handle_client_closing_failure_test(net_pkt_family(pkt), &th); in tester_send()
488 handle_client_fin_wait_2_failure_test(net_pkt_family(pkt), &th); in tester_send()
491 handle_client_fin_ack_with_data_test(net_pkt_family(pkt), &th); in tester_send()
531 static void handle_client_test(sa_family_t af, struct tcphdr *th) in handle_client_test() argument
538 test_verify_flags(th, SYN); in handle_client_test()
540 ack = ntohl(th->th_seq) + 1U; in handle_client_test()
542 th->th_sport); in handle_client_test()
546 test_verify_flags(th, ACK); in handle_client_test()
552 test_verify_flags(th, PSH | ACK); in handle_client_test()
555 reply = prepare_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_client_test()
560 test_verify_flags(th, FIN | ACK); in handle_client_test()
564 th->th_sport); in handle_client_test()
567 test_verify_flags(th, ACK); in handle_client_test()
709 static void handle_server_test(sa_family_t af, struct tcphdr *th) in handle_server_test() argument
721 test_verify_flags(th, SYN | ACK); in handle_server_test()
723 ack = ntohl(th->th_seq) + 1U; in handle_server_test()
734 test_verify_flags(th, ACK); in handle_server_test()
741 test_verify_flags(th, FIN | ACK); in handle_server_test()
1070 static void handle_syn_rst_ack(sa_family_t af, struct tcphdr *th) in handle_syn_rst_ack() argument
1077 test_verify_flags(th, SYN); in handle_syn_rst_ack()
1079 ack = ntohl(th->th_seq) + 1U; in handle_syn_rst_ack()
1081 th->th_sport); in handle_syn_rst_ack()
1132 static void handle_client_fin_wait_2_test(sa_family_t af, struct tcphdr *th) in handle_client_fin_wait_2_test() argument
1140 test_verify_flags(th, SYN); in handle_client_fin_wait_2_test()
1142 ack = ntohl(th->th_seq) + 1U; in handle_client_fin_wait_2_test()
1144 th->th_sport); in handle_client_fin_wait_2_test()
1148 test_verify_flags(th, ACK); in handle_client_fin_wait_2_test()
1154 test_verify_flags(th, PSH | ACK); in handle_client_fin_wait_2_test()
1157 reply = prepare_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_client_fin_wait_2_test()
1162 test_verify_flags(th, FIN | ACK); in handle_client_fin_wait_2_test()
1165 reply = prepare_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_client_fin_wait_2_test()
1169 reply = prepare_fin_packet(af, htons(MY_PORT), th->th_sport); in handle_client_fin_wait_2_test()
1172 test_verify_flags(th, ACK); in handle_client_fin_wait_2_test()
1257 static void handle_client_fin_wait_2_failure_test(sa_family_t af, struct tcphdr *th) in handle_client_fin_wait_2_failure_test() argument
1265 test_verify_flags(th, SYN); in handle_client_fin_wait_2_failure_test()
1267 ack = ntohl(th->th_seq) + 1U; in handle_client_fin_wait_2_failure_test()
1269 th->th_sport); in handle_client_fin_wait_2_failure_test()
1273 test_verify_flags(th, ACK); in handle_client_fin_wait_2_failure_test()
1279 test_verify_flags(th, PSH | ACK); in handle_client_fin_wait_2_failure_test()
1282 reply = prepare_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_client_fin_wait_2_failure_test()
1287 test_verify_flags(th, FIN | ACK); in handle_client_fin_wait_2_failure_test()
1290 reply = prepare_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_client_fin_wait_2_failure_test()
1398 static uint32_t get_rel_seq(struct tcphdr *th) in get_rel_seq() argument
1400 return ntohl(th->th_seq) - device_initial_seq; in get_rel_seq()
1403 static void handle_data_fin1_test(sa_family_t af, struct tcphdr *th) in handle_data_fin1_test() argument
1411 test_verify_flags(th, SYN); in handle_data_fin1_test()
1412 device_initial_seq = ntohl(th->th_seq); in handle_data_fin1_test()
1414 ack = ntohl(th->th_seq) + 1U; in handle_data_fin1_test()
1416 th->th_sport); in handle_data_fin1_test()
1421 test_verify_flags(th, ACK); in handle_data_fin1_test()
1424 th->th_sport, "A", 1U); in handle_data_fin1_test()
1428 test_verify_flags(th, ACK); in handle_data_fin1_test()
1434 test_verify_flags(th, FIN | ACK); in handle_data_fin1_test()
1435 zassert_true(get_rel_seq(th) == 1, in handle_data_fin1_test()
1437 __func__, __LINE__, get_rel_seq(th)); in handle_data_fin1_test()
1438 zassert_true(ntohl(th->th_ack) == 2, in handle_data_fin1_test()
1440 __func__, __LINE__, ntohl(th->th_ack)); in handle_data_fin1_test()
1444 th->th_sport, "A", 1U); in handle_data_fin1_test()
1448 test_verify_flags(th, FIN | ACK); in handle_data_fin1_test()
1450 zassert_true(get_rel_seq(th) == 1, in handle_data_fin1_test()
1452 __func__, __LINE__, get_rel_seq(th)); in handle_data_fin1_test()
1453 zassert_true(ntohl(th->th_ack) == 2, in handle_data_fin1_test()
1455 __func__, __LINE__, ntohl(th->th_ack)); in handle_data_fin1_test()
1458 reply = prepare_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_data_fin1_test()
1462 reply = prepare_fin_packet(af, htons(MY_PORT), th->th_sport); in handle_data_fin1_test()
1465 test_verify_flags(th, ACK); in handle_data_fin1_test()
1545 static void handle_data_during_fin1_test(sa_family_t af, struct tcphdr *th) in handle_data_during_fin1_test() argument
1552 test_verify_flags(th, SYN); in handle_data_during_fin1_test()
1553 device_initial_seq = ntohl(th->th_seq); in handle_data_during_fin1_test()
1555 ack = ntohl(th->th_seq) + 1U; in handle_data_during_fin1_test()
1557 th->th_sport); in handle_data_during_fin1_test()
1562 test_verify_flags(th, ACK); in handle_data_during_fin1_test()
1567 test_verify_flags(th, FIN | ACK); in handle_data_during_fin1_test()
1568 zassert_true(get_rel_seq(th) == 1, in handle_data_during_fin1_test()
1570 __func__, __LINE__, get_rel_seq(th)); in handle_data_during_fin1_test()
1571 zassert_true(ntohl(th->th_ack) == 1, in handle_data_during_fin1_test()
1573 __func__, __LINE__, ntohl(th->th_ack)); in handle_data_during_fin1_test()
1579 th->th_sport, "A", 1U); in handle_data_during_fin1_test()
1584 test_verify_flags(th, RST); in handle_data_during_fin1_test()
1585 zassert_true(get_rel_seq(th) == 2, in handle_data_during_fin1_test()
1587 __func__, __LINE__, get_rel_seq(th)); in handle_data_during_fin1_test()
1660 static void handle_client_closing_test(sa_family_t af, struct tcphdr *th) in handle_client_closing_test() argument
1667 test_verify_flags(th, SYN); in handle_client_closing_test()
1669 ack = ntohl(th->th_seq) + 1U; in handle_client_closing_test()
1671 th->th_sport); in handle_client_closing_test()
1675 test_verify_flags(th, ACK); in handle_client_closing_test()
1681 test_verify_flags(th, PSH | ACK); in handle_client_closing_test()
1684 reply = prepare_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_client_closing_test()
1689 test_verify_flags(th, FIN | ACK); in handle_client_closing_test()
1692 reply = prepare_fin_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_client_closing_test()
1695 test_verify_flags(th, ACK); in handle_client_closing_test()
1698 reply = prepare_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_client_closing_test()
1785 static void handle_client_closing_failure_test(sa_family_t af, struct tcphdr *th) in handle_client_closing_failure_test() argument
1792 test_verify_flags(th, SYN); in handle_client_closing_failure_test()
1794 ack = ntohl(th->th_seq) + 1U; in handle_client_closing_failure_test()
1796 th->th_sport); in handle_client_closing_failure_test()
1800 test_verify_flags(th, ACK); in handle_client_closing_failure_test()
1806 test_verify_flags(th, PSH | ACK); in handle_client_closing_failure_test()
1809 reply = prepare_ack_packet(af, htons(MY_PORT), th->th_sport); in handle_client_closing_failure_test()
1814 test_verify_flags(th, FIN | ACK); in handle_client_closing_failure_test()
1816 reply = prepare_fin_packet(af, htons(MY_PORT), th->th_sport); in handle_client_closing_failure_test()
1819 test_verify_flags(th, FIN | ACK); in handle_client_closing_failure_test()
1821 reply = prepare_fin_packet(af, htons(MY_PORT), th->th_sport); in handle_client_closing_failure_test()
1824 test_verify_flags(th, FIN | ACK); in handle_client_closing_failure_test()
2041 struct tcphdr th; in handle_server_recv_out_of_order() local
2044 ret = read_tcp_header(pkt, &th); in handle_server_recv_out_of_order()
2050 zassert_equal(expected_ack, ntohl(th.th_ack), in handle_server_recv_out_of_order()
2053 expected_ack, ntohl(th.th_ack)); in handle_server_recv_out_of_order()
2204 static void handle_server_rst_on_closed_port(sa_family_t af, struct tcphdr *th) in handle_server_rst_on_closed_port() argument
2209 test_verify_flags(th, RST | ACK); in handle_server_rst_on_closed_port()
2210 zassert_equal(ntohl(th->th_seq), 0, "Invalid SEQ value"); in handle_server_rst_on_closed_port()
2211 zassert_equal(ntohl(th->th_ack), seq, "Invalid ACK value"); in handle_server_rst_on_closed_port()
2240 static void handle_server_rst_on_listening_port(sa_family_t af, struct tcphdr *th) in handle_server_rst_on_listening_port() argument
2245 test_verify_flags(th, RST); in handle_server_rst_on_listening_port()
2246 zassert_equal(ntohl(th->th_seq), ack, "Invalid SEQ value"); in handle_server_rst_on_listening_port()
2323 static void handle_syn_invalid_ack(sa_family_t af, struct tcphdr *th) in handle_syn_invalid_ack() argument
2332 test_verify_flags(th, SYN); in handle_syn_invalid_ack()
2334 ack = ntohl(th->th_seq) + 1000U; in handle_syn_invalid_ack()
2336 th->th_sport); in handle_syn_invalid_ack()
2341 ack = ntohl(th->th_seq) + 1U; in handle_syn_invalid_ack()
2343 th->th_sport); in handle_syn_invalid_ack()
2350 test_verify_flags(th, ACK); in handle_syn_invalid_ack()
2355 test_verify_flags(th, FIN | ACK); in handle_syn_invalid_ack()
2360 th->th_sport); in handle_syn_invalid_ack()
2363 test_verify_flags(th, ACK); in handle_syn_invalid_ack()
2367 test_verify_flags(th, RST); in handle_syn_invalid_ack()
2368 zassert_equal(ntohl(th->th_seq), ack, "Invalid SEQ value"); in handle_syn_invalid_ack()
2431 static void handle_client_fin_ack_with_data_test(sa_family_t af, struct tcphdr *th) in handle_client_fin_ack_with_data_test() argument
2439 test_verify_flags(th, SYN); in handle_client_fin_ack_with_data_test()
2440 device_initial_seq = ntohl(th->th_seq); in handle_client_fin_ack_with_data_test()
2442 ack = ntohl(th->th_seq) + 1U; in handle_client_fin_ack_with_data_test()
2443 peer_port = th->th_sport; in handle_client_fin_ack_with_data_test()
2449 test_verify_flags(th, ACK); in handle_client_fin_ack_with_data_test()
2482 test_verify_flags(th, ACK); in handle_client_fin_ack_with_data_test()
2483 zassert_equal(get_rel_seq(th), 1, "Unexpected SEQ number in T_FIN, got %d", in handle_client_fin_ack_with_data_test()
2484 get_rel_seq(th)); in handle_client_fin_ack_with_data_test()
2485 zassert_equal(ntohl(th->th_ack), seq, "Unexpected ACK in T_FIN, got %d", in handle_client_fin_ack_with_data_test()
2486 ntohl(th->th_ack)); in handle_client_fin_ack_with_data_test()
2491 test_verify_flags(th, FIN | ACK); in handle_client_fin_ack_with_data_test()
2492 zassert_equal(get_rel_seq(th), 1, "Unexpected SEQ number in T_FIN_ACK, got %d", in handle_client_fin_ack_with_data_test()
2493 get_rel_seq(th)); in handle_client_fin_ack_with_data_test()
2494 zassert_equal(ntohl(th->th_ack), seq, "Unexpected ACK in T_FIN_ACK, got %d", in handle_client_fin_ack_with_data_test()
2495 ntohl(th->th_ack)); in handle_client_fin_ack_with_data_test()
2503 test_verify_flags(th, FIN); in handle_client_fin_ack_with_data_test()
2504 zassert_equal(get_rel_seq(th), 1, "Unexpected SEQ number in T_CLOSING, got %d", in handle_client_fin_ack_with_data_test()
2505 get_rel_seq(th)); in handle_client_fin_ack_with_data_test()