Lines Matching refs:s
264 def assertValidPingResponse(self, s, data): argument
265 family = s.family
268 rcvd, src = s.recvfrom(32768)
284 self.fail("Unknown socket address family %d" * s.family)
336 s = net_test.IPv4PingSocket()
337 self.assertRaisesErrno(errno.EDESTADDRREQ, s.send, net_test.IPV4_PING)
340 s = net_test.IPv6PingSocket()
341 self.assertRaisesErrno(errno.EDESTADDRREQ, s.send, net_test.IPV6_PING)
344 s = net_test.IPv4PingSocket()
345 s.connect(("127.0.0.1", 55))
347 s.send(data)
348 self.assertValidPingResponse(s, data)
351 s = net_test.IPv6PingSocket()
352 s.connect(("::1", 55))
353 s.send(net_test.IPV6_PING)
354 self.assertValidPingResponse(s, net_test.IPV6_PING)
357 s = net_test.IPv4PingSocket()
358 written = s.sendto(net_test.IPV4_PING, (net_test.IPV4_ADDR, 55))
360 self.assertValidPingResponse(s, net_test.IPV4_PING)
363 s = net_test.IPv6PingSocket()
364 written = s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
366 self.assertValidPingResponse(s, net_test.IPV6_PING)
370 s = net_test.IPv4PingSocket()
371 written = s.sendto(net_test.IPV4_PING, ("127.0.0.1", 55))
373 fd = s.fileno()
379 s = net_test.IPv6PingSocket()
380 written = s.sendto(net_test.IPV6_PING, ("::1", 55))
382 fd = s.fileno()
408 s = net_test.IPv4PingSocket()
409 s.connect(("127.0.0.1", 12345))
410 _, port = s.getsockname()
459 s = net_test.IPv4PingSocket()
460 s.bind(("0.0.0.0", 544))
461 self.assertEquals(("0.0.0.0", 544), s.getsockname())
464 s = net_test.IPv4PingSocket()
465 s.bind(("127.0.0.1", 99))
466 self.assertEquals(("127.0.0.1", 99), s.getsockname())
469 self.assertRaisesErrno(errno.EINVAL, s.bind, ("127.0.0.1", 22))
496 s = net_test.IPv4PingSocket()
497 s.sendto(net_test.IPV4_PING, (net_test.IPV4_ADDR, 9132))
498 self.assertRaisesErrno(errno.EINVAL, s.bind, ("0.0.0.0", 5429))
502 s = net_test.IPv6PingSocket()
503 s.bind(("::", 769))
504 self.assertEquals(("::", 769, 0, 0), s.getsockname())
507 s = net_test.IPv6PingSocket()
508 s.bind(("::1", 99))
509 self.assertEquals(("::1", 99, 0, 0), s.getsockname())
512 self.assertRaisesErrno(errno.EINVAL, s.bind, ("::1", 22))
529 s = net_test.IPv6PingSocket()
530 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 9132))
531 self.assertRaisesErrno(errno.EINVAL, s.bind, ("::", 5429))
534 s = net_test.IPv4PingSocket()
536 s.bind, ("255.255.255.255", 1026))
538 s.bind, ("224.0.0.1", 651))
541 s.bind, (net_test.IPV4_ADDR, 651))
543 s.setsockopt(SOL_IP, net_test.IP_TRANSPARENT, 1)
544 s.bind((net_test.IPV4_ADDR, 651))
550 s = net_test.IPv6PingSocket()
552 s.bind, ("ff02::2", 1026))
556 s.bind, (net_test.IPV6_ADDR, 651))
558 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_TRANSPARENT, 1)
559 s.bind((net_test.IPV6_ADDR, 651))
585 s = net_test.IPv6PingSocket()
587 s.bind, (self.lladdr, 1026, 0, 0))
593 s.bind((self.lladdr, 4646, 0, self.ifindex))
594 self.assertEquals((expected, 4646, 0, self.ifindex), s.getsockname())
599 s.bind, ("fe80::f00", 1026, 0, 1))
602 s = net_test.IPv6PingSocket()
603 s.bind(("::1", 1234, 0, 1))
604 self.assertEquals(("::1", 1234, 0, 0), s.getsockname())
607 s = net_test.IPv6PingSocket()
608 s.bind((self.globaladdr, 0xf976))
609 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
610 self.assertEquals("\xf9\x76", s.recv(32768)[4:6])
612 s = net_test.IPv6PingSocket()
613 s.bind((self.globaladdr, 0xace))
614 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
615 self.assertEquals("\x0a\xce", s.recv(32768)[4:6])
618 s = net_test.IPv6PingSocket()
621 s.sendto, net_test.IPV6_PING, ("fe80::1", 55))
624 s.sendto(net_test.IPV6_PING, ("fe80::1", 55, 0, self.ifindex))
635 s = net_test.IPv6PingSocket()
642 self.SelectInterface(s, netid, mode)
656 s.sendto, net_test.IPV6_PING, (dst, 55, 0, otherscopeid))
659 s.connect, (dst, 55, 0, otherscopeid))
663 s.sendto(net_test.IPV6_PING, (dst, 123, 0, scopeid))
664 self.assertValidPingResponse(s, net_test.IPV6_PING)
673 s = net_test.IPv6PingSocket()
674 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
675 self.assertValidPingResponse(s, net_test.IPV6_PING)
676 s.sendto(net_test.IPV6_PING, ("2001:4860:4860::8844", 55))
677 self.assertValidPingResponse(s, net_test.IPV6_PING)
678 self.assertRaisesErrno(errno.EINVAL, s.sendto, net_test.IPV6_PING,
683 s = net_test.IPv6PingSocket()
687 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 93, 0xdead, 0))
688 self.assertValidPingResponse(s, net_test.IPV6_PING) # Checks flow label==0.
692 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_FLOWINFO_SEND, 1)
695 self.assertRaisesErrno(errno.EINVAL, s.sendto, net_test.IPV6_PING,
700 net_test.SetFlowLabel(s, net_test.IPV6_ADDR, 0xdead)
701 self.assertEqual(1, s.getsockopt(net_test.SOL_IPV6,
703 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 93, 0xdead, 0))
704 _, src = s.recvfrom(32768)
709 s = net_test.IPv4PingSocket()
710 s.setsockopt(SOL_IP, IP_TTL, 2)
711 s.setsockopt(SOL_IP, net_test.IP_RECVERR, 1)
712 s.sendto(net_test.IPV4_PING, (net_test.IPV4_ADDR, 55))
715 self.assertRaisesErrno(errno.EHOSTUNREACH, s.recv, 32768) # No response.
718 s = net_test.IPv6PingSocket()
719 s.setsockopt(net_test.SOL_IPV6, IPV6_UNICAST_HOPS, 2)
720 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_RECVERR, 1)
721 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
724 self.assertRaisesErrno(errno.EHOSTUNREACH, s.recv, 32768) # No response.
727 s = net_test.IPv6PingSocket()
730 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_MULTICAST_IF, self.ifindex)
731 s.sendto(net_test.IPV6_PING, ("ff02::1", 55, 0, self.ifindex))
732 self.assertValidPingResponse(s, net_test.IPV6_PING)
733 self.assertValidPingResponse(s, net_test.IPV6_PING)
736 s = net_test.IPv4PingSocket()
738 s.sendto(data, ("127.0.0.1", 987))
739 self.assertValidPingResponse(s, data)
742 s = net_test.IPv6PingSocket()
743 s.bind(("::", 0xace))
745 s.sendto(data, ("::1", 953))
751 s = net_test.Socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP)
752 s.bind(("127.0.0.1", 0xace))
753 s.connect(("127.0.0.1", 0xbeef))
761 s = net_test.IPv6PingSocket()
762 s.bind(("::1", 0xace))
763 s.connect(("::1", 0xbeef))
768 s = net_test.Socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP)
769 s.bind(("127.0.0.1", 0xace))
770 s.connect(("127.0.0.1", 0xbeef))
776 s = net_test.IPv6PingSocket()
777 s.bind(("::1", 0xace))
778 s.connect(("::1", 0xbeef))
782 s.close()
786 s = net_test.IPv6PingSocket()
788 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 12345))
792 s = net_test.IPv6PingSocket()
794 s.bind((self.lladdr, 0xd00d, 0, self.ifindex))
798 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_MULTICAST_IF, self.ifindex)
799 s.connect(("ff02::1", 0xdead))
801 s.send(net_test.IPV6_PING)
802 s.recvfrom(32768, MSG_PEEK) # Wait until the receive thread replies.
805 self.assertValidPingResponse(s, net_test.IPV6_PING)
810 s = net_test.Socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)
811 s.bind(("::1", 0xace))
812 s.connect(("::1", 0xbeef))
816 s = net_test.Socket(AF_INET6, SOCK_RAW, IPPROTO_RAW)
817 s.bind(("::1", 0xace))
818 s.connect(("::1", 0xbeef))
828 s = net_test.IPv6PingSocket()
829 s.setsockopt(net_test.SOL_IPV6, csocket.IPV6_DONTFRAG, 1)
830 s.setsockopt(net_test.SOL_IPV6, csocket.IPV6_MTU_DISCOVER, 2)
831 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_RECVERR, 1)
832 s.connect((net_test.IPV6_ADDR, 55))
834 s.send(pkt)
835 self.assertRaisesErrno(errno.EMSGSIZE, s.recv, 32768)
836 data, addr, cmsg = csocket.Recvmsg(s, 4096, 1024, csocket.MSG_ERRQUEUE)
841 ident = struct.pack("!H", s.getsockname()[1])