def fix_parsed (m): """ Translate parsed packet data to dicts and stuff """ if m is None: return {"type":"raw","data":[]} if isinstance(m, basestring): return {"type":"raw","data":[ord(b) for b in m]} assert isinstance(m, packet_base) if not m.parsed: u = fix_parsed(m.raw) u['unparsed_type'] = m.__class__.__name__ return u r = {} for k,v in fields_of(m, primitives_only = False).iteritems(): if is_scalar(v): r[k] = v elif isinstance(v, (IPAddr, EthAddr)): r[k] = str(v) if hasattr(m, "payload"): r['payload'] = fix_parsed(m.payload) if 'raw' in r: #r['raw'] = [ord(b) for b in m['raw']] del r['raw'] if 'next' in r: del r['next'] r['type'] = m.__class__.__name__ return r
def fix_parsed(m): """ Translate parsed packet data to dicts and stuff """ if m is None: return {"type": "raw", "data": []} if isinstance(m, basestring): return {"type": "raw", "data": [ord(b) for b in m]} assert isinstance(m, packet_base) if not m.parsed: u = fix_parsed(m.raw) u['unparsed_type'] = m.__class__.__name__ return u r = {} for k, v in fields_of(m, primitives_only=False).iteritems(): if is_scalar(v): r[k] = v elif isinstance(v, (IPAddr, EthAddr)): r[k] = str(v) if hasattr(m, "payload"): r['payload'] = fix_parsed(m.payload) if 'raw' in r: #r['raw'] = [ord(b) for b in m['raw']] del r['raw'] if 'next' in r: del r['next'] r['type'] = m.__class__.__name__ return r
def fix_parsed (m): """ Translate parsed packet data to dicts and stuff """ if m is None: return {"type":"raw","data":[]} if isinstance(m, basestring): """ Dada uma cadeia de comprimento um, retornar um inteiro representando o ponto de código Unicode do caractere quando o argumento é um objeto unicode, ou o valor do byte quando o argumento é uma string de 8 bits. """ return {"type":"raw","data":[ord(b) for b in m]} assert isinstance(m, packet_base) if not m.parsed: u = fix_parsed(m.raw) u['unparsed_type'] = m.__class__.__name__ return u r = {} for k,v in fields_of(m, primitives_only = False).iteritems(): if is_scalar(v): r[k] = v elif isinstance(v, (IPAddr, EthAddr)): r[k] = str(v) if hasattr(m, "payload"): r['payload'] = fix_parsed(m.payload) if 'raw' in r: #r['raw'] = [ord(b) for b in m['raw']] del r['raw'] if 'next' in r: del r['next'] r['type'] = m.__class__.__name__ return r