我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用data.MTU。
def read_packet(self, size=MTU): rp = RawPcapReader.read_packet(self,size) if rp is None: return None s,(sec,usec,wirelen) = rp try: p = self.LLcls(s) except KeyboardInterrupt: raise except: if conf.debug_dissector: raise p = conf.raw_layer(s) p.time = sec+0.000001*usec return p
def read_packet(self, size=MTU): rp = RawPcapReader.read_packet(self, size=size) if rp is None: return None s,(sec,usec,wirelen) = rp try: p = self.LLcls(s) except KeyboardInterrupt: raise except: if conf.debug_dissector: raise p = conf.raw_layer(s) p.time = sec+0.000001*usec return p
def read_packet(self, size=MTU): """Read blocks until it reaches either EOF or a packet, and returns None or (packet, (linktype, sec, usec, wirelen)), where packet is a string. """ while True: try: blocktype, blocklen = struct.unpack(self.endian + "2I", self.f.read(8)) except struct.error: return None block = self.f.read(blocklen - 12) try: if (blocklen,) != struct.unpack(self.endian + 'I', self.f.read(4)): raise Scapy_Exception( "Invalid pcapng block (bad blocklen)" ) except struct.error: return None res = self.blocktypes.get(blocktype, lambda block, size: None)(block, size) if res is not None: return res
def read_packet(self, size=MTU): """return a single packet read from the file returns None when no more packets are available """ hdr = self.f.read(16) if len(hdr) < 16: return None sec,usec,caplen,wirelen = struct.unpack(self.endian+"IIII", hdr) s = self.f.read(caplen)[:MTU] return s,(sec,usec,wirelen) # caplen = len(s)
def recv(self, size=MTU): """ Emulate a socket """ return self.read_packet(size)[0]
def recv(self, size=MTU): return self.read_packet(size)
def _write_header(self, pkt): self.header_present=1 if self.append: # Even if prone to race conditions, this seems to be # safest way to tell whether the header is already present # because we have to handle compressed streams that # are not as flexible as basic files g = [open,gzip.open][self.gz](self.filename,"rb") if g.read(16): return self.f.write(struct.pack(self.endian+"IHHIIII", 0xa1b2c3d4L, 2, 4, 0, 0, MTU, self.linktype)) self.f.flush()
def read_packet(self, size=MTU): """return a single packet read from the file returns None when no more packets are available """ hdr = self.f.read(16) if len(hdr) < 16: return None sec,usec,caplen,wirelen = struct.unpack(self.endian+"IIII", hdr) s = self.f.read(caplen)[:size] return s,(sec,usec,wirelen) # caplen = len(s)
def recv(self, size=MTU): """ Emulate a socket """ return self.read_packet(size=size)[0]
def recv(self, size=MTU): return self.read_packet(size=size)
def recv(self, size=MTU): return self.read_packet()
def recv(self, n=MTU): r = self.spa.recv(n) if self.proto is not None: r = self.proto(r) return r