Lines Matching refs:socket
6 use crate::socket::PollAt;
8 use crate::socket::WakerRegistration;
429 pub fn socket( in socket() function
460 pub fn socket( in socket() function
498 ($module:ident, $socket:path, $hdr:path, $packet:path, $payload:path) => {
504 let mut socket = $socket(buffer(0), buffer(1)); localVariable
505 assert_eq!(socket.send_slice(&[0; 56][..]), Err(SendError::BufferFull));
510 let mut socket = $socket(buffer(0), buffer(1)); localVariable
513 assert!(socket.can_send());
515 socket.dispatch(&mut cx, |_, _| unreachable!()),
519 assert_eq!(socket.send_slice(&$packet[..]), Ok(()));
520 assert_eq!(socket.send_slice(b""), Err(SendError::BufferFull));
521 assert!(!socket.can_send());
524 socket.dispatch(&mut cx, |_, (ip_repr, ip_payload)| {
531 assert!(!socket.can_send());
534 socket.dispatch(&mut cx, |_, (ip_repr, ip_payload)| {
541 assert!(socket.can_send());
546 let mut socket = $socket(buffer(1), buffer(0)); localVariable
549 assert!(socket.accepts(&$hdr));
550 socket.process(&mut cx, &$hdr, &$payload);
553 assert_eq!(socket.recv_slice(&mut slice[..]), Ok(4));
559 let mut socket = $socket(buffer(1), buffer(0)); localVariable
565 assert!(socket.accepts(&$hdr));
566 socket.process(&mut cx, &$hdr, &buffer);
571 let mut socket = $socket(buffer(1), buffer(0)); localVariable
574 assert!(socket.accepts(&$hdr));
575 socket.process(&mut cx, &$hdr, &$payload);
578 assert_eq!(socket.peek_slice(&mut slice[..]), Ok(4));
580 assert_eq!(socket.recv_slice(&mut slice[..]), Ok(4));
582 assert_eq!(socket.peek_slice(&mut slice[..]), Err(RecvError::Exhausted));
591 ipv4_locals::socket,
600 ipv6_locals::socket,
611 let mut socket = ipv4_locals::socket(buffer(0), buffer(2)); in test_send_illegal() localVariable
617 assert_eq!(socket.send_slice(&wrong_version[..]), Ok(())); in test_send_illegal()
619 socket.dispatch(&mut cx, |_, _| unreachable!()), in test_send_illegal()
626 assert_eq!(socket.send_slice(&wrong_protocol[..]), Ok(())); in test_send_illegal()
628 socket.dispatch(&mut cx, |_, _| unreachable!()), in test_send_illegal()
634 let mut socket = ipv6_locals::socket(buffer(0), buffer(2)); in test_send_illegal() localVariable
640 assert_eq!(socket.send_slice(&wrong_version[..]), Ok(())); in test_send_illegal()
642 socket.dispatch(&mut cx, |_, _| unreachable!()), in test_send_illegal()
649 assert_eq!(socket.send_slice(&wrong_protocol[..]), Ok(())); in test_send_illegal()
651 socket.dispatch(&mut cx, |_, _| unreachable!()), in test_send_illegal()
661 let mut socket = ipv4_locals::socket(buffer(1), buffer(0)); in test_recv_process() localVariable
662 assert!(!socket.can_recv()); in test_recv_process()
668 assert_eq!(socket.recv(), Err(RecvError::Exhausted)); in test_recv_process()
669 assert!(socket.accepts(&ipv4_locals::HEADER_REPR)); in test_recv_process()
670 socket.process( in test_recv_process()
675 assert!(socket.can_recv()); in test_recv_process()
677 assert!(socket.accepts(&ipv4_locals::HEADER_REPR)); in test_recv_process()
678 socket.process( in test_recv_process()
683 assert_eq!(socket.recv(), Ok(&cksumd_packet[..])); in test_recv_process()
684 assert!(!socket.can_recv()); in test_recv_process()
688 let mut socket = ipv6_locals::socket(buffer(1), buffer(0)); in test_recv_process() localVariable
689 assert!(!socket.can_recv()); in test_recv_process()
692 assert_eq!(socket.recv(), Err(RecvError::Exhausted)); in test_recv_process()
693 assert!(socket.accepts(&ipv6_locals::HEADER_REPR)); in test_recv_process()
694 socket.process( in test_recv_process()
699 assert!(socket.can_recv()); in test_recv_process()
701 assert!(socket.accepts(&ipv6_locals::HEADER_REPR)); in test_recv_process()
702 socket.process( in test_recv_process()
707 assert_eq!(socket.recv(), Ok(&ipv6_locals::PACKET_BYTES[..])); in test_recv_process()
708 assert!(!socket.can_recv()); in test_recv_process()
716 let mut socket = ipv4_locals::socket(buffer(1), buffer(0)); in test_peek_process() localVariable
722 assert_eq!(socket.peek(), Err(RecvError::Exhausted)); in test_peek_process()
723 assert!(socket.accepts(&ipv4_locals::HEADER_REPR)); in test_peek_process()
724 socket.process( in test_peek_process()
730 assert!(socket.accepts(&ipv4_locals::HEADER_REPR)); in test_peek_process()
731 socket.process( in test_peek_process()
736 assert_eq!(socket.peek(), Ok(&cksumd_packet[..])); in test_peek_process()
737 assert_eq!(socket.recv(), Ok(&cksumd_packet[..])); in test_peek_process()
738 assert_eq!(socket.peek(), Err(RecvError::Exhausted)); in test_peek_process()
742 let mut socket = ipv6_locals::socket(buffer(1), buffer(0)); in test_peek_process() localVariable
745 assert_eq!(socket.peek(), Err(RecvError::Exhausted)); in test_peek_process()
746 assert!(socket.accepts(&ipv6_locals::HEADER_REPR)); in test_peek_process()
747 socket.process( in test_peek_process()
753 assert!(socket.accepts(&ipv6_locals::HEADER_REPR)); in test_peek_process()
754 socket.process( in test_peek_process()
759 assert_eq!(socket.peek(), Ok(&ipv6_locals::PACKET_BYTES[..])); in test_peek_process()
760 assert_eq!(socket.recv(), Ok(&ipv6_locals::PACKET_BYTES[..])); in test_peek_process()
761 assert_eq!(socket.peek(), Err(RecvError::Exhausted)); in test_peek_process()
769 let socket = Socket::new( in test_doesnt_accept_wrong_proto() localVariable
775 assert!(!socket.accepts(&ipv4_locals::HEADER_REPR)); in test_doesnt_accept_wrong_proto()
777 assert!(!socket.accepts(&ipv6_locals::HEADER_REPR)); in test_doesnt_accept_wrong_proto()
781 let socket = Socket::new( in test_doesnt_accept_wrong_proto() localVariable
787 assert!(!socket.accepts(&ipv6_locals::HEADER_REPR)); in test_doesnt_accept_wrong_proto()
789 assert!(!socket.accepts(&ipv4_locals::HEADER_REPR)); in test_doesnt_accept_wrong_proto()