def parse (self): basic_tlv.parse(self) (cap,en) = struct.parse("!HH", self.next) del self.caps[:] del self.enabled_caps[:] for i in range(0, 16): self.caps.append(True if (cap and (1 << i)) else False) self.enabled_caps.append(True if (en and (1 << i)) else False)
def parse(self): basic_tlv.parse(self) (cap, en) = struct.parse("!HH", self.next) del self.caps[:] del self.enabled_caps[:] for i in range(0, 16): self.caps.append(True if (cap and (1 << i)) else False) self.enabled_caps.append(True if (en and (1 << i)) else False)
def parsePkgs(struct, bytestream): try: container = struct.parse(bytestream) return container.packets, container.leftovers except Exception, e: print "错误原因:" print e print "输入的参数1不是Struct" print "输入的参数2不是字节流"
def parse_stream(cls, stream, ctx=None): if cls._struct_fields: for name, struct in cls._struct_fields: try: ctx[name] = struct.parse(stream, ctx=ctx) except: print("Context at time of failure:", ctx) raise res = ctx else: res = cls._parse(stream, ctx=ctx) return res
def parse(self): basic_tlv.parse(self) (self.oui, self.subtype) = struct.parse("3sB", self.next[0:4]) self.next = self.next[4:]
def getStructAt(self,addr,struct): out=struct.parse(self.read(addr,struct.sizeof())) if isinstance(out,Container): out['address']=addr return out
def parse (self): basic_tlv.parse(self) (self.oui,self.subtype) = struct.parse("3sB", self.next[0:4]) self.next = self.next[4:]
def getStructAt(self, addr, struct): out = struct.parse(self.read(addr, struct.sizeof())) if isinstance(out, Container): out['address'] = addr return out