Lines Matching refs:s

211   def assertValidPingResponse(self, s, data):  argument
212 family = s.family
215 rcvd, src = s.recvfrom(32768)
231 self.fail("Unknown socket address family %d" * s.family)
267 s = net_test.IPv4PingSocket()
268 self.assertRaisesErrno(errno.EDESTADDRREQ, s.send, net_test.IPV4_PING)
271 s = net_test.IPv6PingSocket()
272 self.assertRaisesErrno(errno.EDESTADDRREQ, s.send, net_test.IPV6_PING)
275 s = net_test.IPv4PingSocket()
276 s.connect(("127.0.0.1", 55))
278 s.send(data)
279 self.assertValidPingResponse(s, data)
282 s = net_test.IPv6PingSocket()
283 s.connect(("::1", 55))
284 s.send(net_test.IPV6_PING)
285 self.assertValidPingResponse(s, net_test.IPV6_PING)
288 s = net_test.IPv4PingSocket()
289 written = s.sendto(net_test.IPV4_PING, (net_test.IPV4_ADDR, 55))
291 self.assertValidPingResponse(s, net_test.IPV4_PING)
294 s = net_test.IPv6PingSocket()
295 written = s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
297 self.assertValidPingResponse(s, net_test.IPV6_PING)
301 s = net_test.IPv4PingSocket()
302 written = s.sendto(net_test.IPV4_PING, ("127.0.0.1", 55))
304 fd = s.fileno()
310 s = net_test.IPv6PingSocket()
311 written = s.sendto(net_test.IPV6_PING, ("::1", 55))
313 fd = s.fileno()
339 s = net_test.IPv4PingSocket()
340 s.connect(("127.0.0.1", 12345))
341 _, port = s.getsockname()
390 s = net_test.IPv4PingSocket()
391 s.bind(("0.0.0.0", 544))
392 self.assertEquals(("0.0.0.0", 544), s.getsockname())
395 s = net_test.IPv4PingSocket()
396 s.bind(("127.0.0.1", 99))
397 self.assertEquals(("127.0.0.1", 99), s.getsockname())
400 self.assertRaisesErrno(errno.EINVAL, s.bind, ("127.0.0.1", 22))
427 s = net_test.IPv4PingSocket()
428 s.sendto(net_test.IPV4_PING, (net_test.IPV4_ADDR, 9132))
429 self.assertRaisesErrno(errno.EINVAL, s.bind, ("0.0.0.0", 5429))
433 s = net_test.IPv6PingSocket()
434 s.bind(("::", 769))
435 self.assertEquals(("::", 769, 0, 0), s.getsockname())
438 s = net_test.IPv6PingSocket()
439 s.bind(("::1", 99))
440 self.assertEquals(("::1", 99, 0, 0), s.getsockname())
443 self.assertRaisesErrno(errno.EINVAL, s.bind, ("::1", 22))
460 s = net_test.IPv6PingSocket()
461 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 9132))
462 self.assertRaisesErrno(errno.EINVAL, s.bind, ("::", 5429))
465 s = net_test.IPv4PingSocket()
467 s.bind, ("255.255.255.255", 1026))
469 s.bind, ("224.0.0.1", 651))
472 s.bind, (net_test.IPV4_ADDR, 651))
474 s.setsockopt(SOL_IP, net_test.IP_TRANSPARENT, 1)
475 s.bind((net_test.IPV4_ADDR, 651))
481 s = net_test.IPv6PingSocket()
483 s.bind, ("ff02::2", 1026))
487 s.bind, (net_test.IPV6_ADDR, 651))
489 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_TRANSPARENT, 1)
490 s.bind((net_test.IPV6_ADDR, 651))
516 s = net_test.IPv6PingSocket()
518 s.bind, (self.lladdr, 1026, 0, 0))
524 s.bind((self.lladdr, 4646, 0, self.ifindex))
525 self.assertEquals((expected, 4646, 0, self.ifindex), s.getsockname())
530 s.bind, ("fe80::f00", 1026, 0, 1))
533 s = net_test.IPv6PingSocket()
534 s.bind(("::1", 1234, 0, 1))
535 self.assertEquals(("::1", 1234, 0, 0), s.getsockname())
538 s = net_test.IPv6PingSocket()
539 s.bind((self.globaladdr, 0xf976))
540 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
541 self.assertEquals("\xf9\x76", s.recv(32768)[4:6])
543 s = net_test.IPv6PingSocket()
544 s.bind((self.globaladdr, 0xace))
545 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
546 self.assertEquals("\x0a\xce", s.recv(32768)[4:6])
549 s = net_test.IPv6PingSocket()
552 s.sendto, net_test.IPV6_PING, ("fe80::1", 55))
555 s.sendto(net_test.IPV6_PING, ("fe80::1", 55, 0, self.ifindex))
559 s = net_test.IPv6PingSocket()
560 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
561 self.assertValidPingResponse(s, net_test.IPV6_PING)
562 s.sendto(net_test.IPV6_PING, ("2001:4860:4860::8844", 55))
563 self.assertValidPingResponse(s, net_test.IPV6_PING)
564 self.assertRaisesErrno(errno.EINVAL, s.sendto, net_test.IPV6_PING,
569 s = net_test.IPv6PingSocket()
573 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 93, 0xdead, 0))
574 self.assertValidPingResponse(s, net_test.IPV6_PING) # Checks flow label==0.
578 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_FLOWINFO_SEND, 1)
581 self.assertRaisesErrno(errno.EINVAL, s.sendto, net_test.IPV6_PING,
586 net_test.SetFlowLabel(s, net_test.IPV6_ADDR, 0xdead)
587 self.assertEqual(1, s.getsockopt(net_test.SOL_IPV6,
589 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 93, 0xdead, 0))
590 _, src = s.recvfrom(32768)
595 s = net_test.IPv4PingSocket()
596 s.setsockopt(SOL_IP, IP_TTL, 2)
597 s.setsockopt(SOL_IP, net_test.IP_RECVERR, 1)
598 s.sendto(net_test.IPV4_PING, (net_test.IPV4_ADDR, 55))
601 self.assertRaisesErrno(errno.EHOSTUNREACH, s.recv, 32768) # No response.
604 s = net_test.IPv6PingSocket()
605 s.setsockopt(net_test.SOL_IPV6, IPV6_UNICAST_HOPS, 2)
606 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_RECVERR, 1)
607 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 55))
610 self.assertRaisesErrno(errno.EHOSTUNREACH, s.recv, 32768) # No response.
613 s = net_test.IPv6PingSocket()
616 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_MULTICAST_IF, self.ifindex)
617 s.sendto(net_test.IPV6_PING, ("ff02::1", 55, 0, self.ifindex))
618 self.assertValidPingResponse(s, net_test.IPV6_PING)
619 self.assertValidPingResponse(s, net_test.IPV6_PING)
622 s = net_test.IPv4PingSocket()
624 s.sendto(data, ("127.0.0.1", 987))
625 self.assertValidPingResponse(s, data)
628 s = net_test.IPv6PingSocket()
629 s.bind(("::", 0xace))
631 s.sendto(data, ("::1", 953))
637 s = net_test.Socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP)
638 s.bind(("127.0.0.1", 0xace))
639 s.connect(("127.0.0.1", 0xbeef))
647 s = net_test.IPv6PingSocket()
648 s.bind(("::1", 0xace))
649 s.connect(("::1", 0xbeef))
654 s = net_test.Socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP)
655 s.bind(("127.0.0.1", 0xace))
656 s.connect(("127.0.0.1", 0xbeef))
662 s = net_test.IPv6PingSocket()
663 s.bind(("::1", 0xace))
664 s.connect(("::1", 0xbeef))
668 s.close()
672 s = net_test.IPv6PingSocket()
674 s.sendto(net_test.IPV6_PING, (net_test.IPV6_ADDR, 12345))
678 s = net_test.IPv6PingSocket()
680 s.bind((self.lladdr, 0xd00d, 0, self.ifindex))
684 s.setsockopt(net_test.SOL_IPV6, net_test.IPV6_MULTICAST_IF, self.ifindex)
685 s.connect(("ff02::1", 0xdead))
687 s.send(net_test.IPV6_PING)
691 self.assertValidPingResponse(s, net_test.IPV6_PING)
696 s = net_test.Socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)
697 s.bind(("::1", 0xace))
698 s.connect(("::1", 0xbeef))
702 s = net_test.Socket(AF_INET6, SOCK_RAW, IPPROTO_RAW)
703 s.bind(("::1", 0xace))
704 s.connect(("::1", 0xbeef))