Changeset 5712
- Timestamp:
- 07/06/10 00:13:02 (3 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
umpa/branches/link-layer-integration/tests/a_unit/test_extensions/test_models.py
r5711 r5712 36 36 # Windows doesn't have a loopback interface and wants us to send 37 37 # from a valid local address 38 revhosts_ip = '127.0.0.1'38 local_ip = '127.0.0.1' 39 39 else: 40 40 # other OSes have a loopback interface (which we don't want to use here) 41 41 # and allow us to use any IP we like 42 revhosts_ip = '1.2.3.4'42 local_ip = '1.2.3.4' 43 43 44 44 class SniffThread(threading.Thread): … … 54 54 filter=self._filter) 55 55 try: 56 assert pkt[0].ip.src == "1.2.3.4"56 assert pkt[0].ip.src == local_ip 57 57 assert pkt[0].ip.dst == "8.8.8.8" 58 58 assert pkt[0].tcp.srcport == 80 59 59 assert pkt[0].tcp.dstport == 0 60 assert pkt[1].ip.src == "1.2.3.4"60 assert pkt[1].ip.src == local_ip 61 61 assert pkt[1].ip.dst == "8.8.8.8" 62 62 assert pkt[1].tcp.srcport == 0 … … 70 70 filter=self._filter) 71 71 try: 72 assert pkt[0].ip.src == "127.0.0.1"72 assert pkt[0].ip.src == local_ip 73 73 assert pkt[0].ip.dst == "8.8.8.8" 74 74 assert pkt[0].udp.srcport == 80 75 75 assert pkt[0].udp.dstport == 0 76 assert pkt[1].ip.src == "127.0.0.1"76 assert pkt[1].ip.src == local_ip 77 77 assert pkt[1].ip.dst == "8.8.8.8" 78 78 assert pkt[1].udp.srcport == 0 … … 86 86 try: 87 87 assert pkt[0].ip.src == "8.8.8.8" 88 assert pkt[0].ip.dst == revhosts_ip89 assert pkt[1].ip.src == revhosts_ip88 assert pkt[0].ip.dst == local_ip 89 assert pkt[1].ip.src == local_ip 90 90 assert pkt[1].ip.dst == "8.8.8.8" 91 91 except Exception, e: … … 96 96 pkt = umit.umpa.sniffing.sniff(2, device=self._device, filter=self._filter) 97 97 try: 98 assert pkt[0].ip.src == "127.0.0.1"98 assert pkt[0].ip.src == local_ip 99 99 assert pkt[0].ip.dst == "8.8.8.8" 100 assert pkt[1].ip.src == "127.0.0.1"100 assert pkt[1].ip.src == local_ip 101 101 assert pkt[1].ip.dst == "8.8.4.4" 102 102 except Exception, e: … … 130 130 queue = Queue.Queue() 131 131 132 th = SendPacket(umit.umpa.Packet(IP(src= '1.2.3.4', dst='8.8.8.8'),132 th = SendPacket(umit.umpa.Packet(IP(src=local_ip, dst='8.8.8.8'), 133 133 TCP(srcport=80, dstport=0))) 134 134 th.start() … … 154 154 queue = Queue.Queue() 155 155 156 th = SendPacket(umit.umpa.Packet(IP(src= '127.0.0.1', dst='8.8.8.8'),156 th = SendPacket(umit.umpa.Packet(IP(src=local_ip, dst='8.8.8.8'), 157 157 UDP(srcport=80, dstport=0))) 158 158 th.start() … … 175 175 queue = Queue.Queue() 176 176 177 th = SendPacket(umit.umpa.Packet(IP(src="8.8.8.8", dst= revhosts_ip),177 th = SendPacket(umit.umpa.Packet(IP(src="8.8.8.8", dst=local_ip), 178 178 UDP(srcport=80, dstport=0))) 179 179 th.start() … … 196 196 queue = Queue.Queue() 197 197 198 th = SendPacket(umit.umpa.Packet(IP(src= "127.0.0.1",198 th = SendPacket(umit.umpa.Packet(IP(src=local_ip, 199 199 dst="8.8.8.8"), UDP(srcport=888))) 200 200 th.start() 201 201 202 202 th2 = ForwardThread( 203 "host 127.0.0.1 and port 888 and udp",203 "host %s and port 888 and udp" % local_ip, 204 204 self.device, queue) 205 205 th2.start() 206 206 models.react(1, 207 filter="host 127.0.0.1 and port 888 and udp",207 filter="host %s and port 888 and udp" % local_ip, 208 208 device=self.device, forward="8.8.4.4") 209 209 th.join() … … 221 221 222 222 th = SendPacket(umit.umpa.Packet( 223 IP(src= "127.0.0.1", dst="8.8.8.8", ttl=ttl),223 IP(src=local_ip, dst="8.8.8.8", ttl=ttl), 224 224 UDP(srcport=888))) 225 225 th.start() 226 226 227 227 th2 = TTLThread( 228 "host 127.0.0.1and port 888 and udp",228 "host 8.8.8.8 and port 888 and udp", 229 229 self.device, queue, begin=ttl, decrement=decrement) 230 230 th2.start() 231 231 models.react(1, 232 filter="host 127.0.0.1and port 888 and udp",232 filter="host 8.8.8.8 and port 888 and udp", 233 233 device=self.device, 234 234 ttl=decrement)
