Пример #1
0
 def SendOnNetid(self, version, s, dstaddr, dstport, netid, payload, cmsgs):
   if netid is not None:
     pktinfo = MakePktInfo(version, None, self.ifindices[netid])
     cmsg_level, cmsg_name = {
         4: (net_test.SOL_IP, csocket.IP_PKTINFO),
         6: (net_test.SOL_IPV6, csocket.IPV6_PKTINFO)}[version]
     cmsgs.append((cmsg_level, cmsg_name, pktinfo))
   csocket.Sendmsg(s, (dstaddr, dstport), payload, cmsgs, csocket.MSG_CONFIRM)
Пример #2
0
 def SendWithSourceAddress(self, address, netid, dest=net_test.IPV6_ADDR):
     pktinfo = multinetwork_base.MakePktInfo(6, address, 0)
     cmsgs = [(net_test.SOL_IPV6, IPV6_PKTINFO, pktinfo)]
     s = self.BuildSocket(6, net_test.UDPSocket, netid, "mark")
     return csocket.Sendmsg(s, (dest, 53), "Hello", cmsgs, 0)