code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
_resv = self._read_fileng(2) _keys = self._read_unpack(1) _alen = self._read_unpack(1) _seqn = self._read_unpack(4) auth = dict( key_id=_keys, len=_alen, seq=_seqn, ) return auth
def _read_encrypt_auth(self)
Read Authentication field when Cryptographic Authentication is employed. Structure of Cryptographic Authentication [RFC 2328]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0 | Key ID | Auth Data Len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Cryptographic sequence number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 - Reserved (must be zero) 2 16 ospf.auth.key_id Key ID 3 24 ospf.auth.len Auth Data Length 4 32 ospf.auth.seq Cryptographic Sequence Number
5.794355
4.385906
1.321131
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, numbers.Integral): name = type(var).__name__ raise ComplexError( f'Function {func} expected integral number, {name} got instead.')
def int_check(*args, func=None)
Check if arguments are integrals.
5.261915
4.563182
1.153124
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, numbers.Real): name = type(var).__name__ raise ComplexError( f'Function {func} expected real number, {name} got instead.')
def real_check(*args, func=None)
Check if arguments are real numbers.
5.248132
4.301405
1.220097
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, numbers.Complex): name = type(var).__name__ raise ComplexError( f'Function {func} expected complex number, {name} got instead.')
def complex_check(*args, func=None)
Check if arguments are complex numbers.
4.893411
4.299806
1.138054
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, numbers.Number): name = type(var).__name__ raise DigitError( f'Function {func} expected number, {name} got instead.')
def number_check(*args, func=None)
Check if arguments are numbers.
5.174087
4.583232
1.128917
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (bytes, collections.abc.ByteString)): name = type(var).__name__ raise BytesError( f'Function {func} expected bytes, {name} got instead.')
def bytes_check(*args, func=None)
Check if arguments are bytes type.
5.229712
4.612471
1.13382
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (bytearray, collections.abc.ByteString, collections.abc.MutableSequence)): name = type(var).__name__ raise BytearrayError( f'Function {func} expected bytearray, {name} got instead.')
def bytearray_check(*args, func=None)
Check if arguments are bytearray type.
4.483716
4.060209
1.104307
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (str, collections.UserString, collections.abc.Sequence)): name = type(var).__name__ raise StringError( f'Function {func} expected str, {name} got instead.')
def str_check(*args, func=None)
Check if arguments are str type.
5.553167
5.070527
1.095185
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, bool): name = type(var).__name__ raise BoolError( f'Function {func} expected bool, {name} got instead.')
def bool_check(*args, func=None)
Check if arguments are bytes type.
5.497958
4.996364
1.100392
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (list, collections.UserList, collections.abc.MutableSequence)): name = type(var).__name__ raise ListError( f'Function {func} expected list, {name} got instead.')
def list_check(*args, func=None)
Check if arguments are list type.
5.420522
4.837774
1.120458
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (dict, collections.UserDict, collections.abc.MutableMapping)): name = type(var).__name__ raise DictError( f'Function {func} expected dict, {name} got instead.')
def dict_check(*args, func=None)
Check if arguments are dict type.
4.864711
4.566705
1.065256
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (tuple, collections.abc.Sequence)): name = type(var).__name__ raise TupleError( f'Function {func} expected tuple, {name} got instead.')
def tuple_check(*args, func=None)
Check if arguments are tuple type.
4.763874
4.275981
1.114101
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, io.IOBase): name = type(var).__name__ raise IOObjError( f'Function {func} expected file-like object, {name} got instead.')
def io_check(*args, func=None)
Check if arguments are file-like object.
5.370134
4.234899
1.268067
from pcapkit.corekit.infoclass import Info func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, Info): name = type(var).__name__ raise InfoError( f'Function {func} expected Info instance, {name} got instead.')
def info_check(*args, func=None)
Check if arguments are Info instance.
5.200924
4.50248
1.155124
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, ipaddress._IPAddressBase): name = type(var).__name__ raise IPError( f'Function {func} expected IP address, {name} got instead.')
def ip_check(*args, func=None)
Check if arguments are IP addresses.
5.708911
5.039999
1.132721
func = func or inspect.stack()[2][3] for var in args: if not isinstance(var, (enum.EnumMeta, aenum.EnumMeta)): name = type(var).__name__ raise EnumError( f'Function {func} expected enumeration, {name} got instead.')
def enum_check(*args, func=None)
Check if arguments are of protocol type.
5.471378
4.998597
1.094583
func = func or inspect.stack()[2][3] if 'IP' in protocol: _ip_frag_check(*args, func=func) elif 'TCP' in protocol: _tcp_frag_check(*args, func=func) else: raise FragmentError(f'Unknown fragmented protocol {protocol}.')
def frag_check(*args, protocol, func=None)
Check if arguments are valid fragments.
3.343638
2.985109
1.120106
func = func or inspect.stack()[2][3] for var in args: dict_check(var, func=func) bufid = var.get('bufid') str_check(bufid[3], func=func) bool_check(var.get('mf'), func=func) ip_check(bufid[0], bufid[1], func=func) bytearray_check(var.get('header'), var.get('payload'), func=func) int_check(bufid[2], var.get('num'), var.get('fo'), var.get('ihl'), var.get('tl'), func=func)
def _ip_frag_check(*args, func=None)
Check if arguments are valid IP fragments.
4.395572
4.1907
1.048887
func = func or inspect.stack()[2][3] for var in args: dict_check(var, func=func) dict_check(var.get('frame'), func=func) enum_check(var.get('protocol'), func=func) real_check(var.get('timestamp'), func=func) ip_check(var.get('src'), var.get('dst'), func=func) bool_check(var.get('syn'), var.get('fin'), func=func) int_check(var.get('srcport'), var.get('dstport'), var.get('index'), func=func)
def pkt_check(*args, func=None)
Check if arguments are valid packets.
2.973686
2.794975
1.06394
if self._newflg: self._newflg = False temp_dtgram = copy.deepcopy(self._dtgram) for (bufid, buffer) in self._buffer.items(): temp_dtgram += self.submit(buffer, bufid=bufid) return tuple(temp_dtgram) return tuple(self._dtgram)
def fetch(self)
Fetch datagram.
6.249832
5.445486
1.147709
int_check(pkt_num) for counter, datagram in enumerate(self.datagram): if pkt_num in datagram.index: return counter return None
def index(self, pkt_num)
Return datagram index.
7.377694
5.06461
1.456715
for packet in packets: frag_check(packet, protocol=self.protocol) info = Info(packet) self.reassembly(info) self._newflg = True
def run(self, packets)
Run automatically. Positional arguments: * packets -- list<dict>, list of packet dicts to be reassembled
14.253448
18.839838
0.756559
if length is None: length = len(self) _next = self._read_protos(1) _hlen = self._read_unpack(1) _type = self._read_unpack(1) _temp = self._read_fileng(1) _csum = self._read_fileng(2) # _data = self._read_fileng((_hlen+1)*8) mh = dict( next=_next, length=(_hlen + 1) * 8, type=_MOBILITY_TYPE.get(_type, 'Unassigned'), chksum=_csum, ) length -= mh['length'] mh['packet'] = self._read_packet(header=mh['length'], payload=length) if extension: self._protos = None return mh return self._decode_next_layer(mh, _next, length)
def read_mh(self, length, extension)
Read Mobility Header. Structure of MH header [RFC 6275]: +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Payload Proto | Header Len | MH Type | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Checksum | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | . . . Message Data . . . | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 mh.next Next Header 1 8 mh.length Header Length 2 16 mh.type Mobility Header Type 3 24 - Reserved 4 32 mh.chksum Checksum 6 48 mh.data Message Data
5.072417
4.21231
1.204189
if isinstance(key, int): return DI(key) if key not in DI._member_map_: extend_enum(DI, key, default) return DI[key]
def get(key, default=-1)
Backport support for original codes.
7.669672
6.563574
1.168521
if isinstance(key, int): return Certificate(key) if key not in Certificate._member_map_: extend_enum(Certificate, key, default) return Certificate[key]
def get(key, default=-1)
Backport support for original codes.
7.167058
6.423409
1.115772
if length is None: length = len(self) _srcp = self._read_unpack(2) _dstp = self._read_unpack(2) _tlen = self._read_unpack(2) _csum = self._read_fileng(2) udp = dict( srcport=_srcp, dstport=_dstp, len=_tlen, checksum=_csum, ) length = udp['len'] - 8 udp['packet'] = self._read_packet(header=8, payload=length) return self._decode_next_layer(udp, None, length)
def read_udp(self, length)
Read User Datagram Protocol (UDP). Structure of UDP header [RFC 768]: 0 7 8 15 16 23 24 31 +--------+--------+--------+--------+ | Source | Destination | | Port | Port | +--------+--------+--------+--------+ | | | | Length | Checksum | +--------+--------+--------+--------+ | | data octets ... +---------------- ... Octets Bits Name Description 0 0 udp.srcport Source Port 2 16 udp.dstport Destination Port 4 32 udp.len Length (header includes) 6 48 udp.checksum Checksum
3.936729
3.626405
1.085573
if length is None: length = len(self) _csum = self._read_fileng(2) _tlen = self._read_unpack(2) _ctrl = self._read_unpack(1) _type = self._read_unpack(1) _dsta = self._read_ipx_address() _srca = self._read_ipx_address() ipx = dict( chksum=_csum, len=_tlen, count=_ctrl, type=TYPE.get(_type), dst=_dsta, src=_srca, ) proto = ipx['type'] length = ipx['len'] - 30 ipx['packet'] = self._read_packet(header=30, payload=length) return self._decode_next_layer(ipx, proto, length)
def read_ipx(self, length)
Read Internetwork Packet Exchange. Structure of IPX header [RFC 1132]: Octets Bits Name Description 0 0 ipx.cksum Checksum 2 16 ipx.len Packet Length (header includes) 4 32 ipx.count Transport Control (hop count) 5 40 ipx.type Packet Type 6 48 ipx.dst Destination Address 18 144 ipx.src Source Address
3.904575
3.366942
1.15968
# Address Number _byte = self._read_fileng(4) _ntwk = ':'.join(textwrap.wrap(_byte.hex(), 2)) # Node Number (MAC) _byte = self._read_fileng(6) _node = ':'.join(textwrap.wrap(_byte.hex(), 2)) _maca = '-'.join(textwrap.wrap(_byte.hex(), 2)) # Socket Number _sock = self._read_fileng(2) # Whole Address _list = [_ntwk, _node, _sock.hex()] _addr = ':'.join(_list) addr = dict( network=_ntwk, node=_maca, socket=SOCK.get(int(_sock.hex(), base=16)) or _sock, addr=_addr, ) return addr
def _read_ipx_address(self)
Read IPX address field. Structure of IPX address: Octets Bits Name Description 0 0 ipx.addr.network Network Number 4 32 ipx.addr.node Node Number 10 80 ipx.addr.socket Socket Number
4.247075
4.029067
1.054109
if isinstance(key, int): return Group(key) if key not in Group._member_map_: extend_enum(Group, key, default) return Group[key]
def get(key, default=-1)
Backport support for original codes.
6.341535
5.210846
1.216988
if length is None: length = len(self) _hwty = self._read_unpack(2) _ptty = self._read_unpack(2) _hlen = self._read_unpack(1) _plen = self._read_unpack(1) _oper = self._read_unpack(2) _shwa = self._read_addr_resolve(_hlen, _hwty) _spta = self._read_proto_resolve(_plen, _ptty) _thwa = self._read_addr_resolve(_hlen, _hwty) _tpta = self._read_proto_resolve(_plen, _ptty) if _oper in (5, 6, 7): self._acnm = 'DRARP' self._name = 'Dynamic Reverse Address Resolution Protocol' elif _oper in (8, 9): self._acnm = 'InARP' self._name = 'Inverse Address Resolution Protocol' elif _oper in (3, 4): self._acnm = 'RARP' self._name = 'Reverse Address Resolution Protocol' else: self._acnm = 'ARP' self._name = 'Address Resolution Protocol' _htype = HRD.get(_hwty) if re.match(r'.*Ethernet.*', _htype, re.IGNORECASE): _ptype = ETHERTYPE.get(_ptty) else: _ptype = f'Unknown [{_ptty}]' arp = dict( htype=_htype, ptype=_ptype, hlen=_hlen, plen=_plen, oper=OPER.get(_oper), sha=_shwa, spa=_spta, tha=_thwa, tpa=_tpta, len=8 + _hlen * 2 + _plen * 2, ) length -= arp['len'] arp['packet'] = self._read_packet(header=arp['len'], payload=length) return self._decode_next_layer(arp, None, length)
def read_arp(self, length)
Read Address Resolution Protocol. Structure of ARP header [RFC 826]: Octets Bits Name Description 0 0 arp.htype Hardware Type 2 16 arp.ptype Protocol Type 4 32 arp.hlen Hardware Address Length 5 40 arp.plen Protocol Address Length 6 48 arp.oper Operation 8 64 arp.sha Sender Hardware Address 14 112 arp.spa Sender Protocol Address 18 144 arp.tha Target Hardware Address 24 192 arp.tpa Target Protocol Address
3.004964
2.716878
1.106036
if htype == 1: # Ethernet _byte = self._read_fileng(6) _addr = '-'.join(textwrap.wrap(_byte.hex(), 2)) else: _addr = self._read_fileng(length) return _addr
def _read_addr_resolve(self, length, htype)
Resolve MAC address according to protocol. Positional arguments: * length -- int, hardware address length * htype -- int, hardware type Returns: * str -- MAC address
4.696834
4.836373
0.971148
# if ptype == '0800': # IPv4 # _byte = self._read_fileng(4) # _addr = '.'.join([str(_) for _ in _byte]) # elif ptype == '86dd': # IPv6 # adlt = [] # list of IPv6 hexadecimal address # ctr_ = collections.defaultdict(int) # # counter for consecutive groups of zero value # ptr_ = 0 # start pointer of consecutive groups of zero value # last = False # if last hextet/group is zero value # omit = False # omitted flag, since IPv6 address can omit to `::` only once # for index in range(8): # hex_ = self._read_fileng(2).hex().lstrip('0') # if hex_: # if hextet is not '', directly append # adlt.append(hex_) # last = False # else: # if hextet is '', append '0' # adlt.append('0') # if last: # if last hextet is '', ascend counter # ctr_[ptr_] += 1 # else: # if last hextet is not '', record pointer # ptr_ = index # last = True # ctr_[ptr_] = 1 # ptr_ = max(ctr_, key=ctr_.get) if ctr_ else 0 # fetch start pointer with longest zero values # end_ = ptr_ + ctr_[ptr_] # calculate end pointer # if ctr_[ptr_] > 1: # only omit if zero values are in a consecutive group # del adlt[ptr_:end_] # remove zero values # if ptr_ == 0 and end_ == 8: # insert `::` if IPv6 unspecified address (::) # adlt.insert(ptr_, '::') # elif ptr_ == 0 or end_ == 8: # insert `:` if zero values are from start or at end # adlt.insert(ptr_, ':') # else: # insert '' otherwise # adlt.insert(ptr_, '') # _addr = ':'.join(adlt) # else: # _addr = self._read_fileng(length) # return _addr if ptype == '0800': # IPv4 return ipaddress.ip_address(self._read_fileng(4)) elif ptype == '86dd': # IPv6 return ipaddress.ip_address(self._read_fileng(16)) else: return self._read_fileng(length)
def _read_proto_resolve(self, length, ptype)
Resolve IP address according to protocol. Positional arguments: * length -- int, protocol address length * ptype -- int, protocol type Returns: * str -- IP address
3.743573
3.681486
1.016865
if isinstance(key, int): return Setting(key) if key not in Setting._member_map_: extend_enum(Setting, key, default) return Setting[key]
def get(key, default=-1)
Backport support for original codes.
6.737927
5.813331
1.159048
if isinstance(key, int): return Transport(key) if key not in Transport._member_map_: extend_enum(Transport, key, default) return Transport[key]
def get(key, default=-1)
Backport support for original codes.
7.01059
6.056963
1.157443
if isinstance(key, int): return TOS_DEL(key) if key not in TOS_DEL._member_map_: extend_enum(TOS_DEL, key, default) return TOS_DEL[key]
def get(key, default=-1)
Backport support for original codes.
5.956742
5.557714
1.071797
if isinstance(key, int): return EtherType(key) if key not in EtherType._member_map_: extend_enum(EtherType, key, default) return EtherType[key]
def get(key, default=-1)
Backport support for original codes.
4.918379
4.51947
1.088265
if isinstance(key, int): return TOS_ECN(key) if key not in TOS_ECN._member_map_: extend_enum(TOS_ECN, key, default) return TOS_ECN[key]
def get(key, default=-1)
Backport support for original codes.
4.681132
4.398568
1.06424
if isinstance(key, int): return Frame(key) if key not in Frame._member_map_: extend_enum(Frame, key, default) return Frame[key]
def get(key, default=-1)
Backport support for original codes.
6.792215
5.95616
1.140368
if not (isinstance(value, int) and 0x00 <= value <= 0xFF): raise ValueError('%r is not a valid %s' % (value, cls.__name__)) if 0x0D <= value <= 0xEF: extend_enum(cls, 'Unassigned [0x%s]' % hex(value)[2:].upper().zfill(2), value) return cls(value) if 0xF0 <= value <= 0xFF: # [RFC 7540] extend_enum(cls, 'Reserved for Experimental Use [0x%s]' % hex(value)[2:].upper().zfill(2), value) return cls(value) super()._missing_(value)
def _missing_(cls, value)
Lookup function used when value is not found.
3.074729
3.163337
0.971989
if 'IPv4' in frame: ipv4 = frame['IPv4'].info if ipv4.flags.df: # dismiss not fragmented frame return False, None data = dict( bufid=( ipv4.src, # source IP address ipv4.dst, # destination IP address ipv4.id, # identification ipv4.proto.name, # payload protocol type ), num=frame.info.number, # original packet range number fo=ipv4.frag_offset, # fragment offset ihl=ipv4.hdr_len, # internet header length mf=ipv4.flags.mf, # more fragment flag tl=ipv4.len, # total length, header includes header=bytearray(ipv4.packet.header), # raw bytearray type header payload=bytearray(ipv4.packet.payload or b''), # raw bytearray type payload ) return True, data return False, None
def ipv4_reassembly(frame)
Make data for IPv4 reassembly.
5.225379
5.103569
1.023868
if 'IPv6' in frame: ipv6 = frame['IPv6'].info if 'frag' not in ipv6: # dismiss not fragmented frame return False, None data = dict( bufid=( ipv6.src, # source IP address ipv6.dst, # destination IP address ipv6.label, # label ipv6.ipv6_frag.next.name, # next header field in IPv6 Fragment Header ), num=frame.info.number, # original packet range number fo=ipv6.ipv6_frag.offset, # fragment offset ihl=ipv6.hdr_len, # header length, only headers before IPv6-Frag mf=ipv6.ipv6_frag.mf, # more fragment flag tl=ipv6.hdr_len + ipv6.raw_len, # total length, header includes header=bytearray(ipv6.fragment.header), # raw bytearray type header before IPv6-Frag payload=bytearray(ipv6.fragment.payload or b''), # raw bytearray type payload after IPv6-Frag ) return True, data return False, None
def ipv6_reassembly(frame)
Make data for IPv6 reassembly.
5.54193
5.415977
1.023256
if 'TCP' in frame: ip = (frame['IPv4'] if 'IPv4' in frame else frame['IPv6']).info tcp = frame['TCP'].info data = dict( bufid=( ip.src, # source IP address ip.dst, # destination IP address tcp.srcport, # source port tcp.dstport, # destination port ), num=frame.info.number, # original packet range number ack=tcp.ack, # acknowledgement dsn=tcp.seq, # data sequence number syn=tcp.flags.syn, # synchronise flag fin=tcp.flags.fin, # finish flag rst=tcp.flags.rst, # reset connection flag payload=bytearray(tcp.packet.payload or b''), # raw bytearray type payload ) raw_len = len(data['payload']) # payload length, header excludes data['first'] = tcp.seq # this sequence number data['last'] = tcp.seq + raw_len # next (wanted) sequence number data['len'] = raw_len # payload length, header excludes return True, data return False, None
def tcp_reassembly(frame)
Make data for TCP reassembly.
4.320276
4.20076
1.028451
if 'TCP' in frame: ip = (frame['IPv4'] if 'IPv4' in frame else frame['IPv6']).info tcp = frame['TCP'].info data = dict( protocol=data_link, # data link type from global header index=frame.info.number, # frame number frame=frame.info, # extracted frame info syn=tcp.flags.syn, # TCP synchronise (SYN) flag fin=tcp.flags.fin, # TCP finish (FIN) flag src=ip.src, # source IP dst=ip.dst, # destination IP srcport=tcp.srcport, # TCP source port dstport=tcp.dstport, # TCP destination port timestamp=frame.info.time_epoch, # frame timestamp ) return True, data return False, None
def tcp_traceflow(frame, *, data_link)
Trace packet flow for TCP.
3.558325
3.471468
1.02502
if isinstance(key, int): return TOS_REL(key) if key not in TOS_REL._member_map_: extend_enum(TOS_REL, key, default) return TOS_REL[key]
def get(key, default=-1)
Backport support for original codes.
5.406889
5.047052
1.071296
BUFID = info.bufid # Buffer Identifier FO = info.fo # Fragment Offset IHL = info.ihl # Internet Header Length MF = info.mf # More Fragments flag TL = info.tl # Total Length # when non-fragmented (possibly discarded) packet received if not FO and not MF: if BUFID in self._buffer: self._dtgram += self.submit(self._buffer[BUFID]) del self._buffer[BUFID] return # initialise buffer with BUFID if BUFID not in self._buffer: self._buffer[BUFID] = dict( TDL=0, # Total Data Length RCVBT=bytearray(8191), # Fragment Received Bit Table index=list(), # index record header=bytearray(), # header buffer datagram=bytearray(65535), # data buffer ) # append packet index self._buffer[BUFID]['index'].append(info.num) # put data into data buffer start = FO stop = TL - IHL + FO self._buffer[BUFID]['datagram'][start:stop] = info.payload # set RCVBT bits (in 8 octets) start = FO // 8 stop = FO // 8 + (TL - IHL + 7) // 8 self._buffer[BUFID]['RCVBT'][start:stop] = b'\x01' * (stop - start + 1) # get total data length (header excludes) if not MF: TDL = TL - IHL + FO # put header into header buffer if not FO: self._buffer[BUFID]['header'] = info.header # when datagram is reassembled in whole start = 0 stop = (TDL + 7) // 8 if TDL and all(self._buffer[BUFID]['RCVBT'][start:stop]): self._dtgram += self.submit(self._buffer[BUFID], checked=True) del self._buffer[BUFID]
def reassembly(self, info)
Reassembly procedure. Positional arguments: * info -- Info, info dict of packets to be reassembled
4.599947
4.651062
0.98901
TDL = buf['TDL'] RCVBT = buf['RCVBT'] index = buf['index'] header = buf['header'] datagram = buf['datagram'] start = 0 stop = (TDL + 7) // 8 flag = checked or (TDL and all(RCVBT[start:stop])) # if datagram is not implemented if not flag and self._strflg: data = list() byte = bytearray() # extract received payload for (bctr, bit) in enumerate(RCVBT): if bit: # received bit this = bctr * 8 that = this + 8 byte += datagram[this:that] else: # missing bit if byte: # strip empty payload data.append(bytes(byte)) byte = bytearray() # strip empty packets if data or header: packet = Info( NotImplemented=True, index=tuple(index), header=header or None, payload=tuple(data) or None, ) # if datagram is reassembled in whole else: payload = datagram[:TDL] packet = Info( NotImplemented=False, index=tuple(index), packet=(bytes(header) + bytes(payload)) or None, ) return [packet]
def submit(self, buf, *, checked=False)
Submit reassembled payload. Positional arguments: * buf -- dict, buffer dict of reassembled packets Keyword arguments: * bufid -- tuple, buffer identifier Returns: * list -- reassembled packets
6.162082
6.055474
1.017605
if length is None: length = len(self) _htet = self._read_ip_hextet() _plen = self._read_unpack(2) _next = self._read_protos(1) _hlmt = self._read_unpack(1) _srca = self._read_ip_addr() _dsta = self._read_ip_addr() ipv6 = dict( version=_htet[0], tclass=_htet[1], label=_htet[2], payload=_plen, next=_next, limit=_hlmt, src=_srca, dst=_dsta, ) hdr_len = 40 raw_len = ipv6['payload'] ipv6['packet'] = self._read_packet(header=hdr_len, payload=raw_len) return self._decode_next_layer(ipv6, _next, raw_len)
def read_ipv6(self, length)
Read Internet Protocol version 6 (IPv6). Structure of IPv6 header [RFC 2460]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Version| Traffic Class | Flow Label | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Payload Length | Next Header | Hop Limit | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + + | | + Source Address + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + + | | + Destination Address + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 ip.version Version (6) 0 4 ip.class Traffic Class 1 12 ip.label Flow Label 4 32 ip.payload Payload Length (header excludes) 6 48 ip.next Next Header 7 56 ip.limit Hop Limit 8 64 ip.src Source Address 24 192 ip.dst Destination Address
3.904551
3.310102
1.179586
_htet = self._read_fileng(4).hex() _vers = _htet[0] # version number (6) _tcls = int(_htet[0:2], base=16) # traffic class _flow = int(_htet[2:], base=16) # flow label return (_vers, _tcls, _flow)
def _read_ip_hextet(self)
Read first four hextets of IPv6.
5.765831
4.686666
1.230263
hdr_len = 40 # header length raw_len = ipv6['payload'] # payload length _protos = list() # ProtoChain buffer # traverse if next header is an extensive header while proto in EXT_HDR: # keep original data after fragment header if proto.value == 44: ipv6['fragment'] = self._read_packet(header=hdr_len, payload=raw_len) # # directly break when No Next Header occurs # if proto.name == 'IPv6-NoNxt': # proto = None # break # make protocol name next_ = self._import_next_layer(proto, version=6, extension=True) info = next_.info name = next_.alias.lstrip('IPv6-').lower() ipv6[name] = info # record protocol name # self._protos = ProtoChain(name, chain, alias) _protos.append(next_) proto = info.next # pylint: disable=E1101 # update header & payload length hdr_len += info.length # pylint: disable=E1101 raw_len -= info.length # pylint: disable=E1101 # record real header & payload length (headers exclude) ipv6['hdr_len'] = hdr_len ipv6['raw_len'] = raw_len # update next header ipv6['protocol'] = proto return super()._decode_next_layer(ipv6, proto, raw_len, ipv6_exthdr=_protos)
def _decode_next_layer(self, ipv6, proto=None, length=None)
Decode next layer extractor. Positional arguments: * ipv6 -- dict, info buffer * proto -- str, next layer protocol name * length -- int, valid (not padding) length Returns: * dict -- current protocol with next layer extracted
6.500879
6.615775
0.982633
_byte = self._read_unpack(size) _prot = TP_PROTO.get(_byte) return _prot
def _read_protos(self, size)
Read next layer protocol type. Positional arguments: * size -- int, buffer size Returns: * str -- next layer's protocol name
12.660256
12.72099
0.995226
if self._onerror: next_ = beholder(self._import_next_layer)(self, proto, length, version=version) else: next_ = self._import_next_layer(proto, length, version=version) info, chain = next_.info, next_.protochain # make next layer protocol name layer = next_.alias.lower() # proto = next_.__class__.__name__ # write info and protocol chain into dict dict_[layer] = info self._next = next_ if ipv6_exthdr is not None: for proto in reversed(ipv6_exthdr): chain = ProtoChain(proto.__class__, proto.alias, basis=chain) self._protos = ProtoChain(self.__class__, self.alias, basis=chain) return dict_
def _decode_next_layer(self, dict_, proto=None, length=None, *, version=4, ipv6_exthdr=None)
Decode next layer extractor. Positional arguments: * dict_ -- dict, info buffer * proto -- str, next layer protocol name * length -- int, valid (not padding) length Keyword Arguments: * version -- int, IP version (4 in default) <keyword> 4 / 6 * ext_proto -- ProtoChain, ProtoChain of IPv6 extension headers Returns: * dict -- current protocol with next layer extracted
5.89928
5.57629
1.057922
if length == 0: from pcapkit.protocols.null import NoPayload as Protocol elif self._sigterm or proto == 59: from pcapkit.protocols.raw import Raw as Protocol elif proto == 51: from pcapkit.protocols.internet.ah import AH as Protocol elif proto == 139: from pcapkit.protocols.internet.hip import HIP as Protocol elif proto == 0: from pcapkit.protocols.internet.hopopt import HOPOPT as Protocol elif proto == 44: from pcapkit.protocols.internet.ipv6_frag import IPv6_Frag as Protocol elif proto == 60: from pcapkit.protocols.internet.ipv6_opts import IPv6_Opts as Protocol elif proto == 43: from pcapkit.protocols.internet.ipv6_route import IPv6_Route as Protocol elif proto == 135: from pcapkit.protocols.internet.mh import MH as Protocol elif proto == 4: from pcapkit.protocols.internet.ipv4 import IPv4 as Protocol elif proto == 41: from pcapkit.protocols.internet.ipv6 import IPv6 as Protocol elif proto == 6: from pcapkit.protocols.transport.tcp import TCP as Protocol elif proto == 17: from pcapkit.protocols.transport.udp import UDP as Protocol else: from pcapkit.protocols.raw import Raw as Protocol next_ = Protocol(self._file, length, version=version, extension=extension, error=self._onerror, layer=self._exlayer, protocol=self._exproto) return next_
def _import_next_layer(self, proto, length=None, *, version=4, extension=False)
Import next layer extractor. Positional arguments: * proto -- str, next layer protocol name * length -- int, valid (not padding) length Keyword Arguments: * version -- int, IP version (4 in default) <keyword> 4 / 6 * extension -- bool, if is extension header (False in default) <keyword> True / False Returns: * bool -- flag if extraction of next layer succeeded * Info -- info of next layer * ProtoChain -- protocol chain of next layer * str -- alias of next layer Protocols: * IPv4 -- internet layer * IPv6 -- internet layer * AH -- internet layer * TCP -- transport layer * UDP -- transport layer
2.397974
2.438436
0.983407
if length is None: length = len(self) _next = self._read_protos(1) _hlen = self._read_unpack(1) _type = self._read_binary(1) if _type[0] != '0': raise ProtocolError('HIP: invalid format') _vers = self._read_binary(1) if _vers[7] != '1': raise ProtocolError('HIP: invalid format') _csum = self._read_fileng(2) _ctrl = self._read_binary(2) _shit = self._read_unpack(16) _rhit = self._read_unpack(16) hip = dict( next=_next, length=(_hlen + 1) * 8, type=_HIP_TYPES.get(int(_type[1:], base=2), 'Unassigned'), version=int(_vers[:4], base=2), chksum=_csum, control=dict( anonymous=True if int(_ctrl[15], base=2) else False, ), shit=_shit, rhit=_rhit, ) _prml = _hlen - 38 if _prml: parameters = self._read_hip_para(_prml, version=hip['version']) hip['parameters'] = parameters[0] # tuple of parameter acronyms hip.update(parameters[1]) # merge parameters info to buffer length -= hip['length'] hip['packet'] = self._read_packet(header=hip['length'], payload=length) if extension: self._protos = None return hip return self._decode_next_layer(hip, _next, length)
def read_hip(self, length, extension)
Read Host Identity Protocol. Structure of HIP header [RFC 5201][RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Next Header | Header Length |0| Packet Type |Version| RES.|1| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Checksum | Controls | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sender's Host Identity Tag (HIT) | | | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Receiver's Host Identity Tag (HIT) | | | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | / HIP Parameters / / / | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 hip.next Next Header 1 8 hip.length Header Length 2 16 - Reserved (0) 2 17 hip.type Packet Type 3 24 hip.version Version 3 28 - Reserved 3 31 - Reserved (1) 4 32 hip.chksum Checksum 6 48 hip.control Controls 8 64 hip.shit Sender's Host Identity Tag 24 192 hip.rhit Receiver's Host Identity Tag 40 320 hip.parameters HIP Parameters
4.539284
3.634942
1.248791
counter = 0 # length of read parameters optkind = list() # parameter type list options = dict() # dict of parameter data while counter < length: # break when eol triggered kind = self._read_binary(2) if not kind: break # get parameter type & C-bit code = int(kind, base=2) cbit = True if int(kind[15], base=2) else False # get parameter length clen = self._read_unpack(2) plen = 11 + clen - (clen + 3) % 8 # extract parameter dscp = _HIP_PARA.get(code, 'Unassigned') # if 0 <= code <= 1023 or 61440 <= code <= 65535: # desc = f'{dscp} (IETF Review)' # elif 1024 <= code <= 32767 or 49152 <= code <= 61439: # desc = f'{dscp} (Specification Required)' # elif 32768 <= code <= 49151: # desc = f'{dscp} (Reserved for Private Use)' # else: # raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid parameter') data = _HIP_PROC(dscp)(self, code, cbit, clen, desc=dscp, length=plen, version=version) # record parameter data counter += plen if dscp in optkind: if isinstance(options[dscp], tuple): options[dscp] += (Info(data),) else: options[dscp] = (Info(options[dscp]), Info(data)) else: optkind.append(dscp) options[dscp] = data # check threshold if counter != length: raise ProtocolError(f'HIPv{version}: invalid format') return tuple(optkind), options
def _read_hip_para(self, length, *, version)
Read HIP parameters. Positional arguments: * length -- int, length of parameters Keyword arguments: * version -- int, HIP version Returns: * dict -- extracted HIP parameters
4.508835
4.48476
1.005368
unassigned = dict( type=desc, critical=cbit, length=clen, contents=self._read_fileng(clen), ) plen = length - clen if plen: self._read_fileng(plen) return unassigned
def _read_para_unassigned(self, code, cbit, clen, *, desc, length, version)
Read HIP unassigned parameters. Structure of HIP unassigned parameters [RFC 5201][RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type |C| Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | / Contents / / +-+-+-+-+-+-+-+-+ | | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 para.type Parameter Type 1 15 para.critical Critical Bit 2 16 para.length Length of Contents 4 32 para.contents Contents - - - Padding
4.96014
3.881894
1.277763
if clen != 12: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _resv = self._read_fileng(2) _kind = self._read_unpack(2) _olds = self._read_unpack(2) _news = self._read_unpack(2) esp_info = dict( type=desc, critical=cbit, length=clen, index=_kind, old_spi=_olds, new_spi=_news, ) return esp_info
def _read_para_esp_info(self, code, cbit, clen, *, desc, length, version)
Read HIP ESP_INFO parameter. Structure of HIP ESP_INFO parameter [RFC 7402]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved | KEYMAT Index | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OLD SPI | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | NEW SPI | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 esp_info.type Parameter Type 1 15 esp_info.critical Critical Bit 2 16 esp_info.length Length of Contents 4 32 - Reserved 6 48 esp_info.index KEYMAT Index 8 64 esp_info.old_spi OLD SPI 12 96 esp_info.new_spi NEW SPI
6.414338
4.278646
1.499152
if clen != 12: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') if code == 128 and version != 1: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid parameter') _resv = self._read_fileng(4) _genc = self._read_unpack(8) r1_counter = dict( type=desc, critical=cbit, length=clen, count=_genc, ) return r1_counter
def _read_para_r1_counter(self, code, cbit, clen, *, desc, length, version)
Read HIP R1_COUNTER parameter. Structure of HIP R1_COUNTER parameter [RFC 5201][RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved, 4 bytes | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | R1 generation counter, 8 bytes | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 ri_counter.type Parameter Type 1 15 ri_counter.critical Critical Bit 2 16 ri_counter.length Length of Contents 4 32 - Reserved 8 64 ri_counter.count Generation of Valid Puzzles
6.742385
5.044722
1.336523
def _read_locator(kind, size): if kind == 0 and size == 16: return ipaddress.ip_address(self._read_fileng(16)) elif kind == 1 and size == 20: return dict( spi=self._read_unpack(4), ip=ipaddress.ip_address(self._read_fileng(16)), ) else: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _size = 0 # length of read locators _locs = list() # list of locators while _size < clen: _traf = self._read_unpack(1) _loct = self._read_unpack(1) _locl = self._read_unpack(1) * 4 _resp = self._read_binary(1) _life = self._read_unpack(4) _lobj = _read_locator(_loct, _locl) _locs.append(Info( traffic=_traf, type=_loct, length=_locl, preferred=int(_resp[7], base=2), lifetime=_life, object=_lobj, )) locator_set = dict( type=desc, critical=cbit, length=clen, locator=tuple(_locs), ) return locator_set
def _read_para_locator_set(self, code, cbit, clen, *, desc, length, version)
Read HIP LOCATOR_SET parameter. Structure of HIP LOCATOR_SET parameter [RFC 8046]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Traffic Type | Locator Type | Locator Length | Reserved |P| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Locator Lifetime | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Locator | | | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ . . . . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Traffic Type | Locator Type | Locator Length | Reserved |P| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Locator Lifetime | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Locator | | | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 locator_set.type Parameter Type 1 15 locator_set.critical Critical Bit 2 16 locator_set.length Length of Contents 4 32 locator.traffic Traffic Type 5 40 locator.type Locator Type 6 48 locator.length Locator Length 7 56 - Reserved 7 63 locator.preferred Preferred Locator 8 64 locator.lifetime Locator Lifetime 12 96 locator.object Locator ............
4.520866
3.75155
1.205066
if version == 1 and clen != 12: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _numk = self._read_unpack(1) _time = self._read_unpack(1) _opak = self._read_fileng(2) _rand = self._read_unpack(clen-4) puzzle = dict( type=desc, critical=cbit, length=clen, number=_numk, lifetime=2 ** (_time - 32), opaque=_opak, random=_rand, ) _plen = length - clen if _plen: self._read_fileng(_plen) return puzzle
def _read_para_puzzle(self, code, cbit, clen, *, desc, length, version)
Read HIP PUZZLE parameter. Structure of HIP PUZZLE parameter [RFC 5201][RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | #K, 1 byte | Lifetime | Opaque, 2 bytes | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Random #I, RHASH_len / 8 bytes | / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 puzzle.type Parameter Type 1 15 puzzle.critical Critical Bit 2 16 puzzle.length Length of Contents 4 32 puzzle.number Number of Verified Bits 5 40 puzzle.lifetime Lifetime 6 48 puzzle.opaque Opaque 8 64 puzzle.random Random Number
5.972285
4.179821
1.428837
if clen != 4: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _upid = self._read_unpack(4) seq = dict( type=desc, critical=cbit, length=clen, id=_upid, ) return seq
def _read_para_seq(self, code, cbit, clen, *, desc, length, version)
Read HIP SEQ parameter. Structure of HIP SEQ parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Update ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 seq.type Parameter Type 1 15 seq.critical Critical Bit 2 16 seq.length Length of Contents 4 32 seq.id Update ID
12.143195
7.543375
1.609783
if clen % 4 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _upid = list() for _ in range(clen // 4): _upid.append(self._read_unpack(4)) ack = dict( type=desc, critical=cbit, length=clen, id=tuple(_upid), ) return ack
def _read_para_ack(self, code, cbit, clen, *, desc, length, version)
Read HIP ACK parameter. Structure of HIP ACK parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | peer Update ID 1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / peer Update ID n | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 ack.type Parameter Type 1 15 ack.critical Critical Bit 2 16 ack.length Length of Contents 4 32 ack.id Peer Update ID
6.782451
5.003679
1.355493
_dhid = list() for _ in range(clen): _dhid.append(_GROUP_ID.get(self._read_unpack(1), 'Unassigned')) dh_group_list = dict( type=desc, critical=cbit, length=clen, id=tuple(_dhid), ) _plen = length - clen if _plen: self._read_fileng(_plen) return dh_group_list
def _read_para_dh_group_list(self, code, cbit, clen, *, desc, length, version)
Read HIP DH_GROUP_LIST parameter. Structure of HIP DH_GROUP_LIST parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DH GROUP ID #1| DH GROUP ID #2| DH GROUP ID #3| DH GROUP ID #4| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DH GROUP ID #n| Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 dh_group_list.type Parameter Type 1 15 dh_group_list.critical Critical Bit 2 16 dh_group_list.length Length of Contents 4 32 dh_group_list.id DH GROUP ID
4.977359
4.059136
1.226211
_gpid = self._read_unpack(1) _vlen = self._read_unpack(2) _pval = self._read_fileng(_vlen) diffie_hellman = dict( type=desc, critical=cbit, length=clen, id=_GROUP_ID.get(_gpid, 'Unassigned'), pub_len=_vlen, pub_val=_pval, ) _plen = length - clen if _plen: self._read_fileng(_plen) return diffie_hellman
def _read_para_diffie_hellman(self, code, cbit, clen, *, desc, length, version)
Read HIP DIFFIE_HELLMAN parameter. Structure of HIP DIFFIE_HELLMAN parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Group ID | Public Value Length | Public Value / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 diffie_hellman.type Parameter Type 1 15 diffie_hellman.critical Critical Bit 2 16 diffie_hellman.length Length of Contents 4 32 diffie_hellman.id Group ID 5 40 diffie_hellman.pub_len Public Value Length 6 48 diffie_hellman.pub_val Public Value ? ? - Padding
4.768718
3.28159
1.453173
if version != 1: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid parameter') if clen % 2 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _stid = list() for _ in range(clen // 2): _stid.append(_SUITE_ID.get(self._read_unpack(2), 'Unassigned')) hip_transform = dict( type=desc, critical=cbit, length=clen, id=_stid, ) _plen = length - clen if _plen: self._read_fileng(_plen) return hip_transform
def _read_para_hip_transform(self, code, cbit, clen, *, desc, length, version)
Read HIP HIP_TRANSFORM parameter. Structure of HIP HIP_TRANSFORM parameter [RFC 5201]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Suite ID #1 | Suite ID #2 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Suite ID #n | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 hip_transform.type Parameter Type 1 15 hip_transform.critical Critical Bit 2 16 hip_transform.length Length of Contents 4 32 hip_transform.id Group ID ............ ? ? - Padding
5.145652
4.070499
1.264133
if clen % 2 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _cpid = list() for _ in range(clen // 2): _cpid.append(_CIPHER_ID.get(self._read_unpack(2), 'Unassigned')) hip_cipher = dict( type=desc, critical=cbit, length=clen, id=_cpid, ) _plen = length - clen if _plen: self._read_fileng(_plen) return hip_cipher
def _read_para_hip_cipher(self, code, cbit, clen, *, desc, length, version)
Read HIP HIP_CIPHER parameter. Structure of HIP HIP_CIPHER parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Cipher ID #1 | Cipher ID #2 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Cipher ID #n | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 hip_cipher.type Parameter Type 1 15 hip_cipher.critical Critical Bit 2 16 hip_cipher.length Length of Contents 4 32 hip_cipher.id Cipher ID ............ ? ? - Padding
6.087323
5.026024
1.211161
if clen % 2 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _resv = self._read_fileng(2) _mdid = list() for _ in range((clen - 2) // 2): _mdid.append(_MODE_ID.get(self._read_unpack(2), 'Unassigned')) nat_traversal_mode = dict( type=desc, critical=cbit, length=clen, id=_mdid, ) _plen = length - clen if _plen: self._read_fileng(_plen) return nat_traversal_mode
def _read_para_nat_traversal_mode(self, code, cbit, clen, *, desc, length, version)
Read HIP NAT_TRAVERSAL_MODE parameter. Structure of HIP NAT_TRAVERSAL_MODE parameter [RFC 5770]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved | Mode ID #1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Mode ID #2 | Mode ID #3 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Mode ID #n | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 nat_traversal_mode.type Parameter Type 1 15 nat_traversal_mode.critical Critical Bit 2 16 nat_traversal_mode.length Length of Contents 4 32 - Reserved 6 48 nat_traversal_mode.id Mode ID ............ ? ? - Padding
6.120308
5.130375
1.192955
if clen != 4: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _data = self._read_unpack(4) transaction_pacing = dict( type=desc, critical=cbit, length=clen, min_ta=_data, ) return transaction_pacing
def _read_para_transaction_pacing(self, code, cbit, clen, *, desc, length, version)
Read HIP TRANSACTION_PACING parameter. Structure of HIP TRANSACTION_PACING parameter [RFC 5770]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Min Ta | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 transaction_pacing.type Parameter Type 1 15 transaction_pacing.critical Critical Bit 2 16 transaction_pacing.length Length of Contents 4 32 transaction_pacing.min_ta Min Ta
10.035397
5.375309
1.866943
_resv = self._read_fileng(4) _data = self._read_fileng(clen-4) encrypted = dict( type=desc, critical=cbit, length=clen, raw=_data, ) _plen = length - clen if _plen: self._read_fileng(_plen) return encrypted
def _read_para_encrypted(self, code, cbit, clen, *, desc, length, version)
Read HIP ENCRYPTED parameter. Structure of HIP ENCRYPTED parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | IV / / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / Encrypted data / / / / +-------------------------------+ / | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 encrypted.type Parameter Type 1 15 encrypted.critical Critical Bit 2 16 encrypted.length Length of Contents 4 32 - Reserved 8 48 encrypted.iv Initialization Vector ? ? encrypted.data Encrypted data ? ? - Padding
5.014655
4.244836
1.181354
def _read_host_identifier(length, code): algorithm = _HI_ALGORITHM.get(code, 'Unassigned') if algorithm == 'ECDSA': host_id = dict( curve=_ECDSA_CURVE.get(self._read_unpack(2)), pubkey=self._read_fileng(length-2), ) elif algorithm == 'ECDSA_LOW': host_id = dict( curve=_ECDSA_LOW_CURVE.get(self._read_unpack(2)), pubkey=self._read_fileng(length-2), ) else: host_id = self._read_fileng(length) return algorithm, host_id def _read_domain_identifier(di_data): di_type = _DI_TYPE.get(int(di_data[:4], base=2), 'Unassigned') di_len = int(di_data[4:], base=2) domain_id = self._read_fileng(di_len) return di_type, di_len, domain_id _hlen = self._read_unpack(2) _didt = self._read_binary(2) _algo = self._read_unpack(2) _hidf = _read_host_identifier(_hlen, _algo) _didf = _read_domain_identifier(_didt) host_id = dict( type=desc, critical=cbit, length=clen, id_len=_hlen, di_type=_didf[0], di_len=_didf[1], algorithm=_hidf[0], host_id=_hidf[1], domain_id=_didf[2], ) _plen = length - clen if _plen: self._read_fileng(_plen) return host_id
def _read_para_host_id(self, code, cbit, clen, *, desc, length, version)
Read HIP HOST_ID parameter. Structure of HIP HOST_ID parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HI Length |DI-Type| DI Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Algorithm | Host Identity / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / | Domain Identifier / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 host_id.type Parameter Type 1 15 host_id.critical Critical Bit 2 16 host_id.length Length of Contents 4 32 host_id.id_len Host Identity Length 6 48 host_id.di_type Domain Identifier Type 6 52 host_id.di_len Domain Identifier Length 8 64 host_id.algorithm Algorithm 10 80 host_id.host_id Host Identity ? ? host_id.domain_id Domain Identifier ? ? - Padding
2.789326
2.332926
1.195634
_hsid = list() for _ in range(clen): _hsid.append(_HIT_SUITE_ID.get(self._read_unpack(1), 'Unassigned')) hit_suite_list = dict( type=desc, critical=cbit, length=clen, id=tuple(_hsid), ) _plen = length - clen if _plen: self._read_fileng(_plen) return hit_suite_list
def _read_para_hit_suite_list(self, code, cbit, clen, *, desc, length, version)
Read HIP HIT_SUITE_LIST parameter. Structure of HIP HIT_SUITE_LIST parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID #1 | ID #2 | ID #3 | ID #4 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID #n | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 hit_suite_list.type Parameter Type 1 15 hit_suite_list.critical Critical Bit 2 16 hit_suite_list.length Length of Contents 4 32 hit_suite_list.id HIT Suite ID ............ ? ? - Padding
5.074521
3.926154
1.292491
_ctgp = self._read_unpack(1) _ctct = self._read_unpack(1) _ctid = self._read_unpack(1) _cttp = self._read_unpack(1) _ctdt = self._read_fileng(clen-4) cert = dict( type=desc, critical=cbit, length=clen, group=_GROUP_ID.get(_ctgp, 'Unassigned'), count=_ctct, id=_ctid, cert_type=_CERT_TYPE.get(_cttp, 'Unassigned'), certificate=_ctdt, ) _plen = length - clen if _plen: self._read_fileng(_plen) return cert
def _read_para_cert(self, code, cbit, clen, *, desc, length, version)
Read HIP CERT parameter. Structure of HIP CERT parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CERT group | CERT count | CERT ID | CERT type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Certificate / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / | Padding (variable length) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 cert.type Parameter Type 1 15 cert.critical Critical Bit 2 16 cert.length Length of Contents 4 32 cert.group CERT Group 5 40 cert.count CERT Count 6 48 cert.id CERT ID 7 56 cert.cert_type CERT Type 8 64 cert.certificate Certificate ? ? - Padding
3.826371
2.923468
1.308847
_resv = self._read_fileng(2) _code = self._read_unpack(2) _data = self._read_fileng(2) _type = _NOTIFICATION_TYPE.get(_code) if _type is None: if 1 <= _code <= 50: _type = 'Unassigned (IETF Review)' elif 51 <= _code <= 8191: _type = 'Unassigned (Specification Required; Error Message)' elif 8192 <= _code <= 16383: _type = 'Unassigned (Reserved for Private Use; Error Message)' elif 16384 <= _code <= 40959: _type = 'Unassigned (Specification Required; Status Message)' elif 40960 <= _code <= 65535: _type = 'Unassigned (Reserved for Private Use; Status Message)' else: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') notification = dict( type=desc, critical=cbit, length=clen, msg_type=_type, data=_data, ) _plen = length - clen if _plen: self._read_fileng(_plen) return notification
def _read_para_notification(self, code, cbit, clen, *, desc, length, version)
Read HIP NOTIFICATION parameter. Structure of HIP NOTIFICATION parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved | Notify Message Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | / / Notification Data / / +---------------+ / | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 notification.type Parameter Type 1 15 notification.critical Critical Bit 2 16 notification.length Length of Contents 4 32 - Reserved 6 48 notification.msg_type Notify Message Type 8 64 notification.data Notification Data ? ? - Padding
3.616491
3.373756
1.071948
_data = self._read_fileng(clen) echo_request_signed = dict( type=desc, critical=cbit, length=clen, data=_data, ) _plen = length - clen if _plen: self._read_fileng(_plen) return echo_request_signed
def _read_para_echo_request_signed(self, code, cbit, clen, *, desc, length, version)
Read HIP ECHO_REQUEST_SIGNED parameter. Structure of HIP ECHO_REQUEST_SIGNED parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Opaque data (variable length) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 echo_request_signed.type Parameter Type 1 15 echo_request_signed.critical Critical Bit 2 16 echo_request_signed.length Length of Contents 4 32 echo_request_signed.data Opaque Data
3.992866
3.285066
1.21546
_life = collections.namedtuple('Lifetime', ('min', 'max')) _mint = self._read_unpack(1) _maxt = self._read_unpack(1) _type = list() for _ in range(clen-2): _code = self._read_unpack(1) _kind = _REG_FAILURE_TYPE.get(_code) if _kind is None: if 0 <= _code <= 200: _kind = 'Unassigned (IETF Review)' elif 201 <= _code <= 255: _kind = 'Unassigned (Reserved for Private Use)' else: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _type.append(_kind) reg_failed = dict( type=desc, critical=cbit, length=clen, lifetime=_life(_mint, _maxt), reg_type=tuple(_type), ) _plen = length - clen if _plen: self._read_fileng(_plen) return reg_failed
def _read_para_reg_failed(self, code, cbit, clen, *, desc, length, version)
Read HIP REG_FAILED parameter. Structure of HIP REG_FAILED parameter [RFC 8003]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Lifetime | Reg Type #1 | Reg Type #2 | Reg Type #3 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... | ... | Reg Type #n | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Padding + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 reg_failed.type Parameter Type 1 15 reg_failed.critical Critical Bit 2 16 reg_failed.length Length of Contents 4 32 reg_failed.lifetime Lifetime 4 32 reg_failed.lifetime.min Min Lifetime 5 40 reg_failed.lifetime.max Max Lifetime 6 48 reg_failed.reg_typetype Reg Type ........... ? ? - Padding
4.764068
3.927832
1.2129
if clen != 20: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _port = self._read_unpack(2) _ptcl = self._read_unpack(1) _resv = self._read_fileng(1) _addr = self._read_fileng(16) reg_from = dict( type=desc, critical=cbit, length=clen, port=_port, protocol=TP_PROTO.get(_ptcl), ip=ipaddress.ip_address(_addr), ) return reg_from
def _read_para_reg_from(self, code, cbit, clen, *, desc, length, version)
Read HIP REG_FROM parameter. Structure of HIP REG_FROM parameter [RFC 5770]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Port | Protocol | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | Address | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 reg_from.type Parameter Type 1 15 reg_from.critical Critical Bit 2 16 reg_from.length Length of Contents 4 32 reg_from.port Port 6 48 reg_from.protocol Protocol 7 56 - Reserved 8 64 reg_from.ip Address (IPv6)
6.469426
4.357806
1.48456
_data = self._read_fileng(clen) echo_response_signed = dict( type=desc, critical=cbit, length=clen, data=_data, ) _plen = length - clen if _plen: self._read_fileng(_plen) return echo_response_signed
def _read_para_echo_response_signed(self, code, cbit, clen, *, desc, length, version)
Read HIP ECHO_RESPONSE_SIGNED parameter. Structure of HIP ECHO_RESPONSE_SIGNED parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Opaque data (variable length) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 echo_response_signed.type Parameter Type 1 15 echo_response_signed.critical Critical Bit 2 16 echo_response_signed.length Length of Contents 4 32 echo_response_signed.data Opaque Data
3.960182
3.267492
1.211995
if clen % 2 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _tfid = list() for _ in range(clen // 2): _tfid.append(self._read_unpack(2)) transport_format_list = dict( type=desc, critical=cbit, length=clen, tf_type=tuple(_tfid), ) _plen = length - clen if _plen: self._read_fileng(_plen) return transport_format_list
def _read_para_transport_format_list(self, code, cbit, clen, *, desc, length, version)
Read HIP TRANSPORT_FORMAT_LIST parameter. Structure of HIP TRANSPORT_FORMAT_LIST parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TF type #1 | TF type #2 / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / TF type #n | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 transport_format_list.type Parameter Type 1 15 transport_format_list.critical Critical Bit 2 16 transport_format_list.length Length of Contents 4 32 transport_format_list.tf_type TF Type ............ ? ? - Padding
5.624038
4.266928
1.318053
if clen % 2 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _resv = self._read_fileng(2) _stid = list() for _ in range((clen - 2) // 2): _stid.append(_ESP_SUITE_ID.get(self._read_unpack(2), 'Unassigned')) esp_transform = dict( type=desc, critical=cbit, length=clen, id=tuple(_stid), ) _plen = length - clen if _plen: self._read_fileng(_plen) return esp_transform
def _read_para_esp_transform(self, code, cbit, clen, *, desc, length, version)
Read HIP ESP_TRANSFORM parameter. Structure of HIP ESP_TRANSFORM parameter [RFC 7402]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reserved | Suite ID #1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Suite ID #2 | Suite ID #3 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Suite ID #n | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 esp_transform.type Parameter Type 1 15 esp_transform.critical Critical Bit 2 16 esp_transform.length Length of Contents 4 32 - Reserved 6 48 esp_transform.id Suite ID ............ ? ? - Padding
6.35317
5.094151
1.24715
if clen != 4: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _seqn = self._read_unpack(4) seq_data = dict( type=desc, critical=cbit, length=clen, seq=_seqn, ) return seq_data
def _read_para_seq_data(self, code, cbit, clen, *, desc, length, version)
Read HIP SEQ_DATA parameter. Structure of HIP SEQ_DATA parameter [RFC 6078]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 seq_data.type Parameter Type 1 15 seq_data.critical Critical Bit 2 16 seq_data.length Length of Contents 4 32 seq_data.seq Sequence number
9.599232
6.478459
1.481715
if clen % 4 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _ackn = list() for _ in range(clen // 4): _ackn.append(self._read_unpack(4)) ack_data = dict( type=desc, critical=cbit, length=clen, ack=tuple(_ackn), ) return ack_data
def _read_para_ack_data(self, code, cbit, clen, *, desc, length, version)
Read HIP ACK_DATA parameter. Structure of HIP ACK_DATA parameter [RFC 6078]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Acked Sequence number / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 ack_data.type Parameter Type 1 15 ack_data.critical Critical Bit 2 16 ack_data.length Length of Contents 4 32 ack_data.ack Acked Sequence number
5.886178
4.728151
1.244922
_next = self._read_unpack(1) _resv = self._read_fileng(3) _data = self._read_fileng(4) _micv = self._read_fileng(clen-8) payload_mic = dict( type=desc, critical=cbit, length=clen, next=TP_PROTO.get(_next), data=_data, value=_micv, ) _plen = length - clen if _plen: self._read_fileng(_plen) return payload_mic
def _read_para_payload_mic(self, code, cbit, clen, *, desc, length, version)
Read HIP ACK_DATA parameter. Structure of HIP ACK_DATA parameter [RFC 6078]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Next Header | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Payload Data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | / MIC Value / / +-+-+-+-+-+-+-+-+ | | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 payload_mic.type Parameter Type 1 15 payload_mic.critical Critical Bit 2 16 payload_mic.length Length of Contents 4 32 payload_mic.next Next Header 5 40 - Reserved 8 64 payload_mic.data Payload Data 12 96 payload_mic.value MIC Value ? ? - Padding
4.6696
3.734748
1.250312
_tsid = self._read_unpack(clen) transaction_id = dict( type=desc, critical=cbit, length=clen, id=_tsid, ) _plen = length - clen if _plen: self._read_fileng(_plen) return transaction_id
def _read_para_transaction_id(self, code, cbit, clen, *, desc, length, version)
Read HIP TRANSACTION_ID parameter. Structure of HIP TRANSACTION_ID parameter [RFC 6078]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identifier / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 transaction_id.type Parameter Type 1 15 transaction_id.critical Critical Bit 2 16 transaction_id.length Length of Contents 4 32 transaction_id.id Identifier
5.257873
4.199193
1.252115
_olid = self._read_unpack(clen) overlay_id = dict( type=desc, critical=cbit, length=clen, id=_olid, ) _plen = length - clen if _plen: self._read_fileng(_plen) return overlay_id
def _read_para_overlay_id(self, code, cbit, clen, *, desc, length, version)
Read HIP TRANSACTION_ID parameter. Structure of HIP TRANSACTION_ID parameter [RFC 6079]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identifier / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 overlay_id.type Parameter Type 1 15 overlay_id.critical Critical Bit 2 16 overlay_id.length Length of Contents 4 32 overlay_id.id Identifier
5.158573
4.381285
1.177411
if (clen - 4) % 16 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _flag = self._read_binary(2) _resv = self._read_fileng(2) _addr = list() for _ in range((clen - 4) // 16): _addr.append(ipaddress.ip_address(self._read_fileng(16))) route_dst = dict( type=desc, critical=cbit, length=clen, flags=dict( symmetric=True if int(_flag[0], base=2) else False, must_follow=True if int(_flag[1], base=2) else False, ), ip=tuple(_addr), ) return route_dst
def _read_para_route_dst(self, code, cbit, clen, *, desc, length, version)
Read HIP ROUTE_DST parameter. Structure of HIP ROUTE_DST parameter [RFC 6028]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Flags | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | HIT #1 | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ . . . . . . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | HIT #n | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 route_dst.type Parameter Type 1 15 route_dst.critical Critical Bit 2 16 route_dst.length Length of Contents 4 32 route_dst.flags Flags 4 32 route_dst.flags.symmetric SYMMETRIC [RFC 6028] 4 33 route_dst.flags.must_follow MUST_FOLLOW [RFC 6028] 6 48 - Reserved 8 64 route_dst.ip HIT ............
4.456692
3.416002
1.304651
if clen % 2 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _port = self._read_unpack(2) _mdid = list() for _ in range((clen - 2) // 2): _mdid.append(_TP_MODE_ID.get(self._read_unpack(2), 'Unassigned')) hip_transport_mode = dict( type=desc, critical=cbit, length=clen, port=_port, id=tuple(_mdid), ) _plen = length - clen if _plen: self._read_fileng(_plen) return hip_transport_mode
def _read_para_hip_transport_mode(self, code, cbit, clen, *, desc, length, version)
Read HIP HIP_TRANSPORT_MODE parameter. Structure of HIP HIP_TRANSPORT_MODE parameter [RFC 6261]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Port | Mode ID #1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Mode ID #2 | Mode ID #3 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Mode ID #n | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 hip_transport_mode.type Parameter Type 1 15 hip_transport_mode.critical Critical Bit 2 16 hip_transport_mode.length Length of Contents 4 32 hip_transport_mode.port Port 6 48 hip_transport_mode.id Mode ID ............ ? ? - Padding
5.475774
4.378584
1.250581
_hmac = self._read_fileng(clen) hip_mac = dict( type=desc, critical=cbit, length=clen, hmac=_hmac, ) _plen = length - clen if _plen: self._read_fileng(_plen) return hip_mac
def _read_para_hip_mac(self, code, cbit, clen, *, desc, length, version)
Read HIP HIP_MAC parameter. Structure of HIP HIP_MAC parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | HMAC | / / / +-------------------------------+ | | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 hip_mac.type Parameter Type 1 15 hip_mac.critical Critical Bit 2 16 hip_mac.length Length of Contents 4 32 hip_mac.hmac HMAC ? ? - Padding
4.448202
3.425693
1.298482
_hmac = self._read_fileng(clen) hip_mac_2 = dict( type=desc, critical=cbit, length=clen, hmac=_hmac, ) _plen = length - clen if _plen: self._read_fileng(_plen) return hip_mac_2
def _read_para_hip_mac_2(self, code, cbit, clen, *, desc, length, version)
Read HIP HIP_MAC_2 parameter. Structure of HIP HIP_MAC_2 parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | HMAC | / / / +-------------------------------+ | | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 hip_mac_2.type Parameter Type 1 15 hip_mac_2.critical Critical Bit 2 16 hip_mac_2.length Length of Contents 4 32 hip_mac_2.hmac HMAC ? ? - Padding
4.122571
3.209229
1.284598
_algo = self._read_unpack(2) _sign = self._read_fileng(clen-2) hip_signature_2 = dict( type=desc, critical=cbit, length=clen, algorithm=_HI_ALGORITHM.get(_algo, 'Unassigned'), signature=_sign, ) _plen = length - clen if _plen: self._read_fileng(_plen) return hip_signature_2
def _read_para_hip_signature_2(self, code, cbit, clen, *, desc, length, version)
Read HIP HIP_SIGNATURE_2 parameter. Structure of HIP HIP_SIGNATURE_2 parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SIG alg | Signature / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 hip_signature_2.type Parameter Type 1 15 hip_signature_2.critical Critical Bit 2 16 hip_signature_2.length Length of Contents 4 32 hip_signature_2.algorithm SIG Algorithm 6 48 hip_signature_2.signature Signature ? ? - Padding
5.143594
3.985769
1.29049
_data = self._read_fileng(clen) echo_request_unsigned = dict( type=desc, critical=cbit, length=clen, data=_data, ) _plen = length - clen if _plen: self._read_fileng(_plen) return echo_request_unsigned
def _read_para_echo_request_unsigned(self, code, cbit, clen, *, desc, length, version)
Read HIP ECHO_REQUEST_UNSIGNED parameter. Structure of HIP ECHO_REQUEST_UNSIGNED parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Opaque data (variable length) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 echo_request_unsigned.type Parameter Type 1 15 echo_request_unsigned.critical Critical Bit 2 16 echo_request_unsigned.length Length of Contents 4 32 echo_request_unsigned.data Opaque Data
4.073941
3.324292
1.225506
_data = self._read_fileng(clen) echo_response_unsigned = dict( type=desc, critical=cbit, length=clen, data=_data, ) _plen = length - clen if _plen: self._read_fileng(_plen) return echo_response_unsigned
def _read_para_echo_response_unsigned(self, code, cbit, clen, *, desc, length, version)
Read HIP ECHO_RESPONSE_UNSIGNED parameter. Structure of HIP ECHO_RESPONSE_UNSIGNED parameter [RFC 7401]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Opaque data (variable length) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 echo_response_unsigned.type Parameter Type 1 15 echo_response_unsigned.critical Critical Bit 2 16 echo_response_unsigned.length Length of Contents 4 32 echo_response_unsigned.data Opaque Data
4.074225
3.280403
1.241989
if clen != 4: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _ttln = self._read_unpack(2) overlay_ttl = dict( type=desc, critical=cbit, length=clen, ttl=_ttln, ) return overlay_ttl
def _read_para_overlay_ttl(self, code, cbit, clen, *, desc, length, version)
Read HIP OVERLAY_TTL parameter. Structure of HIP OVERLAY_TTL parameter [RFC 6078]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TTL | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 overlay_ttl.type Parameter Type 1 15 overlay_ttl.critical Critical Bit 2 16 overlay_ttl.length Length of Contents 4 32 overlay_ttl.ttl TTL 6 48 - Reserved
8.589677
7.120255
1.206372
if clen != 16: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _addr = self._read_fileng(16) from_ = dict( type=desc, critical=cbit, length=clen, ip=ipaddress.ip_address(_addr), ) return from_
def _read_para_from(self, code, cbit, clen, *, desc, length, version)
Read HIP FROM parameter. Structure of HIP FROM parameter [RFC 8004]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | Address | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 from.type Parameter Type 1 15 from.critical Critical Bit 2 16 from.length Length of Contents 4 32 from.ip Address
9.673621
6.528733
1.4817
_hmac = self._read_fileng(clen) rvs_hmac = dict( type=desc, critical=cbit, length=clen, hmac=_hmac, ) _plen = length - clen if _plen: self._read_fileng(_plen) return rvs_hmac
def _read_para_rvs_hmac(self, code, cbit, clen, *, desc, length, version)
Read HIP RVS_HMAC parameter. Structure of HIP RVS_HMAC parameter [RFC 8004]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | HMAC | / / / +-------------------------------+ | | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 rvs_hmac.type Parameter Type 1 15 rvs_hmac.critical Critical Bit 2 16 rvs_hmac.length Length of Contents 4 32 rvs_hmac.hmac HMAC ? ? - Padding
4.277079
3.425964
1.248431
if clen % 16 != 0: raise ProtocolError(f'HIPv{version}: [Parano {code}] invalid format') _addr = list() for _ in range(clen // 16): _addr.append(ipaddress.ip_address(self._read_fileng(16))) via_rvs = dict( type=desc, critical=cbit, length=clen, ip=tuple(_addr), ) return via_rvs
def _read_para_via_rvs(self, code, cbit, clen, *, desc, length, version)
Read HIP VIA_RVS parameter. Structure of HIP VIA_RVS parameter [RFC 6028]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | Address | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ . . . . . . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | Address | | | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 via_rvs.type Parameter Type 1 15 via_rvs.critical Critical Bit 2 16 via_rvs.length Length of Contents 4 32 via_rvs.ip Address ............
6.595158
4.41546
1.493652
_hmac = self._read_fileng(clen) relay_hmac = dict( type=desc, critical=cbit, length=clen, hmac=_hmac, ) _plen = length - clen if _plen: self._read_fileng(_plen) return relay_hmac
def _read_para_relay_hmac(self, code, cbit, clen, *, desc, length, version)
Read HIP RELAY_HMAC parameter. Structure of HIP RELAY_HMAC parameter [RFC 5770]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | HMAC | / / / +-------------------------------+ | | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Octets Bits Name Description 0 0 relay_hmac.type Parameter Type 1 15 relay_hmac.critical Critical Bit 2 16 relay_hmac.length Length of Contents 4 32 relay_hmac.hmac HMAC ? ? - Padding
4.075726
3.369635
1.209545
pcapkit = f'{os.path.sep}pcapkit{os.path.sep}' tb = traceback.extract_stack() for index, tbitem in enumerate(tb): if pcapkit in tbitem[0]: break else: index = len(tb) return (index-1)
def stacklevel()
Fetch current stack level.
4.816233
4.532772
1.062536
if isinstance(key, int): return LinkType(key) if key not in LinkType._member_map_: extend_enum(LinkType, key, default) return LinkType[key]
def get(key, default=-1)
Backport support for original codes.
4.335323
3.851614
1.125586
@functools.wraps(func) def seekcur(self, *args, **kw): seek_cur = self._file.tell() self._file.seek(self._seekset, os.SEEK_SET) return_ = func(self, *args, **kw) self._file.seek(seek_cur, os.SEEK_SET) return return_ return seekcur
def seekset(func)
[ClassMethod] Read file from start then set back to original.
2.28481
2.299948
0.993418
@functools.wraps(func) def seekcur(file, *args, seekset=os.SEEK_SET, **kw): # seek_cur = file.tell() file.seek(seekset, os.SEEK_SET) return_ = func(file, *args, seekset=seekset, **kw) # file.seek(seek_cur, os.SEEK_SET) return return_ return seekcur
def seekset_ng(func)
Read file from start then set back to original.
2.627379
2.623126
1.001621
@functools.wraps(func) def behold(self, proto, length, *args, **kwargs): seek_cur = self._file.tell() try: return func(proto, length, *args, **kwargs) except Exception: from pcapkit.protocols.raw import Raw error = traceback.format_exc(limit=1).strip().split(os.linesep)[-1] # error = traceback.format_exc() self._file.seek(seek_cur, os.SEEK_SET) next_ = Raw(io.BytesIO(self._read_fileng(length)), length, error=error) return next_ return behold
def beholder(func)
[ClassMethod] Behold extraction procedure.
3.883914
3.968122
0.978779