예제 #1
0
파일: lldp.py 프로젝트: apanda/pox
 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)
예제 #2
0
 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)
예제 #3
0
파일: util.py 프로젝트: kooksee/TIOT
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不是字节流"
예제 #4
0
    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
예제 #5
0
    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
예제 #6
0
 def parse(self):
     basic_tlv.parse(self)
     (self.oui, self.subtype) = struct.parse("3sB", self.next[0:4])
     self.next = self.next[4:]
예제 #7
0
	def getStructAt(self,addr,struct):
		out=struct.parse(self.read(addr,struct.sizeof()))
		if isinstance(out,Container):
			out['address']=addr
		return out
예제 #8
0
파일: lldp.py 프로젝트: apanda/pox
 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