Skip to content

Commit a980fb7

Browse files
committed
udp ipv6 socket test
1 parent 3b333ef commit a980fb7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/tests/networking_tests.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod net_tests {
1212
ut_lind_net_bind_multiple();
1313
ut_lind_net_bind_on_zero();
1414
ut_lind_net_connect_basic_udp();
15+
// ut_lind_net_connect_basic_udp_ipv6(); Failing
1516
ut_lind_net_getpeername();
1617
ut_lind_net_getsockname();
1718
ut_lind_net_listen();
@@ -539,6 +540,41 @@ pub mod net_tests {
539540
lindrustfinalize();
540541
}
541542

543+
//Test connect sys call using AF_INET6/IPv6 address family and UDP socket type
544+
//** Currently failing ** //
545+
pub fn ut_lind_net_connect_basic_udp_ipv6() {
546+
lindrustinit(0);
547+
let cage = interface::cagetable_getref(1);
548+
549+
//Initialize initial socket fd and remote socket to connect to
550+
let sockfd = cage.socket_syscall(AF_INET6, SOCK_DGRAM, 0);
551+
let port: u16 = generate_random_port();
552+
let mut socket = interface::GenSockaddr::V6(interface::SockaddrV6 {
553+
sin6_family: AF_INET6 as u16,
554+
sin6_port: port.to_be(),
555+
sin6_addr: interface::V6Addr {
556+
s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]},
557+
sin6_flowinfo: 0,
558+
sin6_scope_id: 0,
559+
}); //::1 LOCALHOST
560+
assert_eq!(cage.connect_syscall(sockfd, &socket), 0);
561+
562+
//Change the port and retarget the socket
563+
let port: u16 = generate_random_port();
564+
socket = interface::GenSockaddr::V6(interface::SockaddrV6 {
565+
sin6_family: AF_INET6 as u16,
566+
sin6_port: port.to_be(),
567+
sin6_addr: interface::V6Addr {
568+
s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]},
569+
sin6_flowinfo: 0,
570+
sin6_scope_id: 0,
571+
}); //::1 LOCALHOST
572+
assert_eq!(cage.connect_syscall(sockfd, &socket), 0);
573+
574+
assert_eq!(cage.exit_syscall(EXIT_SUCCESS), EXIT_SUCCESS);
575+
lindrustfinalize();
576+
}
577+
542578
pub fn ut_lind_net_getpeername() {
543579
lindrustinit(0);
544580
let cage = interface::cagetable_getref(1);

0 commit comments

Comments
 (0)