def recv(self, bufsize): self.ins.read(1) # used only for poll/sync pkt, ts = self.nflog.pipe.popleft() if pkt is None: return try: pkt = IP(pkt) except KeyboardInterrupt: raise except: if conf.debug_dissector: raise pkt = conf.raw_layer(pkt) pkt.time = ts return pkt
def fake_sr_return(): """Fake srloop response.""" # fake unans pkt_fail = IP(dst="127.0.0.1", tos=dscp_to_tos(1)) / ICMP(type="echo-request") fake_unans = pkt_fail # fake ans pkt_ok_sent = IP(dst="127.0.0.1", tos=dscp_to_tos(2)) / ICMP(type="echo-request") pkt_ok_response = IP(dst="127.0.0.1") / ICMP(type="echo-reply") pkt_ok_sent.sent_time = 0 pkt_ok_response.time = 0.1 fake_ans = [[pkt_ok_sent, pkt_ok_response]] return (fake_ans, fake_unans)
def fake_sr_return(): """Fake srl response.""" # fake unans pkt_fail = IP(dst="127.0.0.1") / TCP( flags="S", seq=0, dport=80, sport=65000) fake_unans = PacketList(pkt_fail) # fake ans pkt_ok_sent = IP(dst="127.0.0.1") / TCP( flags="S", seq=1, dport=80, sport=65001) pkt_ok_response = IP(dst="127.0.0.1") / TCP( flags="S", seq=1, ack=2, dport=65001, sport=80) pkt_ok_sent.sent_time = 0 pkt_ok_response.time = 0.1 fake_ans = [[pkt_ok_sent, pkt_ok_response]] return (fake_ans, fake_unans)