id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1,200 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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 ... | python | def _read_para_reg_from(self, code, cbit, clen, *, desc, length, version):
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_f... | [
"def",
"_read_para_reg_from",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"if",
"clen",
"!=",
"20",
":",
"raise",
"ProtocolError",
"(",
"f'HIPv{version}: [Parano {code}] invalid format'",
... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HIP",
"REG_FROM",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1477-L1521 |
1,201 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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 ... | python | def _read_para_echo_response_signed(self, code, cbit, clen, *, desc, length, version):
_data = self._read_fileng(clen)
echo_response_signed = dict(
type=desc,
critical=cbit,
length=clen,
data=_data,
)
_plen = length - clen
if _ple... | [
"def",
"_read_para_echo_response_signed",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"_data",
"=",
"self",
".",
"_read_fileng",
"(",
"clen",
")",
"echo_response_signed",
"=",
"dict",
... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HIP",
"ECHO_RESPONSE_SIGNED",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1523-L1555 |
1,202 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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... | python | def _read_para_transport_format_list(self, code, cbit, clen, *, desc, length, version):
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... | [
"def",
"_read_para_transport_format_list",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"if",
"clen",
"%",
"2",
"!=",
"0",
":",
"raise",
"ProtocolError",
"(",
"f'HIPv{version}: [Parano ... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HIP",
"TRANSPORT_FORMAT_LIST",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1557-L1598 |
1,203 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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... | python | def _read_para_esp_transform(self, code, cbit, clen, *, desc, length, version):
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_... | [
"def",
"_read_para_esp_transform",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"if",
"clen",
"%",
"2",
"!=",
"0",
":",
"raise",
"ProtocolError",
"(",
"f'HIPv{version}: [Parano {code}] ... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HIP",
"ESP_TRANSFORM",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1600-L1645 |
1,204 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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 ... | python | def _read_para_seq_data(self, code, cbit, clen, *, desc, length, version):
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,
... | [
"def",
"_read_para_seq_data",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"if",
"clen",
"!=",
"4",
":",
"raise",
"ProtocolError",
"(",
"f'HIPv{version}: [Parano {code}] invalid format'",
... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HIP",
"SEQ_DATA",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1647-L1678 |
1,205 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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... | python | def _read_para_route_dst(self, code, cbit, clen, *, desc, length, version):
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 - ... | [
"def",
"_read_para_route_dst",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"if",
"(",
"clen",
"-",
"4",
")",
"%",
"16",
"!=",
"0",
":",
"raise",
"ProtocolError",
"(",
"f'HIPv{v... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HIP",
"ROUTE_DST",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1838-L1895 |
1,206 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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 ... | python | def _read_para_hip_transport_mode(self, code, cbit, clen, *, desc, length, version):
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(... | [
"def",
"_read_para_hip_transport_mode",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"if",
"clen",
"%",
"2",
"!=",
"0",
":",
"raise",
"ProtocolError",
"(",
"f'HIPv{version}: [Parano {co... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HIP",
"HIP_TRANSPORT_MODE",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1897-L1943 |
1,207 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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... | python | def _read_para_hip_mac(self, code, cbit, clen, *, desc, length, version):
_hmac = self._read_fileng(clen)
hip_mac = dict(
type=desc,
critical=cbit,
length=clen,
hmac=_hmac,
)
_plen = length - clen
if _plen:
self._read_... | [
"def",
"_read_para_hip_mac",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"_hmac",
"=",
"self",
".",
"_read_fileng",
"(",
"clen",
")",
"hip_mac",
"=",
"dict",
"(",
"type",
"=",
... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HIP",
"HIP_MAC",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1945-L1982 |
1,208 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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... | python | def _read_para_hip_mac_2(self, code, cbit, clen, *, desc, length, version):
_hmac = self._read_fileng(clen)
hip_mac_2 = dict(
type=desc,
critical=cbit,
length=clen,
hmac=_hmac,
)
_plen = length - clen
if _plen:
self._r... | [
"def",
"_read_para_hip_mac_2",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"_hmac",
"=",
"self",
".",
"_read_fileng",
"(",
"clen",
")",
"hip_mac_2",
"=",
"dict",
"(",
"type",
"="... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HIP",
"HIP_MAC_2",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1984-L2021 |
1,209 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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... | python | def _read_para_hip_signature_2(self, code, cbit, clen, *, desc, length, version):
_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, 'Una... | [
"def",
"_read_para_hip_signature_2",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"_algo",
"=",
"self",
".",
"_read_unpack",
"(",
"2",
")",
"_sign",
"=",
"self",
".",
"_read_fileng"... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HIP",
"HIP_SIGNATURE_2",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L2023-L2061 |
1,210 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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... | python | def _read_para_echo_request_unsigned(self, code, cbit, clen, *, desc, length, version):
_data = self._read_fileng(clen)
echo_request_unsigned = dict(
type=desc,
critical=cbit,
length=clen,
data=_data,
)
_plen = length - clen
if _p... | [
"def",
"_read_para_echo_request_unsigned",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"_data",
"=",
"self",
".",
"_read_fileng",
"(",
"clen",
")",
"echo_request_unsigned",
"=",
"dict"... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HIP",
"ECHO_REQUEST_UNSIGNED",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L2103-L2135 |
1,211 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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 ... | python | def _read_para_echo_response_unsigned(self, code, cbit, clen, *, desc, length, version):
_data = self._read_fileng(clen)
echo_response_unsigned = dict(
type=desc,
critical=cbit,
length=clen,
data=_data,
)
_plen = length - clen
if ... | [
"def",
"_read_para_echo_response_unsigned",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"_data",
"=",
"self",
".",
"_read_fileng",
"(",
"clen",
")",
"echo_response_unsigned",
"=",
"dic... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HIP",
"ECHO_RESPONSE_UNSIGNED",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L2137-L2169 |
1,212 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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... | python | def _read_para_overlay_ttl(self, code, cbit, clen, *, desc, length, version):
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=cl... | [
"def",
"_read_para_overlay_ttl",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"if",
"clen",
"!=",
"4",
":",
"raise",
"ProtocolError",
"(",
"f'HIPv{version}: [Parano {code}] invalid format'"... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HIP",
"OVERLAY_TTL",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L2263-L2295 |
1,213 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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
... | python | def _read_para_from(self, code, cbit, clen, *, desc, length, version):
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,
... | [
"def",
"_read_para_from",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"if",
"clen",
"!=",
"16",
":",
"raise",
"ProtocolError",
"(",
"f'HIPv{version}: [Parano {code}] invalid format'",
")... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HIP",
"FROM",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L2356-L2390 |
1,214 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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 ... | python | def _read_para_rvs_hmac(self, code, cbit, clen, *, desc, length, version):
_hmac = self._read_fileng(clen)
rvs_hmac = dict(
type=desc,
critical=cbit,
length=clen,
hmac=_hmac,
)
_plen = length - clen
if _plen:
self._rea... | [
"def",
"_read_para_rvs_hmac",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"_hmac",
"=",
"self",
".",
"_read_fileng",
"(",
"clen",
")",
"rvs_hmac",
"=",
"dict",
"(",
"type",
"=",
... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HIP",
"RVS_HMAC",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L2392-L2427 |
1,215 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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... | python | def _read_para_via_rvs(self, code, cbit, clen, *, desc, length, version):
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)))
... | [
"def",
"_read_para_via_rvs",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"if",
"clen",
"%",
"16",
"!=",
"0",
":",
"raise",
"ProtocolError",
"(",
"f'HIPv{version}: [Parano {code}] inval... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HIP",
"VIA_RVS",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L2429-L2474 |
1,216 | JarryShaw/PyPCAPKit | src/protocols/internet/hip.py | HIP._read_para_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 ... | python | def _read_para_relay_hmac(self, code, cbit, clen, *, desc, length, version):
_hmac = self._read_fileng(clen)
relay_hmac = dict(
type=desc,
critical=cbit,
length=clen,
hmac=_hmac,
)
_plen = length - clen
if _plen:
self.... | [
"def",
"_read_para_relay_hmac",
"(",
"self",
",",
"code",
",",
"cbit",
",",
"clen",
",",
"*",
",",
"desc",
",",
"length",
",",
"version",
")",
":",
"_hmac",
"=",
"self",
".",
"_read_fileng",
"(",
"clen",
")",
"relay_hmac",
"=",
"dict",
"(",
"type",
"... | 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HIP",
"RELAY_HMAC",
"parameter",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L2476-L2511 |
1,217 | JarryShaw/PyPCAPKit | src/utilities/exceptions.py | stacklevel | def stacklevel():
"""Fetch current stack level."""
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) | python | def stacklevel():
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",
"(",
")",
":",
"pcapkit",
"=",
"f'{os.path.sep}pcapkit{os.path.sep}'",
"tb",
"=",
"traceback",
".",
"extract_stack",
"(",
")",
"for",
"index",
",",
"tbitem",
"in",
"enumerate",
"(",
"tb",
")",
":",
"if",
"pcapkit",
"in",
"tbitem",
"[",
... | Fetch current stack level. | [
"Fetch",
"current",
"stack",
"level",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/utilities/exceptions.py#L46-L55 |
1,218 | JarryShaw/PyPCAPKit | src/utilities/decorators.py | seekset_ng | def seekset_ng(func):
"""Read file from start then set back to original."""
@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... | python | def seekset_ng(func):
@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 seekc... | [
"def",
"seekset_ng",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"seekcur",
"(",
"file",
",",
"*",
"args",
",",
"seekset",
"=",
"os",
".",
"SEEK_SET",
",",
"*",
"*",
"kw",
")",
":",
"# seek_cur = file.tell()",
"fil... | Read file from start then set back to original. | [
"Read",
"file",
"from",
"start",
"then",
"set",
"back",
"to",
"original",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/utilities/decorators.py#L33-L42 |
1,219 | JarryShaw/PyPCAPKit | src/utilities/decorators.py | beholder_ng | def beholder_ng(func):
"""Behold analysis procedure."""
@functools.wraps(func)
def behold(file, length, *args, **kwargs):
seek_cur = file.tell()
try:
return func(file, length, *args, **kwargs)
except Exception:
# from pcapkit.foundation.analysis import analyse... | python | def beholder_ng(func):
@functools.wraps(func)
def behold(file, length, *args, **kwargs):
seek_cur = file.tell()
try:
return func(file, length, *args, **kwargs)
except Exception:
# from pcapkit.foundation.analysis import analyse
from pcapkit.protocols.r... | [
"def",
"beholder_ng",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"behold",
"(",
"file",
",",
"length",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"seek_cur",
"=",
"file",
".",
"tell",
"(",
")",
"try"... | Behold analysis procedure. | [
"Behold",
"analysis",
"procedure",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/utilities/decorators.py#L63-L82 |
1,220 | JarryShaw/PyPCAPKit | src/protocols/link/l2tp.py | L2TP.read_l2tp | def read_l2tp(self, length):
"""Read Layer Two Tunnelling Protocol.
Structure of L2TP header [RFC 2661]:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | python | def read_l2tp(self, length):
if length is None:
length = len(self)
_flag = self._read_binary(1)
_vers = self._read_fileng(1).hex()[1]
_hlen = self._read_unpack(2) if int(_flag[1]) else None
_tnnl = self._read_unpack(2)
_sssn = self._read_unpack(2)
_ns... | [
"def",
"read_l2tp",
"(",
"self",
",",
"length",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"len",
"(",
"self",
")",
"_flag",
"=",
"self",
".",
"_read_binary",
"(",
"1",
")",
"_vers",
"=",
"self",
".",
"_read_fileng",
"(",
"1",
")",... | Read Layer Two Tunnelling Protocol.
Structure of L2TP header [RFC 2661]:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"Layer",
"Two",
"Tunnelling",
"Protocol",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/link/l2tp.py#L84-L156 |
1,221 | JarryShaw/PyPCAPKit | src/protocols/link/vlan.py | VLAN.read_vlan | def read_vlan(self, length):
"""Read 802.1Q Customer VLAN Tag Type.
Structure of 802.1Q Customer VLAN Tag Type [RFC 7042]:
Octets Bits Name Description
1 0 vlan.tci Tag Control Information
1 0 ... | python | def read_vlan(self, length):
if length is None:
length = len(self)
_tcif = self._read_binary(2)
_type = self._read_protos(2)
vlan = dict(
tci=dict(
pcp=_PCP.get(int(_tcif[:3], base=2)),
dei=True if _tcif[3] else False,
... | [
"def",
"read_vlan",
"(",
"self",
",",
"length",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"len",
"(",
"self",
")",
"_tcif",
"=",
"self",
".",
"_read_binary",
"(",
"2",
")",
"_type",
"=",
"self",
".",
"_read_protos",
"(",
"2",
")",... | Read 802.1Q Customer VLAN Tag Type.
Structure of 802.1Q Customer VLAN Tag Type [RFC 7042]:
Octets Bits Name Description
1 0 vlan.tci Tag Control Information
1 0 vlan.tci.pcp Priority Cod... | [
"Read",
"802",
".",
"1Q",
"Customer",
"VLAN",
"Tag",
"Type",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/link/vlan.py#L83-L113 |
1,222 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_tcp_options | def _read_tcp_options(self, size):
"""Read TCP option list.
Positional arguments:
* size -- int, length of option list
Returns:
* tuple -- TCP option list
* dict -- extracted TCP option
"""
counter = 0 # length of read option list
... | python | def _read_tcp_options(self, size):
counter = 0 # length of read option list
optkind = list() # option kind list
options = dict() # dict of option data
while counter < size:
# get option kind
kind = self._read_unpack(1)
# fetch correspon... | [
"def",
"_read_tcp_options",
"(",
"self",
",",
"size",
")",
":",
"counter",
"=",
"0",
"# length of read option list",
"optkind",
"=",
"list",
"(",
")",
"# option kind list",
"options",
"=",
"dict",
"(",
")",
"# dict of option data",
"while",
"counter",
"<",
"size... | Read TCP option list.
Positional arguments:
* size -- int, length of option list
Returns:
* tuple -- TCP option list
* dict -- extracted TCP option | [
"Read",
"TCP",
"option",
"list",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L345-L414 |
1,223 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mode_tsopt | def _read_mode_tsopt(self, size, kind):
"""Read Timestamps option.
Positional arguments:
* size - int, length of option
* kind - int, 8 (Timestamps)
Returns:
* dict -- extracted Timestamps (TS) option
Structure of TCP TSopt [RFC 7323]:
+... | python | def _read_mode_tsopt(self, size, kind):
temp = struct.unpack('>II', self._read_fileng(size))
data = dict(
kind=kind,
length=size,
val=temp[0],
ecr=temp[1],
)
return data | [
"def",
"_read_mode_tsopt",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"temp",
"=",
"struct",
".",
"unpack",
"(",
"'>II'",
",",
"self",
".",
"_read_fileng",
"(",
"size",
")",
")",
"data",
"=",
"dict",
"(",
"kind",
"=",
"kind",
",",
"length",
"... | Read Timestamps option.
Positional arguments:
* size - int, length of option
* kind - int, 8 (Timestamps)
Returns:
* dict -- extracted Timestamps (TS) option
Structure of TCP TSopt [RFC 7323]:
+-------+-------+---------------------+-------------... | [
"Read",
"Timestamps",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L464-L494 |
1,224 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mode_pocsp | def _read_mode_pocsp(self, size, kind):
"""Read Partial Order Connection Service Profile option.
Positional arguments:
* size - int, length of option
* kind - int, 10 (POC-Serv Profile)
Returns:
* dict -- extracted Partial Order Connection Service Profile (P... | python | def _read_mode_pocsp(self, size, kind):
temp = self._read_binary(size)
data = dict(
kind=kind,
length=size,
start=True if int(temp[0]) else False,
end=True if int(temp[1]) else False,
filler=bytes(chr(int(temp[2:], base=2)), encoding='utf-8'),... | [
"def",
"_read_mode_pocsp",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"temp",
"=",
"self",
".",
"_read_binary",
"(",
"size",
")",
"data",
"=",
"dict",
"(",
"kind",
"=",
"kind",
",",
"length",
"=",
"size",
",",
"start",
"=",
"True",
"if",
"int... | Read Partial Order Connection Service Profile option.
Positional arguments:
* size - int, length of option
* kind - int, 10 (POC-Serv Profile)
Returns:
* dict -- extracted Partial Order Connection Service Profile (POC-SP) option
Structure of TCP POC-SP Opti... | [
"Read",
"Partial",
"Order",
"Connection",
"Service",
"Profile",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L496-L530 |
1,225 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mode_acopt | def _read_mode_acopt(self, size, kind):
"""Read Alternate Checksum Request option.
Positional arguments:
size - int, length of option
kind - int, 14 (Alt-Chksum Request)
Returns:
* dict -- extracted Alternate Checksum Request (CHKSUM-REQ) option
Str... | python | def _read_mode_acopt(self, size, kind):
temp = self._read_unpack(size)
algo = chksum_opt.get(temp)
data = dict(
kind=kind,
length=size,
ac=algo,
)
return data | [
"def",
"_read_mode_acopt",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"temp",
"=",
"self",
".",
"_read_unpack",
"(",
"size",
")",
"algo",
"=",
"chksum_opt",
".",
"get",
"(",
"temp",
")",
"data",
"=",
"dict",
"(",
"kind",
"=",
"kind",
",",
"le... | Read Alternate Checksum Request option.
Positional arguments:
size - int, length of option
kind - int, 14 (Alt-Chksum Request)
Returns:
* dict -- extracted Alternate Checksum Request (CHKSUM-REQ) option
Structure of TCP CHKSUM-REQ [RFC 1146][RFC 6247]:
... | [
"Read",
"Alternate",
"Checksum",
"Request",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L532-L562 |
1,226 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mode_qsopt | def _read_mode_qsopt(self, size, kind):
"""Read Quick-Start Response option.
Positional arguments:
* size - int, length of option
* kind - int, 27 (Quick-Start Response)
Returns:
* dict -- extracted Quick-Start Response (QS) option
Structure of TCP ... | python | def _read_mode_qsopt(self, size, kind):
rvrr = self._read_binary(1)
ttld = self._read_unpack(1)
noun = self._read_fileng(4)
data = dict(
kind=kind,
length=size,
req_rate=int(rvrr[4:], base=2),
ttl_diff=ttld,
nounce=noun[:-2],
... | [
"def",
"_read_mode_qsopt",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"rvrr",
"=",
"self",
".",
"_read_binary",
"(",
"1",
")",
"ttld",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"noun",
"=",
"self",
".",
"_read_fileng",
"(",
"4",
")",
"... | Read Quick-Start Response option.
Positional arguments:
* size - int, length of option
* kind - int, 27 (Quick-Start Response)
Returns:
* dict -- extracted Quick-Start Response (QS) option
Structure of TCP QSopt [RFC 4782]:
0 ... | [
"Read",
"Quick",
"-",
"Start",
"Response",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L564-L606 |
1,227 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mode_utopt | def _read_mode_utopt(self, size, kind):
"""Read User Timeout option.
Positional arguments:
* size - int, length of option
* kind - int, 28 (User Timeout Option)
Returns:
* dict -- extracted User Timeout (TIMEOUT) option
Structure of TCP TIMEOUT [RFC... | python | def _read_mode_utopt(self, size, kind):
temp = self._read_fileng(size)
data = dict(
kind=kind,
length=size,
granularity='minutes' if int(temp[0]) else 'seconds',
timeout=bytes(chr(int(temp[0:], base=2)), encoding='utf-8'),
)
return data | [
"def",
"_read_mode_utopt",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"temp",
"=",
"self",
".",
"_read_fileng",
"(",
"size",
")",
"data",
"=",
"dict",
"(",
"kind",
"=",
"kind",
",",
"length",
"=",
"size",
",",
"granularity",
"=",
"'minutes'",
"... | Read User Timeout option.
Positional arguments:
* size - int, length of option
* kind - int, 28 (User Timeout Option)
Returns:
* dict -- extracted User Timeout (TIMEOUT) option
Structure of TCP TIMEOUT [RFC 5482]:
0 1 ... | [
"Read",
"User",
"Timeout",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L608-L641 |
1,228 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mode_tcpao | def _read_mode_tcpao(self, size, kind):
"""Read Authentication option.
Positional arguments:
* size - int, length of option
* kind - int, 29 (TCP Authentication Option)
Returns:
* dict -- extracted Authentication (AO) option
Structure of TCP AOopt [... | python | def _read_mode_tcpao(self, size, kind):
key_ = self._read_unpack(1)
rkey = self._read_unpack(1)
mac_ = self._read_fileng(size - 2)
data = dict(
kind=kind,
length=size,
keyid=key_,
rnextkeyid=rkey,
mac=mac_,
)
r... | [
"def",
"_read_mode_tcpao",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"key_",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"rkey",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"mac_",
"=",
"self",
".",
"_read_fileng",
"(",
"size",
"-",
... | Read Authentication option.
Positional arguments:
* size - int, length of option
* kind - int, 29 (TCP Authentication Option)
Returns:
* dict -- extracted Authentication (AO) option
Structure of TCP AOopt [RFC 5925]:
+------------+------------+-... | [
"Read",
"Authentication",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L643-L684 |
1,229 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mode_mptcp | def _read_mode_mptcp(self, size, kind):
"""Read Multipath TCP option.
Positional arguments:
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Multipath TCP (MP-TCP) option
Structure of MP-TCP [RFC 6824]:
... | python | def _read_mode_mptcp(self, size, kind):
bins = self._read_binary(1)
subt = int(bins[:4], base=2) # subtype number
bits = bins[4:] # 4-bit data
dlen = size - 1 # length of remaining data
# fetch subtype-specific data
func = mptcp_opt.get... | [
"def",
"_read_mode_mptcp",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"bins",
"=",
"self",
".",
"_read_binary",
"(",
"1",
")",
"subt",
"=",
"int",
"(",
"bins",
"[",
":",
"4",
"]",
",",
"base",
"=",
"2",
")",
"# subtype number",
"bits",
"=",
... | Read Multipath TCP option.
Positional arguments:
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Multipath TCP (MP-TCP) option
Structure of MP-TCP [RFC 6824]:
1 ... | [
"Read",
"Multipath",
"TCP",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L686-L730 |
1,230 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mptcp_capable | def _read_mptcp_capable(self, bits, size, kind):
"""Read Multipath Capable option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Multipath Capable (MP_C... | python | def _read_mptcp_capable(self, bits, size, kind):
vers = int(bits, base=2)
bins = self._read_binary(1)
skey = self._read_fileng(8)
rkey = self._read_fileng(8) if size == 17 else None
data = dict(
kind=kind,
length=size + 1,
subtype='MP_CAPABLE'... | [
"def",
"_read_mptcp_capable",
"(",
"self",
",",
"bits",
",",
"size",
",",
"kind",
")",
":",
"vers",
"=",
"int",
"(",
"bits",
",",
"base",
"=",
"2",
")",
"bins",
"=",
"self",
".",
"_read_binary",
"(",
"1",
")",
"skey",
"=",
"self",
".",
"_read_filen... | Read Multipath Capable option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Multipath Capable (MP_CAPABLE) option
Structure of MP_CAPABLE [RFC 6824]:
... | [
"Read",
"Multipath",
"Capable",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L732-L794 |
1,231 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mptcp_join | def _read_mptcp_join(self, bits, size, kind):
"""Read Join Connection option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Join Connection (MP_JOIN) op... | python | def _read_mptcp_join(self, bits, size, kind):
if self._syn and self._ack: # MP_JOIN-SYN/ACK
return self._read_join_synack(bits, size, kind)
elif self._syn: # MP_JOIN-SYN
return self._read_join_syn(bits, size, kind)
elif self._ack: # MP_... | [
"def",
"_read_mptcp_join",
"(",
"self",
",",
"bits",
",",
"size",
",",
"kind",
")",
":",
"if",
"self",
".",
"_syn",
"and",
"self",
".",
"_ack",
":",
"# MP_JOIN-SYN/ACK",
"return",
"self",
".",
"_read_join_synack",
"(",
"bits",
",",
"size",
",",
"kind",
... | Read Join Connection option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Join Connection (MP_JOIN) option
Structure of MP_JOIN [RFC 6824]:
... | [
"Read",
"Join",
"Connection",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L796-L829 |
1,232 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_join_syn | def _read_join_syn(self, bits, size, kind):
"""Read Join Connection option for Initial SYN.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Join Connectio... | python | def _read_join_syn(self, bits, size, kind):
adid = self._read_unpack(1)
rtkn = self._read_fileng(4)
srno = self._read_unpack(4)
data = dict(
kind=kind,
length=size + 1,
subtype='MP_JOIN-SYN',
join=dict(
syn=dict(
... | [
"def",
"_read_join_syn",
"(",
"self",
",",
"bits",
",",
"size",
",",
"kind",
")",
":",
"adid",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"rtkn",
"=",
"self",
".",
"_read_fileng",
"(",
"4",
")",
"srno",
"=",
"self",
".",
"_read_unpack",
"(",
... | Read Join Connection option for Initial SYN.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Join Connection (MP_JOIN-SYN) option for Initial SYN
Structu... | [
"Read",
"Join",
"Connection",
"option",
"for",
"Initial",
"SYN",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L831-L882 |
1,233 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_join_ack | def _read_join_ack(self, bits, size, kind):
"""Read Join Connection option for Third ACK.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Join Connection ... | python | def _read_join_ack(self, bits, size, kind):
temp = self._read_fileng(20)
data = dict(
kind=kind,
length=size + 1,
subtype='MP_JOIN-ACK',
join=dict(
ack=dict(
hmac=temp,
),
),
)
... | [
"def",
"_read_join_ack",
"(",
"self",
",",
"bits",
",",
"size",
",",
"kind",
")",
":",
"temp",
"=",
"self",
".",
"_read_fileng",
"(",
"20",
")",
"data",
"=",
"dict",
"(",
"kind",
"=",
"kind",
",",
"length",
"=",
"size",
"+",
"1",
",",
"subtype",
... | Read Join Connection option for Third ACK.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Join Connection (MP_JOIN-ACK) option for Third ACK
Structure o... | [
"Read",
"Join",
"Connection",
"option",
"for",
"Third",
"ACK",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L939-L984 |
1,234 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mptcp_add | def _read_mptcp_add(self, bits, size, kind):
"""Read Add Address option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Add Address (ADD_ADDR) option
... | python | def _read_mptcp_add(self, bits, size, kind):
vers = int(bits, base=2)
adid = self._read_unpack(1)
ipad = self._read_fileng(4) if vers == 4 else self._read_fileng(16)
ip_l = 4 if vers == 4 else 16
pt_l = size - 1 - ip_l
port = self._read_unpack(2) if pt_l else None
... | [
"def",
"_read_mptcp_add",
"(",
"self",
",",
"bits",
",",
"size",
",",
"kind",
")",
":",
"vers",
"=",
"int",
"(",
"bits",
",",
"base",
"=",
"2",
")",
"adid",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"ipad",
"=",
"self",
".",
"_read_fileng",
... | Read Add Address option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
* kind - int, 30 (Multipath TCP)
Returns:
* dict -- extracted Add Address (ADD_ADDR) option
Structure of ADD_ADDR [RFC 6824]:
... | [
"Read",
"Add",
"Address",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L1074-L1125 |
1,235 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mptcp_remove | def _read_mptcp_remove(self, bits, size):
"""Read Remove Address option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
Returns:
* dict -- extracted Remove Address (REMOVE_ADDR) option
Structure of REMOVE_ADDR [RFC 682... | python | def _read_mptcp_remove(self, bits, size):
adid = []
for _ in size:
adid.append(self._read_unpack(1))
data = dict(
subtype='REMOVE_ADDR',
removeaddr=dict(
addrid=adid or None,
),
)
return data | [
"def",
"_read_mptcp_remove",
"(",
"self",
",",
"bits",
",",
"size",
")",
":",
"adid",
"=",
"[",
"]",
"for",
"_",
"in",
"size",
":",
"adid",
".",
"append",
"(",
"self",
".",
"_read_unpack",
"(",
"1",
")",
")",
"data",
"=",
"dict",
"(",
"subtype",
... | Read Remove Address option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
Returns:
* dict -- extracted Remove Address (REMOVE_ADDR) option
Structure of REMOVE_ADDR [RFC 6824]:
1 ... | [
"Read",
"Remove",
"Address",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L1173-L1210 |
1,236 | JarryShaw/PyPCAPKit | src/protocols/transport/tcp.py | TCP._read_mptcp_prio | def _read_mptcp_prio(self, bits, size):
"""Read Change Subflow Priority option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
Returns:
* dict -- extracted Change Subflow Priority (MP_PRIO) option
Structure of MP_PRIO ... | python | def _read_mptcp_prio(self, bits, size):
temp = self._read_unpack(1) if size else None
data = dict(
subtype='MP_PRIO',
prio=dict(
res=b'\x00' * 3,
backup=True if int(bits[3]) else False,
addrid=temp,
),
)
... | [
"def",
"_read_mptcp_prio",
"(",
"self",
",",
"bits",
",",
"size",
")",
":",
"temp",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"size",
"else",
"None",
"data",
"=",
"dict",
"(",
"subtype",
"=",
"'MP_PRIO'",
",",
"prio",
"=",
"dict",
"(",
... | Read Change Subflow Priority option.
Positional arguments:
* bits - str, 4-bit data
* size - int, length of option
Returns:
* dict -- extracted Change Subflow Priority (MP_PRIO) option
Structure of MP_PRIO [RFC 6824]:
1 ... | [
"Read",
"Change",
"Subflow",
"Priority",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/transport/tcp.py#L1212-L1248 |
1,237 | JarryShaw/PyPCAPKit | src/interface/__init__.py | extract | def extract(fin=None, fout=None, format=None, # basic settings
auto=True, extension=True, store=True, # internal settings
files=False, nofile=False, verbose=False, # output settings
engine=None, layer=None, protocol=Non... | python | def extract(fin=None, fout=None, format=None, # basic settings
auto=True, extension=True, store=True, # internal settings
files=False, nofile=False, verbose=False, # output settings
engine=None, layer=None, protocol=Non... | [
"def",
"extract",
"(",
"fin",
"=",
"None",
",",
"fout",
"=",
"None",
",",
"format",
"=",
"None",
",",
"# basic settings",
"auto",
"=",
"True",
",",
"extension",
"=",
"True",
",",
"store",
"=",
"True",
",",
"# internal settings",
"files",
"=",
"False",
... | Extract a PCAP file.
Keyword arguments:
* fin -- str, file name to be read; if file not exist, raise an error
* fout -- str, file name to be written
* format -- str, file format of output
<keyword> 'plist' / 'json' / 'tree' / 'html'
* auto -- bool, if auto... | [
"Extract",
"a",
"PCAP",
"file",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/interface/__init__.py#L53-L131 |
1,238 | JarryShaw/PyPCAPKit | src/interface/__init__.py | reassemble | def reassemble(protocol, strict=False):
"""Reassemble fragmented datagrams.
Keyword arguments:
* protocol -- str, protocol to be reassembled
* strict -- bool, if return all datagrams (including those not implemented) when submit (default is False)
<keyword> True / False
... | python | def reassemble(protocol, strict=False):
if isinstance(protocol, type) and issubclass(protocol, Protocol):
protocol = protocol.__index__()
str_check(protocol)
bool_check(strict)
if protocol == 'IPv4':
return IPv4_Reassembly(strict=strict)
elif protocol == 'IPv6':
return IPv6... | [
"def",
"reassemble",
"(",
"protocol",
",",
"strict",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"protocol",
",",
"type",
")",
"and",
"issubclass",
"(",
"protocol",
",",
"Protocol",
")",
":",
"protocol",
"=",
"protocol",
".",
"__index__",
"(",
")",
... | Reassemble fragmented datagrams.
Keyword arguments:
* protocol -- str, protocol to be reassembled
* strict -- bool, if return all datagrams (including those not implemented) when submit (default is False)
<keyword> True / False
Returns:
* [if protocol is IPv4] I... | [
"Reassemble",
"fragmented",
"datagrams",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/interface/__init__.py#L154-L181 |
1,239 | JarryShaw/PyPCAPKit | src/interface/__init__.py | trace | def trace(fout=None, format=None, byteorder=sys.byteorder, nanosecond=False):
"""Trace TCP flows.
Keyword arguments:
* fout -- str, output path
* format -- str, output format
* byteorder -- str, output file byte order
* nanosecond -- bool, output nanosecond-resolution file flag
... | python | def trace(fout=None, format=None, byteorder=sys.byteorder, nanosecond=False):
str_check(fout or '', format or '')
return TraceFlow(fout=fout, format=format, byteorder=byteorder, nanosecond=nanosecond) | [
"def",
"trace",
"(",
"fout",
"=",
"None",
",",
"format",
"=",
"None",
",",
"byteorder",
"=",
"sys",
".",
"byteorder",
",",
"nanosecond",
"=",
"False",
")",
":",
"str_check",
"(",
"fout",
"or",
"''",
",",
"format",
"or",
"''",
")",
"return",
"TraceFlo... | Trace TCP flows.
Keyword arguments:
* fout -- str, output path
* format -- str, output format
* byteorder -- str, output file byte order
* nanosecond -- bool, output nanosecond-resolution file flag | [
"Trace",
"TCP",
"flows",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/interface/__init__.py#L184-L195 |
1,240 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv6_frag.py | IPv6_Frag.read_ipv6_frag | def read_ipv6_frag(self, length, extension):
"""Read Fragment Header for IPv6.
Structure of IPv6-Frag header [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header | Reserved | Fragment Offset |Res|M|
+-+-+-+-+-+-+-... | python | def read_ipv6_frag(self, length, extension):
if length is None:
length = len(self)
_next = self._read_protos(1)
_temp = self._read_fileng(1)
_offm = self._read_binary(2)
_ipid = self._read_unpack(4)
ipv6_frag = dict(
next=_next,
lengt... | [
"def",
"read_ipv6_frag",
"(",
"self",
",",
"length",
",",
"extension",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"len",
"(",
"self",
")",
"_next",
"=",
"self",
".",
"_read_protos",
"(",
"1",
")",
"_temp",
"=",
"self",
".",
"_read_fi... | Read Fragment Header for IPv6.
Structure of IPv6-Frag header [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header | Reserved | Fragment Offset |Res|M|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"Fragment",
"Header",
"for",
"IPv6",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv6_frag.py#L87-L128 |
1,241 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv4.py | IPv4._read_ipv4_options | def _read_ipv4_options(self, size=None):
"""Read IPv4 option list.
Positional arguments:
* size -- int, buffer size
Returns:
* tuple -- IPv4 option list
* dict -- extracted IPv4 option
"""
counter = 0 # length of read option list
... | python | def _read_ipv4_options(self, size=None):
counter = 0 # length of read option list
optkind = list() # option kind list
options = dict() # dict of option data
while counter < size:
# get option kind
kind = self._read_unpack(1)
# fetch cor... | [
"def",
"_read_ipv4_options",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"counter",
"=",
"0",
"# length of read option list",
"optkind",
"=",
"list",
"(",
")",
"# option kind list",
"options",
"=",
"dict",
"(",
")",
"# dict of option data",
"while",
"counte... | Read IPv4 option list.
Positional arguments:
* size -- int, buffer size
Returns:
* tuple -- IPv4 option list
* dict -- extracted IPv4 option | [
"Read",
"IPv4",
"option",
"list",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv4.py#L312-L382 |
1,242 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv4.py | IPv4._read_mode_route | def _read_mode_route(self, size, kind):
"""Read options with route data.
Positional arguments:
* size - int, length of option
* kind - int, 7/131/137 (RR/LSR/SSR)
Returns:
* dict -- extracted option with route data
Structure of these options:
... | python | def _read_mode_route(self, size, kind):
if size < 3 or (size - 3) % 4 != 0:
raise ProtocolError(f'{self.alias}: [Optno {kind}] invalid format')
_rptr = self._read_unpack(1)
if _rptr < 4:
raise ProtocolError(f'{self.alias}: [Optno {kind}] invalid format')
data =... | [
"def",
"_read_mode_route",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"if",
"size",
"<",
"3",
"or",
"(",
"size",
"-",
"3",
")",
"%",
"4",
"!=",
"0",
":",
"raise",
"ProtocolError",
"(",
"f'{self.alias}: [Optno {kind}] invalid format'",
")",
"_rptr",
... | Read options with route data.
Positional arguments:
* size - int, length of option
* kind - int, 7/131/137 (RR/LSR/SSR)
Returns:
* dict -- extracted option with route data
Structure of these options:
* [RFC 791] Loose Source Route
... | [
"Read",
"options",
"with",
"route",
"data",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv4.py#L448-L505 |
1,243 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv4.py | IPv4._read_mode_qs | def _read_mode_qs(self, size, kind):
"""Read Quick Start option.
Positional arguments:
* size - int, length of option
* kind - int, 25 (QS)
Returns:
* dict -- extracted Quick Start (QS) option
Structure of Quick-Start (QS) option [RFC 4782]:
... | python | def _read_mode_qs(self, size, kind):
if size != 8:
raise ProtocolError(f'{self.alias}: [Optno {kind}] invalid format')
_type = self._read_opt_type(kind)
_fcrr = self._read_binary(1)
_func = int(_fcrr[:4], base=2)
_rate = int(_fcrr[4:], base=2)
_ttlv = self._r... | [
"def",
"_read_mode_qs",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"if",
"size",
"!=",
"8",
":",
"raise",
"ProtocolError",
"(",
"f'{self.alias}: [Optno {kind}] invalid format'",
")",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"kind",
")",
"_fcrr",... | Read Quick Start option.
Positional arguments:
* size - int, length of option
* kind - int, 25 (QS)
Returns:
* dict -- extracted Quick Start (QS) option
Structure of Quick-Start (QS) option [RFC 4782]:
* A Quick-Start Request.
0... | [
"Read",
"Quick",
"Start",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv4.py#L507-L574 |
1,244 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv4.py | IPv4._read_mode_ts | def _read_mode_ts(self, size, kind):
"""Read Time Stamp option.
Positional arguments:
* size - int, length of option
* kind - int, 68 (TS)
Returns:
* dict -- extracted Time Stamp (TS) option
Structure of Timestamp (TS) option [RFC 791]:
... | python | def _read_mode_ts(self, size, kind):
if size > 40 or size < 4:
raise ProtocolError(f'{self.alias}: [Optno {kind}] invalid format')
_tptr = self._read_unpack(1)
_oflg = self._read_binary(1)
_oflw = int(_oflg[:4], base=2)
_flag = int(_oflg[4:], base=2)
if _tpt... | [
"def",
"_read_mode_ts",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"if",
"size",
">",
"40",
"or",
"size",
"<",
"4",
":",
"raise",
"ProtocolError",
"(",
"f'{self.alias}: [Optno {kind}] invalid format'",
")",
"_tptr",
"=",
"self",
".",
"_read_unpack",
"(... | Read Time Stamp option.
Positional arguments:
* size - int, length of option
* kind - int, 68 (TS)
Returns:
* dict -- extracted Time Stamp (TS) option
Structure of Timestamp (TS) option [RFC 791]:
+--------+--------+--------+--------+
... | [
"Read",
"Time",
"Stamp",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv4.py#L576-L658 |
1,245 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv4.py | IPv4._read_mode_tr | def _read_mode_tr(self, size, kind):
"""Read Traceroute option.
Positional arguments:
size - int, length of option
kind - int, 82 (TR)
Returns:
* dict -- extracted Traceroute (TR) option
Structure of Traceroute (TR) option [RFC 1393][RFC 6814]:
... | python | def _read_mode_tr(self, size, kind):
if size != 12:
raise ProtocolError(f'{self.alias}: [Optno {kind}] invalid format')
_idnm = self._read_unpack(2)
_ohcn = self._read_unpack(2)
_rhcn = self._read_unpack(2)
_ipad = self._read_ipv4_addr()
data = dict(
... | [
"def",
"_read_mode_tr",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"if",
"size",
"!=",
"12",
":",
"raise",
"ProtocolError",
"(",
"f'{self.alias}: [Optno {kind}] invalid format'",
")",
"_idnm",
"=",
"self",
".",
"_read_unpack",
"(",
"2",
")",
"_ohcn",
"... | Read Traceroute option.
Positional arguments:
size - int, length of option
kind - int, 82 (TR)
Returns:
* dict -- extracted Traceroute (TR) option
Structure of Traceroute (TR) option [RFC 1393][RFC 6814]:
0 8 16 ... | [
"Read",
"Traceroute",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv4.py#L660-L710 |
1,246 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv4.py | IPv4._read_mode_sec | def _read_mode_sec(self, size, kind):
"""Read options with security info.
Positional arguments:
size - int, length of option
kind - int, 130 (SEC )/ 133 (ESEC)
Returns:
* dict -- extracted option with security info (E/SEC)
Structure of these options... | python | def _read_mode_sec(self, size, kind):
if size < 3:
raise ProtocolError(f'{self.alias}: [Optno {kind}] invalid format')
_clvl = self._read_unpack(1)
data = dict(
kind=kind,
type=self._read_opt_type(kind),
length=size,
level=_CLASSIFICA... | [
"def",
"_read_mode_sec",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"if",
"size",
"<",
"3",
":",
"raise",
"ProtocolError",
"(",
"f'{self.alias}: [Optno {kind}] invalid format'",
")",
"_clvl",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"data",
"="... | Read options with security info.
Positional arguments:
size - int, length of option
kind - int, 130 (SEC )/ 133 (ESEC)
Returns:
* dict -- extracted option with security info (E/SEC)
Structure of these options:
* [RFC 1108] Security (SEC)
... | [
"Read",
"options",
"with",
"security",
"info",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv4.py#L712-L776 |
1,247 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv4.py | IPv4._read_mode_rsralt | def _read_mode_rsralt(self, size, kind):
"""Read Router Alert option.
Positional arguments:
size - int, length of option
kind - int, 148 (RTRALT)
Returns:
* dict -- extracted Router Alert (RTRALT) option
Structure of Router Alert (RTRALT) option [RF... | python | def _read_mode_rsralt(self, size, kind):
if size != 4:
raise ProtocolError(f'{self.alias}: [Optno {kind}] invalid format')
_code = self._read_unpack(2)
data = dict(
kind=kind,
type=self._read_opt_type(kind),
length=size,
alert=_ROUTER... | [
"def",
"_read_mode_rsralt",
"(",
"self",
",",
"size",
",",
"kind",
")",
":",
"if",
"size",
"!=",
"4",
":",
"raise",
"ProtocolError",
"(",
"f'{self.alias}: [Optno {kind}] invalid format'",
")",
"_code",
"=",
"self",
".",
"_read_unpack",
"(",
"2",
")",
"data",
... | Read Router Alert option.
Positional arguments:
size - int, length of option
kind - int, 148 (RTRALT)
Returns:
* dict -- extracted Router Alert (RTRALT) option
Structure of Router Alert (RTRALT) option [RFC 2113]:
+--------+--------+--------+---... | [
"Read",
"Router",
"Alert",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv4.py#L778-L816 |
1,248 | JarryShaw/PyPCAPKit | src/protocols/pcap/header.py | Header.read_header | def read_header(self):
"""Read global header of PCAP file.
Structure of global header (C):
typedef struct pcap_hdr_s {
guint32 magic_number; /* magic number */
guint16 version_major; /* major version number */
guint16 version_minor; /* min... | python | def read_header(self):
_magn = self._read_fileng(4)
if _magn == b'\xd4\xc3\xb2\xa1':
lilendian = True
self._nsec = False
self._byte = 'little'
elif _magn == b'\xa1\xb2\xc3\xd4':
lilendian = False
self._nsec = False
self._byt... | [
"def",
"read_header",
"(",
"self",
")",
":",
"_magn",
"=",
"self",
".",
"_read_fileng",
"(",
"4",
")",
"if",
"_magn",
"==",
"b'\\xd4\\xc3\\xb2\\xa1'",
":",
"lilendian",
"=",
"True",
"self",
".",
"_nsec",
"=",
"False",
"self",
".",
"_byte",
"=",
"'little'... | Read global header of PCAP file.
Structure of global header (C):
typedef struct pcap_hdr_s {
guint32 magic_number; /* magic number */
guint16 version_major; /* major version number */
guint16 version_minor; /* minor version number */
... | [
"Read",
"global",
"header",
"of",
"PCAP",
"file",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/pcap/header.py#L110-L170 |
1,249 | JarryShaw/PyPCAPKit | src/protocols/pcap/frame.py | Frame.read_frame | def read_frame(self):
"""Read each block after global header.
Structure of record/package header (C):
typedef struct pcaprec_hdr_s {
guint32 ts_sec; /* timestamp seconds */
guint32 ts_usec; /* timestamp microseconds */
guint32 incl_len;... | python | def read_frame(self):
# _scur = self._file.tell()
_temp = self._read_unpack(4, lilendian=True, quiet=True)
if _temp is None:
raise EOFError
_tsss = _temp
_tsus = self._read_unpack(4, lilendian=True)
_ilen = self._read_unpack(4, lilendian=True)
_olen =... | [
"def",
"read_frame",
"(",
"self",
")",
":",
"# _scur = self._file.tell()",
"_temp",
"=",
"self",
".",
"_read_unpack",
"(",
"4",
",",
"lilendian",
"=",
"True",
",",
"quiet",
"=",
"True",
")",
"if",
"_temp",
"is",
"None",
":",
"raise",
"EOFError",
"_tsss",
... | Read each block after global header.
Structure of record/package header (C):
typedef struct pcaprec_hdr_s {
guint32 ts_sec; /* timestamp seconds */
guint32 ts_usec; /* timestamp microseconds */
guint32 incl_len; /* number of octets of packet ... | [
"Read",
"each",
"block",
"after",
"global",
"header",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/pcap/frame.py#L88-L145 |
1,250 | JarryShaw/PyPCAPKit | src/protocols/pcap/frame.py | Frame._decode_next_layer | def _decode_next_layer(self, dict_, length=None):
"""Decode next layer protocol.
Positional arguments:
dict_ -- dict, info buffer
proto -- str, next layer protocol name
length -- int, valid (not padding) length
Returns:
* dict -- current protocol... | python | def _decode_next_layer(self, dict_, length=None):
seek_cur = self._file.tell()
try:
next_ = self._import_next_layer(self._prot, length)
except Exception:
dict_['error'] = traceback.format_exc(limit=1).strip().split(os.linesep)[-1]
self._file.seek(seek_cur, os.... | [
"def",
"_decode_next_layer",
"(",
"self",
",",
"dict_",
",",
"length",
"=",
"None",
")",
":",
"seek_cur",
"=",
"self",
".",
"_file",
".",
"tell",
"(",
")",
"try",
":",
"next_",
"=",
"self",
".",
"_import_next_layer",
"(",
"self",
".",
"_prot",
",",
"... | Decode next layer protocol.
Positional arguments:
dict_ -- dict, info buffer
proto -- str, next layer protocol name
length -- int, valid (not padding) length
Returns:
* dict -- current protocol with packet extracted | [
"Decode",
"next",
"layer",
"protocol",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/pcap/frame.py#L229-L259 |
1,251 | JarryShaw/PyPCAPKit | src/protocols/raw.py | Raw.read_raw | def read_raw(self, length, *, error=None):
"""Read raw packet data."""
if length is None:
length = len(self)
raw = dict(
packet=self._read_fileng(length),
error=error or None,
)
return raw | python | def read_raw(self, length, *, error=None):
if length is None:
length = len(self)
raw = dict(
packet=self._read_fileng(length),
error=error or None,
)
return raw | [
"def",
"read_raw",
"(",
"self",
",",
"length",
",",
"*",
",",
"error",
"=",
"None",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"len",
"(",
"self",
")",
"raw",
"=",
"dict",
"(",
"packet",
"=",
"self",
".",
"_read_fileng",
"(",
"le... | Read raw packet data. | [
"Read",
"raw",
"packet",
"data",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/raw.py#L73-L83 |
1,252 | JarryShaw/PyPCAPKit | src/toolkit/dpkt.py | ipv6_hdr_len | def ipv6_hdr_len(ipv6):
"""Calculate length of headers before IPv6-Frag"""
hdr_len = ipv6.__hdr_len__
for code in (0, 60, 43):
ext_hdr = ipv6.extension_hdrs.get(code)
if ext_hdr is not None:
hdr_len += ext_hdr.length
return hdr_len | python | def ipv6_hdr_len(ipv6):
hdr_len = ipv6.__hdr_len__
for code in (0, 60, 43):
ext_hdr = ipv6.extension_hdrs.get(code)
if ext_hdr is not None:
hdr_len += ext_hdr.length
return hdr_len | [
"def",
"ipv6_hdr_len",
"(",
"ipv6",
")",
":",
"hdr_len",
"=",
"ipv6",
".",
"__hdr_len__",
"for",
"code",
"in",
"(",
"0",
",",
"60",
",",
"43",
")",
":",
"ext_hdr",
"=",
"ipv6",
".",
"extension_hdrs",
".",
"get",
"(",
"code",
")",
"if",
"ext_hdr",
"... | Calculate length of headers before IPv6-Frag | [
"Calculate",
"length",
"of",
"headers",
"before",
"IPv6",
"-",
"Frag"
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/dpkt.py#L20-L27 |
1,253 | JarryShaw/PyPCAPKit | src/toolkit/dpkt.py | packet2chain | def packet2chain(packet):
"""Fetch DPKT packet protocol chain."""
chain = [type(packet).__name__]
payload = packet.data
while not isinstance(payload, bytes):
chain.append(type(payload).__name__)
payload = payload.data
return ':'.join(chain) | python | def packet2chain(packet):
chain = [type(packet).__name__]
payload = packet.data
while not isinstance(payload, bytes):
chain.append(type(payload).__name__)
payload = payload.data
return ':'.join(chain) | [
"def",
"packet2chain",
"(",
"packet",
")",
":",
"chain",
"=",
"[",
"type",
"(",
"packet",
")",
".",
"__name__",
"]",
"payload",
"=",
"packet",
".",
"data",
"while",
"not",
"isinstance",
"(",
"payload",
",",
"bytes",
")",
":",
"chain",
".",
"append",
... | Fetch DPKT packet protocol chain. | [
"Fetch",
"DPKT",
"packet",
"protocol",
"chain",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/dpkt.py#L30-L37 |
1,254 | JarryShaw/PyPCAPKit | src/toolkit/dpkt.py | packet2dict | def packet2dict(packet, timestamp, *, data_link):
"""Convert DPKT packet into dict."""
def wrapper(packet):
dict_ = dict()
for field in packet.__hdr_fields__:
dict_[field] = getattr(packet, field, None)
payload = packet.data
if not isinstance(payload, bytes):
... | python | def packet2dict(packet, timestamp, *, data_link):
def wrapper(packet):
dict_ = dict()
for field in packet.__hdr_fields__:
dict_[field] = getattr(packet, field, None)
payload = packet.data
if not isinstance(payload, bytes):
dict_[type(payload).__name__] = wrapp... | [
"def",
"packet2dict",
"(",
"packet",
",",
"timestamp",
",",
"*",
",",
"data_link",
")",
":",
"def",
"wrapper",
"(",
"packet",
")",
":",
"dict_",
"=",
"dict",
"(",
")",
"for",
"field",
"in",
"packet",
".",
"__hdr_fields__",
":",
"dict_",
"[",
"field",
... | Convert DPKT packet into dict. | [
"Convert",
"DPKT",
"packet",
"into",
"dict",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/dpkt.py#L40-L54 |
1,255 | JarryShaw/PyPCAPKit | src/protocols/application/httpv2.py | HTTPv2._read_http_none | def _read_http_none(self, size, kind, flag):
"""Read HTTP packet with unsigned type."""
if any((int(bit, base=2) for bit in flag)):
raise ProtocolError(f'HTTP/2: [Type {kind}] invalid format', quiet=True)
data = dict(
flags=None,
payload=self._read_fileng(siz... | python | def _read_http_none(self, size, kind, flag):
if any((int(bit, base=2) for bit in flag)):
raise ProtocolError(f'HTTP/2: [Type {kind}] invalid format', quiet=True)
data = dict(
flags=None,
payload=self._read_fileng(size - 9) or None,
)
return data | [
"def",
"_read_http_none",
"(",
"self",
",",
"size",
",",
"kind",
",",
"flag",
")",
":",
"if",
"any",
"(",
"(",
"int",
"(",
"bit",
",",
"base",
"=",
"2",
")",
"for",
"bit",
"in",
"flag",
")",
")",
":",
"raise",
"ProtocolError",
"(",
"f'HTTP/2: [Type... | Read HTTP packet with unsigned type. | [
"Read",
"HTTP",
"packet",
"with",
"unsigned",
"type",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/application/httpv2.py#L172-L182 |
1,256 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor.run | def run(self):
"""Start extraction."""
flag = True
if self._exeng == 'dpkt':
flag, engine = self.import_test('dpkt', name='DPKT')
if flag:
return self._run_dpkt(engine)
elif self._exeng == 'scapy':
flag, engine = self.import_test('scapy... | python | def run(self):
flag = True
if self._exeng == 'dpkt':
flag, engine = self.import_test('dpkt', name='DPKT')
if flag:
return self._run_dpkt(engine)
elif self._exeng == 'scapy':
flag, engine = self.import_test('scapy.all', name='Scapy')
... | [
"def",
"run",
"(",
"self",
")",
":",
"flag",
"=",
"True",
"if",
"self",
".",
"_exeng",
"==",
"'dpkt'",
":",
"flag",
",",
"engine",
"=",
"self",
".",
"import_test",
"(",
"'dpkt'",
",",
"name",
"=",
"'DPKT'",
")",
"if",
"flag",
":",
"return",
"self",... | Start extraction. | [
"Start",
"extraction",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L224-L261 |
1,257 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor.record_header | def record_header(self):
"""Read global header.
- Extract global header.
- Make Info object out of header properties.
- Append Info.
- Write plist file.
"""
self._gbhdr = Header(self._ifile)
self._vinfo = self._gbhdr.version
self._dlink = self._g... | python | def record_header(self):
self._gbhdr = Header(self._ifile)
self._vinfo = self._gbhdr.version
self._dlink = self._gbhdr.protocol
self._nnsec = self._gbhdr.nanosecond
if self._trace is not NotImplemented:
self._trace._endian = self._gbhdr.byteorder
self._tr... | [
"def",
"record_header",
"(",
"self",
")",
":",
"self",
".",
"_gbhdr",
"=",
"Header",
"(",
"self",
".",
"_ifile",
")",
"self",
".",
"_vinfo",
"=",
"self",
".",
"_gbhdr",
".",
"version",
"self",
".",
"_dlink",
"=",
"self",
".",
"_gbhdr",
".",
"protocol... | Read global header.
- Extract global header.
- Make Info object out of header properties.
- Append Info.
- Write plist file. | [
"Read",
"global",
"header",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L345-L370 |
1,258 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._cleanup | def _cleanup(self):
"""Cleanup after extraction & analysis."""
self._expkg = None
self._extmp = None
self._flag_e = True
self._ifile.close() | python | def _cleanup(self):
self._expkg = None
self._extmp = None
self._flag_e = True
self._ifile.close() | [
"def",
"_cleanup",
"(",
"self",
")",
":",
"self",
".",
"_expkg",
"=",
"None",
"self",
".",
"_extmp",
"=",
"None",
"self",
".",
"_flag_e",
"=",
"True",
"self",
".",
"_ifile",
".",
"close",
"(",
")"
] | Cleanup after extraction & analysis. | [
"Cleanup",
"after",
"extraction",
"&",
"analysis",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L566-L571 |
1,259 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._aftermathmp | def _aftermathmp(self):
"""Aftermath for multiprocessing."""
if not self._flag_e and self._flag_m:
# join processes
[proc.join() for proc in self._mpprc]
if self._exeng == 'server':
self._mpsvc.join()
# restore attributes
if se... | python | def _aftermathmp(self):
if not self._flag_e and self._flag_m:
# join processes
[proc.join() for proc in self._mpprc]
if self._exeng == 'server':
self._mpsvc.join()
# restore attributes
if self._exeng == 'server':
self._... | [
"def",
"_aftermathmp",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_flag_e",
"and",
"self",
".",
"_flag_m",
":",
"# join processes",
"[",
"proc",
".",
"join",
"(",
")",
"for",
"proc",
"in",
"self",
".",
"_mpprc",
"]",
"if",
"self",
".",
"_exeng... | Aftermath for multiprocessing. | [
"Aftermath",
"for",
"multiprocessing",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L573-L594 |
1,260 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._update_eof | def _update_eof(self):
"""Update EOF flag."""
self._aftermathmp()
self._ifile.close()
self._flag_e = True | python | def _update_eof(self):
self._aftermathmp()
self._ifile.close()
self._flag_e = True | [
"def",
"_update_eof",
"(",
"self",
")",
":",
"self",
".",
"_aftermathmp",
"(",
")",
"self",
".",
"_ifile",
".",
"close",
"(",
")",
"self",
".",
"_flag_e",
"=",
"True"
] | Update EOF flag. | [
"Update",
"EOF",
"flag",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L597-L601 |
1,261 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._read_frame | def _read_frame(self):
"""Headquarters for frame reader."""
if self._exeng == 'scapy':
return self._scapy_read_frame()
elif self._exeng == 'dpkt':
return self._dpkt_read_frame()
elif self._exeng == 'pyshark':
return self._pyshark_read_frame()
e... | python | def _read_frame(self):
if self._exeng == 'scapy':
return self._scapy_read_frame()
elif self._exeng == 'dpkt':
return self._dpkt_read_frame()
elif self._exeng == 'pyshark':
return self._pyshark_read_frame()
else:
return self._default_read_fr... | [
"def",
"_read_frame",
"(",
"self",
")",
":",
"if",
"self",
".",
"_exeng",
"==",
"'scapy'",
":",
"return",
"self",
".",
"_scapy_read_frame",
"(",
")",
"elif",
"self",
".",
"_exeng",
"==",
"'dpkt'",
":",
"return",
"self",
".",
"_dpkt_read_frame",
"(",
")",... | Headquarters for frame reader. | [
"Headquarters",
"for",
"frame",
"reader",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L603-L612 |
1,262 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._default_read_frame | def _default_read_frame(self, *, frame=None, mpkit=None):
"""Read frames with default engine.
- Extract frames and each layer of packets.
- Make Info object out of frame properties.
- Append Info.
- Write plist & append Info.
"""
from pcapkit.toolkit.default imp... | python | def _default_read_frame(self, *, frame=None, mpkit=None):
from pcapkit.toolkit.default import (ipv4_reassembly, ipv6_reassembly,
tcp_reassembly, tcp_traceflow)
# read frame header
if not self._flag_m:
frame = Frame(self._ifile, num=self._... | [
"def",
"_default_read_frame",
"(",
"self",
",",
"*",
",",
"frame",
"=",
"None",
",",
"mpkit",
"=",
"None",
")",
":",
"from",
"pcapkit",
".",
"toolkit",
".",
"default",
"import",
"(",
"ipv4_reassembly",
",",
"ipv6_reassembly",
",",
"tcp_reassembly",
",",
"t... | Read frames with default engine.
- Extract frames and each layer of packets.
- Make Info object out of frame properties.
- Append Info.
- Write plist & append Info. | [
"Read",
"frames",
"with",
"default",
"engine",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L614-L685 |
1,263 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._run_scapy | def _run_scapy(self, scapy_all):
"""Call scapy.all.sniff to extract PCAP files."""
# if not self._flag_a:
# self._flag_a = True
# warnings.warn(f"'Extractor(engine=scapy)' object is not iterable; "
# "so 'auto=False' will be ignored", AttributeWarning,... | python | def _run_scapy(self, scapy_all):
# if not self._flag_a:
# self._flag_a = True
# warnings.warn(f"'Extractor(engine=scapy)' object is not iterable; "
# "so 'auto=False' will be ignored", AttributeWarning, stacklevel=stacklevel())
if self._exlyr != 'None... | [
"def",
"_run_scapy",
"(",
"self",
",",
"scapy_all",
")",
":",
"# if not self._flag_a:",
"# self._flag_a = True",
"# warnings.warn(f\"'Extractor(engine=scapy)' object is not iterable; \"",
"# \"so 'auto=False' will be ignored\", AttributeWarning, stacklevel=stackleve... | Call scapy.all.sniff to extract PCAP files. | [
"Call",
"scapy",
".",
"all",
".",
"sniff",
"to",
"extract",
"PCAP",
"files",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L687-L704 |
1,264 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._scapy_read_frame | def _scapy_read_frame(self):
"""Read frames with Scapy."""
from pcapkit.toolkit.scapy import (ipv4_reassembly, ipv6_reassembly,
packet2chain, packet2dict, tcp_reassembly,
tcp_traceflow)
# fetch Scapy packet
... | python | def _scapy_read_frame(self):
from pcapkit.toolkit.scapy import (ipv4_reassembly, ipv6_reassembly,
packet2chain, packet2dict, tcp_reassembly,
tcp_traceflow)
# fetch Scapy packet
packet = next(self._extmp)
... | [
"def",
"_scapy_read_frame",
"(",
"self",
")",
":",
"from",
"pcapkit",
".",
"toolkit",
".",
"scapy",
"import",
"(",
"ipv4_reassembly",
",",
"ipv6_reassembly",
",",
"packet2chain",
",",
"packet2dict",
",",
"tcp_reassembly",
",",
"tcp_traceflow",
")",
"# fetch Scapy ... | Read frames with Scapy. | [
"Read",
"frames",
"with",
"Scapy",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L706-L757 |
1,265 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._run_dpkt | def _run_dpkt(self, dpkt):
"""Call dpkt.pcap.Reader to extract PCAP files."""
# if not self._flag_a:
# self._flag_a = True
# warnings.warn(f"'Extractor(engine=dpkt)' object is not iterable; "
# "so 'auto=False' will be ignored", AttributeWarning, stack... | python | def _run_dpkt(self, dpkt):
# if not self._flag_a:
# self._flag_a = True
# warnings.warn(f"'Extractor(engine=dpkt)' object is not iterable; "
# "so 'auto=False' will be ignored", AttributeWarning, stacklevel=stacklevel())
if self._exlyr != 'None' or se... | [
"def",
"_run_dpkt",
"(",
"self",
",",
"dpkt",
")",
":",
"# if not self._flag_a:",
"# self._flag_a = True",
"# warnings.warn(f\"'Extractor(engine=dpkt)' object is not iterable; \"",
"# \"so 'auto=False' will be ignored\", AttributeWarning, stacklevel=stacklevel())",
... | Call dpkt.pcap.Reader to extract PCAP files. | [
"Call",
"dpkt",
".",
"pcap",
".",
"Reader",
"to",
"extract",
"PCAP",
"files",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L759-L780 |
1,266 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._run_pyshark | def _run_pyshark(self, pyshark):
"""Call pyshark.FileCapture to extract PCAP files."""
# if not self._flag_a:
# self._flag_a = True
# warnings.warn(f"'Extractor(engine=pyshark)' object is not iterable; "
# "so 'auto=False' will be ignored", AttributeWa... | python | def _run_pyshark(self, pyshark):
# if not self._flag_a:
# self._flag_a = True
# warnings.warn(f"'Extractor(engine=pyshark)' object is not iterable; "
# "so 'auto=False' will be ignored", AttributeWarning, stacklevel=stacklevel())
if self._exlyr != 'No... | [
"def",
"_run_pyshark",
"(",
"self",
",",
"pyshark",
")",
":",
"# if not self._flag_a:",
"# self._flag_a = True",
"# warnings.warn(f\"'Extractor(engine=pyshark)' object is not iterable; \"",
"# \"so 'auto=False' will be ignored\", AttributeWarning, stacklevel=stackle... | Call pyshark.FileCapture to extract PCAP files. | [
"Call",
"pyshark",
".",
"FileCapture",
"to",
"extract",
"PCAP",
"files",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L850-L874 |
1,267 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._run_pipeline | def _run_pipeline(self, multiprocessing):
"""Use pipeline multiprocessing to extract PCAP files."""
if not self._flag_m:
raise UnsupportedCall(f"Extractor(engine={self._exeng})' has no attribute '_run_pipline'")
if not self._flag_q:
self._flag_q = True
warnin... | python | def _run_pipeline(self, multiprocessing):
if not self._flag_m:
raise UnsupportedCall(f"Extractor(engine={self._exeng})' has no attribute '_run_pipline'")
if not self._flag_q:
self._flag_q = True
warnings.warn("'Extractor(engine=pipeline)' does not support output; "
... | [
"def",
"_run_pipeline",
"(",
"self",
",",
"multiprocessing",
")",
":",
"if",
"not",
"self",
".",
"_flag_m",
":",
"raise",
"UnsupportedCall",
"(",
"f\"Extractor(engine={self._exeng})' has no attribute '_run_pipline'\"",
")",
"if",
"not",
"self",
".",
"_flag_q",
":",
... | Use pipeline multiprocessing to extract PCAP files. | [
"Use",
"pipeline",
"multiprocessing",
"to",
"extract",
"PCAP",
"files",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L916-L977 |
1,268 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._run_server | def _run_server(self, multiprocessing):
"""Use server multiprocessing to extract PCAP files."""
if not self._flag_m:
raise UnsupportedCall(f"Extractor(engine={self._exeng})' has no attribute '_run_server'")
if not self._flag_q:
self._flag_q = True
warnings.wa... | python | def _run_server(self, multiprocessing):
if not self._flag_m:
raise UnsupportedCall(f"Extractor(engine={self._exeng})' has no attribute '_run_server'")
if not self._flag_q:
self._flag_q = True
warnings.warn("'Extractor(engine=pipeline)' does not support output; "
... | [
"def",
"_run_server",
"(",
"self",
",",
"multiprocessing",
")",
":",
"if",
"not",
"self",
".",
"_flag_m",
":",
"raise",
"UnsupportedCall",
"(",
"f\"Extractor(engine={self._exeng})' has no attribute '_run_server'\"",
")",
"if",
"not",
"self",
".",
"_flag_q",
":",
"se... | Use server multiprocessing to extract PCAP files. | [
"Use",
"server",
"multiprocessing",
"to",
"extract",
"PCAP",
"files",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L1015-L1082 |
1,269 | JarryShaw/PyPCAPKit | src/foundation/extraction.py | Extractor._server_analyse_frame | def _server_analyse_frame(self, *, mpkit, mpfrm, mprsm, mpbuf):
"""Analyse frame."""
while True:
# fetch frame
# print(self._frnum, 'trying')
frame = mpbuf.pop(self._frnum, None)
if frame is EOFError:
break
if frame is None:
... | python | def _server_analyse_frame(self, *, mpkit, mpfrm, mprsm, mpbuf):
while True:
# fetch frame
# print(self._frnum, 'trying')
frame = mpbuf.pop(self._frnum, None)
if frame is EOFError:
break
if frame is None:
continue
... | [
"def",
"_server_analyse_frame",
"(",
"self",
",",
"*",
",",
"mpkit",
",",
"mpfrm",
",",
"mprsm",
",",
"mpbuf",
")",
":",
"while",
"True",
":",
"# fetch frame",
"# print(self._frnum, 'trying')",
"frame",
"=",
"mpbuf",
".",
"pop",
"(",
"self",
".",
"_frnum",
... | Analyse frame. | [
"Analyse",
"frame",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L1104-L1119 |
1,270 | JarryShaw/PyPCAPKit | src/protocols/application/NotImplemented/httpv2.py | HTTPv2.read_http | def read_http(self, length):
"""Read Hypertext Transfer Protocol version 2.
Structure of HTTP/2 packet [RFC 7230]:
+-----------------------------------------------+
| Length (24) |
+---------------+---------------+---------------+
... | python | def read_http(self, length):
_plen = self._read_binary(3)
_type = self._read_unpack(1)
_flag = self._read_binary(1)
_stid = self._read_binary(4) | [
"def",
"read_http",
"(",
"self",
",",
"length",
")",
":",
"_plen",
"=",
"self",
".",
"_read_binary",
"(",
"3",
")",
"_type",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"_flag",
"=",
"self",
".",
"_read_binary",
"(",
"1",
")",
"_stid",
"=",
"s... | Read Hypertext Transfer Protocol version 2.
Structure of HTTP/2 packet [RFC 7230]:
+-----------------------------------------------+
| Length (24) |
+---------------+---------------+---------------+
| Type (8) | Flags (8) ... | [
"Read",
"Hypertext",
"Transfer",
"Protocol",
"version",
"2",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/application/NotImplemented/httpv2.py#L57-L75 |
1,271 | JarryShaw/PyPCAPKit | src/foundation/traceflow.py | TraceFlow.make_fout | def make_fout(fout='./tmp', fmt='pcap'):
"""Make root path for output.
Positional arguments:
* fout -- str, root path for output
* fmt -- str, output format
Returns:
* output -- dumper of specified format
"""
if fmt == 'pcap': # output... | python | def make_fout(fout='./tmp', fmt='pcap'):
if fmt == 'pcap': # output PCAP file
from pcapkit.dumpkit import PCAP as output
elif fmt == 'plist': # output PLIST file
from dictdumper import PLIST as output
elif fmt == 'json': # output JSON file
from di... | [
"def",
"make_fout",
"(",
"fout",
"=",
"'./tmp'",
",",
"fmt",
"=",
"'pcap'",
")",
":",
"if",
"fmt",
"==",
"'pcap'",
":",
"# output PCAP file",
"from",
"pcapkit",
".",
"dumpkit",
"import",
"PCAP",
"as",
"output",
"elif",
"fmt",
"==",
"'plist'",
":",
"# out... | Make root path for output.
Positional arguments:
* fout -- str, root path for output
* fmt -- str, output format
Returns:
* output -- dumper of specified format | [
"Make",
"root",
"path",
"for",
"output",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/traceflow.py#L55-L95 |
1,272 | JarryShaw/PyPCAPKit | src/foundation/traceflow.py | TraceFlow.dump | def dump(self, packet):
"""Dump frame to output files.
Positional arguments:
* packet -- dict, a flow packet
|-- (str) protocol -- data link type from global header
|-- (int) index -- frame number
|-- (Info) frame -- extracted frame info
... | python | def dump(self, packet):
# fetch flow label
output = self.trace(packet, _check=False, _output=True)
# dump files
output(packet['frame'], name=f"Frame {packet['index']}",
byteorder=self._endian, nanosecond=self._nnsecd) | [
"def",
"dump",
"(",
"self",
",",
"packet",
")",
":",
"# fetch flow label",
"output",
"=",
"self",
".",
"trace",
"(",
"packet",
",",
"_check",
"=",
"False",
",",
"_output",
"=",
"True",
")",
"# dump files",
"output",
"(",
"packet",
"[",
"'frame'",
"]",
... | Dump frame to output files.
Positional arguments:
* packet -- dict, a flow packet
|-- (str) protocol -- data link type from global header
|-- (int) index -- frame number
|-- (Info) frame -- extracted frame info
|-- (bool) syn -- TCP sy... | [
"Dump",
"frame",
"to",
"output",
"files",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/traceflow.py#L97-L119 |
1,273 | JarryShaw/PyPCAPKit | src/foundation/traceflow.py | TraceFlow.trace | def trace(self, packet, *, _check=True, _output=False):
"""Trace packets.
Positional arguments:
* packet -- dict, a flow packet
Keyword arguments:
* _check -- bool, flag if run validations
* _output -- bool, flag if has formatted dumper
"""
... | python | def trace(self, packet, *, _check=True, _output=False):
self._newflg = True
if _check:
pkt_check(packet)
info = Info(packet)
# Buffer Identifier
BUFID = tuple(sorted([str(info.src), str(info.srcport), # pylint: disable=E1101
str(info.... | [
"def",
"trace",
"(",
"self",
",",
"packet",
",",
"*",
",",
"_check",
"=",
"True",
",",
"_output",
"=",
"False",
")",
":",
"self",
".",
"_newflg",
"=",
"True",
"if",
"_check",
":",
"pkt_check",
"(",
"packet",
")",
"info",
"=",
"Info",
"(",
"packet",... | Trace packets.
Positional arguments:
* packet -- dict, a flow packet
Keyword arguments:
* _check -- bool, flag if run validations
* _output -- bool, flag if has formatted dumper | [
"Trace",
"packets",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/traceflow.py#L121-L178 |
1,274 | JarryShaw/PyPCAPKit | src/foundation/traceflow.py | TraceFlow.submit | def submit(self):
"""Submit traced TCP flows."""
self._newflg = False
ret = list()
for buf in self._buffer.values():
buf = copy.deepcopy(buf)
if self._fdpext:
buf['fpout'] = f"{self._fproot}/{buf['label']}.{self._fdpext}"
else:
... | python | def submit(self):
self._newflg = False
ret = list()
for buf in self._buffer.values():
buf = copy.deepcopy(buf)
if self._fdpext:
buf['fpout'] = f"{self._fproot}/{buf['label']}.{self._fdpext}"
else:
del buf['fpout']
bu... | [
"def",
"submit",
"(",
"self",
")",
":",
"self",
".",
"_newflg",
"=",
"False",
"ret",
"=",
"list",
"(",
")",
"for",
"buf",
"in",
"self",
".",
"_buffer",
".",
"values",
"(",
")",
":",
"buf",
"=",
"copy",
".",
"deepcopy",
"(",
"buf",
")",
"if",
"s... | Submit traced TCP flows. | [
"Submit",
"traced",
"TCP",
"flows",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/traceflow.py#L180-L193 |
1,275 | JarryShaw/PyPCAPKit | src/protocols/internet/ah.py | AH.read_ah | def read_ah(self, length, version, extension):
"""Read Authentication Header.
Structure of AH header [RFC 4302]:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-... | python | def read_ah(self, length, version, extension):
if length is None:
length = len(self)
_next = self._read_protos(1)
_plen = self._read_unpack(1)
_resv = self._read_fileng(2)
_scpi = self._read_unpack(4)
_dsnf = self._read_unpack(4)
# ICV length & value... | [
"def",
"read_ah",
"(",
"self",
",",
"length",
",",
"version",
",",
"extension",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"len",
"(",
"self",
")",
"_next",
"=",
"self",
".",
"_read_protos",
"(",
"1",
")",
"_plen",
"=",
"self",
"."... | Read Authentication Header.
Structure of AH header [RFC 4302]:
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... | [
"Read",
"Authentication",
"Header",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ah.py#L91-L158 |
1,276 | JarryShaw/PyPCAPKit | src/protocols/link/ethernet.py | Ethernet.read_ethernet | def read_ethernet(self, length):
"""Read Ethernet Protocol.
Structure of Ethernet Protocol header [RFC 7042]:
Octets Bits Name Description
0 0 eth.dst Destination MAC Address
1 8 eth.src ... | python | def read_ethernet(self, length):
if length is None:
length = len(self)
_dstm = self._read_mac_addr()
_srcm = self._read_mac_addr()
_type = self._read_protos(2)
ethernet = dict(
dst=_dstm,
src=_srcm,
type=_type,
)
... | [
"def",
"read_ethernet",
"(",
"self",
",",
"length",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"len",
"(",
"self",
")",
"_dstm",
"=",
"self",
".",
"_read_mac_addr",
"(",
")",
"_srcm",
"=",
"self",
".",
"_read_mac_addr",
"(",
")",
"_t... | Read Ethernet Protocol.
Structure of Ethernet Protocol header [RFC 7042]:
Octets Bits Name Description
0 0 eth.dst Destination MAC Address
1 8 eth.src Source MAC Address
... | [
"Read",
"Ethernet",
"Protocol",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/link/ethernet.py#L92-L118 |
1,277 | JarryShaw/PyPCAPKit | src/protocols/link/ethernet.py | Ethernet._read_mac_addr | def _read_mac_addr(self):
"""Read MAC address."""
_byte = self._read_fileng(6)
_addr = '-'.join(textwrap.wrap(_byte.hex(), 2))
return _addr | python | def _read_mac_addr(self):
_byte = self._read_fileng(6)
_addr = '-'.join(textwrap.wrap(_byte.hex(), 2))
return _addr | [
"def",
"_read_mac_addr",
"(",
"self",
")",
":",
"_byte",
"=",
"self",
".",
"_read_fileng",
"(",
"6",
")",
"_addr",
"=",
"'-'",
".",
"join",
"(",
"textwrap",
".",
"wrap",
"(",
"_byte",
".",
"hex",
"(",
")",
",",
"2",
")",
")",
"return",
"_addr"
] | Read MAC address. | [
"Read",
"MAC",
"address",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/link/ethernet.py#L135-L139 |
1,278 | JarryShaw/PyPCAPKit | src/toolkit/pyshark.py | packet2dict | def packet2dict(packet):
"""Convert PyShark packet into dict."""
dict_ = dict()
frame = packet.frame_info
for field in frame.field_names:
dict_[field] = getattr(frame, field)
tempdict = dict_
for layer in packet.layers:
tempdict[layer.layer_name.upper()] = dict()
tempdic... | python | def packet2dict(packet):
dict_ = dict()
frame = packet.frame_info
for field in frame.field_names:
dict_[field] = getattr(frame, field)
tempdict = dict_
for layer in packet.layers:
tempdict[layer.layer_name.upper()] = dict()
tempdict = tempdict[layer.layer_name.upper()]
... | [
"def",
"packet2dict",
"(",
"packet",
")",
":",
"dict_",
"=",
"dict",
"(",
")",
"frame",
"=",
"packet",
".",
"frame_info",
"for",
"field",
"in",
"frame",
".",
"field_names",
":",
"dict_",
"[",
"field",
"]",
"=",
"getattr",
"(",
"frame",
",",
"field",
... | Convert PyShark packet into dict. | [
"Convert",
"PyShark",
"packet",
"into",
"dict",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/pyshark.py#L17-L31 |
1,279 | JarryShaw/PyPCAPKit | src/toolkit/scapy.py | packet2chain | def packet2chain(packet):
"""Fetch Scapy packet protocol chain."""
if scapy_all is None:
raise ModuleNotFound("No module named 'scapy'", name='scapy')
chain = [packet.name]
payload = packet.payload
while not isinstance(payload, scapy_all.packet.NoPayload):
chain.append(payload.name)
... | python | def packet2chain(packet):
if scapy_all is None:
raise ModuleNotFound("No module named 'scapy'", name='scapy')
chain = [packet.name]
payload = packet.payload
while not isinstance(payload, scapy_all.packet.NoPayload):
chain.append(payload.name)
payload = payload.payload
return ... | [
"def",
"packet2chain",
"(",
"packet",
")",
":",
"if",
"scapy_all",
"is",
"None",
":",
"raise",
"ModuleNotFound",
"(",
"\"No module named 'scapy'\"",
",",
"name",
"=",
"'scapy'",
")",
"chain",
"=",
"[",
"packet",
".",
"name",
"]",
"payload",
"=",
"packet",
... | Fetch Scapy packet protocol chain. | [
"Fetch",
"Scapy",
"packet",
"protocol",
"chain",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/scapy.py#L36-L45 |
1,280 | JarryShaw/PyPCAPKit | src/toolkit/scapy.py | packet2dict | def packet2dict(packet, *, count=NotImplemented):
"""Convert Scapy packet into dict."""
if scapy_all is None:
raise ModuleNotFound("No module named 'scapy'", name='scapy')
def wrapper(packet):
dict_ = packet.fields
payload = packet.payload
if not isinstance(payload, scapy_al... | python | def packet2dict(packet, *, count=NotImplemented):
if scapy_all is None:
raise ModuleNotFound("No module named 'scapy'", name='scapy')
def wrapper(packet):
dict_ = packet.fields
payload = packet.payload
if not isinstance(payload, scapy_all.packet.NoPayload):
dict_[pay... | [
"def",
"packet2dict",
"(",
"packet",
",",
"*",
",",
"count",
"=",
"NotImplemented",
")",
":",
"if",
"scapy_all",
"is",
"None",
":",
"raise",
"ModuleNotFound",
"(",
"\"No module named 'scapy'\"",
",",
"name",
"=",
"'scapy'",
")",
"def",
"wrapper",
"(",
"packe... | Convert Scapy packet into dict. | [
"Convert",
"Scapy",
"packet",
"into",
"dict",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/scapy.py#L48-L63 |
1,281 | JarryShaw/PyPCAPKit | src/toolkit/scapy.py | tcp_reassembly | def tcp_reassembly(packet, *, count=NotImplemented):
"""Store data for TCP reassembly."""
if 'TCP' in packet:
ip = packet['IP'] if 'IP' in packet else packet['IPv6']
tcp = packet['TCP']
data = dict(
bufid=(
ipaddress.ip_address(ip.src), # source IP addre... | python | def tcp_reassembly(packet, *, count=NotImplemented):
if 'TCP' in packet:
ip = packet['IP'] if 'IP' in packet else packet['IPv6']
tcp = packet['TCP']
data = dict(
bufid=(
ipaddress.ip_address(ip.src), # source IP address
ipaddress.ip_address(i... | [
"def",
"tcp_reassembly",
"(",
"packet",
",",
"*",
",",
"count",
"=",
"NotImplemented",
")",
":",
"if",
"'TCP'",
"in",
"packet",
":",
"ip",
"=",
"packet",
"[",
"'IP'",
"]",
"if",
"'IP'",
"in",
"packet",
"else",
"packet",
"[",
"'IPv6'",
"]",
"tcp",
"="... | Store data for TCP reassembly. | [
"Store",
"data",
"for",
"TCP",
"reassembly",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/scapy.py#L119-L144 |
1,282 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT.read_hopopt | def read_hopopt(self, length, extension):
"""Read IPv6 Hop-by-Hop Options.
Structure of HOPOPT header [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header | Hdr Ext Len | |
+-+-+-+-+-+-+-+-+-+-+... | python | def read_hopopt(self, length, extension):
if length is None:
length = len(self)
_next = self._read_protos(1)
_hlen = self._read_unpack(1)
# _opts = self._read_fileng(_hlen*8+6)
hopopt = dict(
next=_next,
length=(_hlen + 1) * 8,
)
... | [
"def",
"read_hopopt",
"(",
"self",
",",
"length",
",",
"extension",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"len",
"(",
"self",
")",
"_next",
"=",
"self",
".",
"_read_protos",
"(",
"1",
")",
"_hlen",
"=",
"self",
".",
"_read_unpac... | Read IPv6 Hop-by-Hop Options.
Structure of HOPOPT header [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header | Hdr Ext Len | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
... | [
"Read",
"IPv6",
"Hop",
"-",
"by",
"-",
"Hop",
"Options",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L147-L189 |
1,283 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_hopopt_options | def _read_hopopt_options(self, length):
"""Read HOPOPT options.
Positional arguments:
* length -- int, length of options
Returns:
* dict -- extracted HOPOPT options
"""
counter = 0 # length of read options
optkind = list() # option ty... | python | def _read_hopopt_options(self, length):
counter = 0 # length of read options
optkind = list() # option type list
options = dict() # dict of option data
while counter < length:
# break when eol triggered
code = self._read_unpack(1)
if not... | [
"def",
"_read_hopopt_options",
"(",
"self",
",",
"length",
")",
":",
"counter",
"=",
"0",
"# length of read options",
"optkind",
"=",
"list",
"(",
")",
"# option type list",
"options",
"=",
"dict",
"(",
")",
"# dict of option data",
"while",
"counter",
"<",
"len... | Read HOPOPT options.
Positional arguments:
* length -- int, length of options
Returns:
* dict -- extracted HOPOPT options | [
"Read",
"HOPOPT",
"options",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L234-L274 |
1,284 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_pad | def _read_opt_pad(self, code, *, desc):
"""Read HOPOPT padding options.
Structure of HOPOPT padding options [RFC 8200]:
* Pad1 Option:
+-+-+-+-+-+-+-+-+
| 0 |
+-+-+-+-+-+-+-+-+
Octets Bits Name ... | python | def _read_opt_pad(self, code, *, desc):
_type = self._read_opt_type(code)
if code == 0:
opt = dict(
desc=desc,
type=_type,
length=1,
)
elif code == 1:
_size = self._read_unpack(1)
_padn = self._read_... | [
"def",
"_read_opt_pad",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"if",
"code",
"==",
"0",
":",
"opt",
"=",
"dict",
"(",
"desc",
"=",
"desc",
",",
"type",
"=",
"_type... | Read HOPOPT padding options.
Structure of HOPOPT padding options [RFC 8200]:
* Pad1 Option:
+-+-+-+-+-+-+-+-+
| 0 |
+-+-+-+-+-+-+-+-+
Octets Bits Name Description
0 ... | [
"Read",
"HOPOPT",
"padding",
"options",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L306-L356 |
1,285 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_tun | def _read_opt_tun(self, code, *, desc):
"""Read HOPOPT Tunnel Encapsulation Limit option.
Structure of HOPOPT Tunnel Encapsulation Limit option [RFC 2473]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header |Hdr Ext Len = 0| Opt Type = 4 |Opt Data... | python | def _read_opt_tun(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
if _size != 1:
raise ProtocolError(f'{self.alias}: [Optno {code}] invalid format')
_limt = self._read_unpack(1)
opt = dict(
desc=desc,
type=... | [
"def",
"_read_opt_tun",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"_size",
"!=",
"1",
":",
"raise",
"Pro... | Read HOPOPT Tunnel Encapsulation Limit option.
Structure of HOPOPT Tunnel Encapsulation Limit option [RFC 2473]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header |Hdr Ext Len = 0| Opt Type = 4 |Opt Data Len=1 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HOPOPT",
"Tunnel",
"Encapsulation",
"Limit",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L358-L390 |
1,286 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_ra | def _read_opt_ra(self, code, *, desc):
"""Read HOPOPT Router Alert option.
Structure of HOPOPT Router Alert option [RFC 2711]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0 0 0|0 0 1 0 1|0 0 0 0 0 0 1 0| Value (2 octets) |
+-+-+-+-... | python | def _read_opt_ra(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
if _size != 2:
raise ProtocolError(f'{self.alias}: [Optno {code}] invalid format')
_rval = self._read_unpack(2)
if 4 <= _rval <= 35:
_dscp = f'Aggregated... | [
"def",
"_read_opt_ra",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"_size",
"!=",
"2",
":",
"raise",
"Prot... | Read HOPOPT Router Alert option.
Structure of HOPOPT Router Alert option [RFC 2711]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0 0 0|0 0 1 0 1|0 0 0 0 0 0 1 0| Value (2 octets) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HOPOPT",
"Router",
"Alert",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L392-L432 |
1,287 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_calipso | def _read_opt_calipso(self, code, *, desc):
"""Read HOPOPT CALIPSO option.
Structure of HOPOPT CALIPSO option [RFC 5570]:
------------------------------------------------------------
| Next Header | Hdr Ext Len | Option Type | Option Length|
+-------------+--------... | python | def _read_opt_calipso(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
if _size < 8 and _size % 8 != 0:
raise ProtocolError(f'{self.alias}: [Optno {code}] invalid format')
_cmpt = self._read_unpack(4)
_clen = self._read_unpack(1)
... | [
"def",
"_read_opt_calipso",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"_size",
"<",
"8",
"and",
"_size",
... | Read HOPOPT CALIPSO option.
Structure of HOPOPT CALIPSO option [RFC 5570]:
------------------------------------------------------------
| Next Header | Hdr Ext Len | Option Type | Option Length|
+-------------+---------------+-------------+--------------+
| ... | [
"Read",
"HOPOPT",
"CALIPSO",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L434-L492 |
1,288 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_smf_dpd | def _read_opt_smf_dpd(self, code, *, desc):
"""Read HOPOPT SMF_DPD option.
Structure of HOPOPT SMF_DPD option [RFC 5570]:
* IPv6 SMF_DPD Option Header in I-DPD mode
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 ... | python | def _read_opt_smf_dpd(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
_tidd = self._read_binary(1)
if _tidd[0] == '0':
_mode = 'I-DPD'
_tidt = _TID_TYPE.get(_tidd[1:4], 'Unassigned')
_tidl = int(_tidd[4:], base=2)
... | [
"def",
"_read_opt_smf_dpd",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"_tidd",
"=",
"self",
".",
"_read_binary",
... | Read HOPOPT SMF_DPD option.
Structure of HOPOPT SMF_DPD option [RFC 5570]:
* IPv6 SMF_DPD Option Header in I-DPD mode
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
+-+-+... | [
"Read",
"HOPOPT",
"SMF_DPD",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L494-L622 |
1,289 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_pdm | def _read_opt_pdm(self, code, *, desc):
"""Read HOPOPT PDM option.
Structure of HOPOPT PDM option [RFC 8250]:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+... | python | def _read_opt_pdm(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
if _size != 10:
raise ProtocolError(f'{self.alias}: [Optno {code}] invalid format')
_stlr = self._read_unpack(1)
_stls = self._read_unpack(1)
_psnt = self._r... | [
"def",
"_read_opt_pdm",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"_size",
"!=",
"10",
":",
"raise",
"Pr... | Read HOPOPT PDM option.
Structure of HOPOPT PDM option [RFC 8250]:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... | [
"Read",
"HOPOPT",
"PDM",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L624-L675 |
1,290 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_qs | def _read_opt_qs(self, code, *, desc):
"""Read HOPOPT Quick Start option.
Structure of HOPOPT Quick-Start option [RFC 4782]:
* A Quick-Start Request.
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... | python | def _read_opt_qs(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
if _size != 6:
raise ProtocolError(f'{self.alias}: [Optno {code}] invalid format')
_fcrr = self._read_binary(1)
_func = int(_fcrr[:4], base=2)
_rate = int(_f... | [
"def",
"_read_opt_qs",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"_size",
"!=",
"6",
":",
"raise",
"Prot... | Read HOPOPT Quick Start option.
Structure of HOPOPT Quick-Start option [RFC 4782]:
* A Quick-Start Request.
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
+-+-+-+-+-+-+-+... | [
"Read",
"HOPOPT",
"Quick",
"Start",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L677-L737 |
1,291 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_rpl | def _read_opt_rpl(self, code, *, desc):
"""Read HOPOPT RPL option.
Structure of HOPOPT RPL option [RFC 6553]:
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
... | python | def _read_opt_rpl(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
if _size < 4:
raise ProtocolError(f'{self.alias}: [Optno {code}] invalid format')
_flag = self._read_binary(1)
_rpld = self._read_unpack(1)
_rank = self._rea... | [
"def",
"_read_opt_rpl",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"_size",
"<",
"4",
":",
"raise",
"Prot... | Read HOPOPT RPL option.
Structure of HOPOPT RPL option [RFC 6553]:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HOPOPT",
"RPL",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L739-L792 |
1,292 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_ilnp | def _read_opt_ilnp(self, code, *, desc):
"""Read HOPOPT ILNP Nonce option.
Structure of HOPOPT ILNP Nonce option [RFC 6744]:
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
+-+-+-+-+-+-+-... | python | def _read_opt_ilnp(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
_nval = self._read_fileng(_size)
opt = dict(
desc=desc,
type=_type,
length=_size + 2,
value=_nval,
)
return opt | [
"def",
"_read_opt_ilnp",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"_nval",
"=",
"self",
".",
"_read_fileng",
"(... | Read HOPOPT ILNP Nonce option.
Structure of HOPOPT ILNP Nonce option [RFC 6744]:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HOPOPT",
"ILNP",
"Nonce",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L865-L897 |
1,293 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_lio | def _read_opt_lio(self, code, *, desc):
"""Read HOPOPT Line-Identification option.
Structure of HOPOPT Line-Identification option [RFC 6788]:
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
... | python | def _read_opt_lio(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
_llen = self._read_unpack(1)
_line = self._read_fileng(_llen)
opt = dict(
desc=desc,
type=_type,
length=_size + 2,
lid_len=_llen... | [
"def",
"_read_opt_lio",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"_llen",
"=",
"self",
".",
"_read_unpack",
"("... | Read HOPOPT Line-Identification option.
Structure of HOPOPT Line-Identification option [RFC 6788]:
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
+-+-+-+-+-+-+-+-... | [
"Read",
"HOPOPT",
"Line",
"-",
"Identification",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L899-L938 |
1,294 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_jumbo | def _read_opt_jumbo(self, code, *, desc):
"""Read HOPOPT Jumbo Payload option.
Structure of HOPOPT Jumbo Payload option [RFC 2675]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Option Type | Opt Data Len |
+-+... | python | def _read_opt_jumbo(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
if _size != 4:
raise ProtocolError(f'{self.alias}: [Optno {code}] invalid format')
_jlen = self._read_unpack(4)
opt = dict(
desc=desc,
typ... | [
"def",
"_read_opt_jumbo",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"_size",
"!=",
"4",
":",
"raise",
"P... | Read HOPOPT Jumbo Payload option.
Structure of HOPOPT Jumbo Payload option [RFC 2675]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Option Type | Opt Data Len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HOPOPT",
"Jumbo",
"Payload",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L940-L972 |
1,295 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_home | def _read_opt_home(self, code, *, desc):
"""Read HOPOPT Home Address option.
Structure of HOPOPT Home Address option [RFC 6275]:
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
... | python | def _read_opt_home(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
if _size != 16:
raise ProtocolError(f'{self.alias}: [Optno {code}] invalid format')
_addr = self._read_fileng(16)
opt = dict(
desc=desc,
ty... | [
"def",
"_read_opt_home",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"_size",
"!=",
"16",
":",
"raise",
"P... | Read HOPOPT Home Address option.
Structure of HOPOPT Home Address option [RFC 6275]:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-... | [
"Read",
"HOPOPT",
"Home",
"Address",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L974-L1014 |
1,296 | JarryShaw/PyPCAPKit | src/protocols/internet/hopopt.py | HOPOPT._read_opt_ip_dff | def _read_opt_ip_dff(self, code, *, desc):
"""Read HOPOPT IP_DFF option.
Structure of HOPOPT IP_DFF option [RFC 6971]:
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
+-+-+-+-+-+-+-+-+-+-... | python | def _read_opt_ip_dff(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
if _size != 2:
raise ProtocolError(f'{self.alias}: [Optno {code}] invalid format')
_verf = self._read_binary(1)
_seqn = self._read_unpack(2)
opt = dict(
... | [
"def",
"_read_opt_ip_dff",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"if",
"_size",
"!=",
"2",
":",
"raise",
"... | Read HOPOPT IP_DFF option.
Structure of HOPOPT IP_DFF option [RFC 6971]:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | [
"Read",
"HOPOPT",
"IP_DFF",
"option",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L1016-L1061 |
1,297 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv6_opts.py | IPv6_Opts.read_ipv6_opts | def read_ipv6_opts(self, length, extension):
"""Read Destination Options for IPv6.
Structure of IPv6-Opts header [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header | Hdr Ext Len | |
+-+-+-+-+-... | python | def read_ipv6_opts(self, length, extension):
if length is None:
length = len(self)
_next = self._read_protos(1)
_hlen = self._read_unpack(1)
# _opts = self._read_fileng(_hlen*8+6)
ipv6_opts = dict(
next=_next,
length=(_hlen + 1) * 8,
... | [
"def",
"read_ipv6_opts",
"(",
"self",
",",
"length",
",",
"extension",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"len",
"(",
"self",
")",
"_next",
"=",
"self",
".",
"_read_protos",
"(",
"1",
")",
"_hlen",
"=",
"self",
".",
"_read_un... | Read Destination Options for IPv6.
Structure of IPv6-Opts header [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header | Hdr Ext Len | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
... | [
"Read",
"Destination",
"Options",
"for",
"IPv6",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv6_opts.py#L152-L194 |
1,298 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv6_opts.py | IPv6_Opts._read_ipv6_opts_options | def _read_ipv6_opts_options(self, length):
"""Read IPv6_Opts options.
Positional arguments:
* length -- int, length of options
Returns:
* dict -- extracted IPv6_Opts options
"""
counter = 0 # length of read options
optkind = list() # ... | python | def _read_ipv6_opts_options(self, length):
counter = 0 # length of read options
optkind = list() # option type list
options = dict() # dict of option data
while counter < length:
# break when eol triggered
code = self._read_unpack(1)
if ... | [
"def",
"_read_ipv6_opts_options",
"(",
"self",
",",
"length",
")",
":",
"counter",
"=",
"0",
"# length of read options",
"optkind",
"=",
"list",
"(",
")",
"# option type list",
"options",
"=",
"dict",
"(",
")",
"# dict of option data",
"while",
"counter",
"<",
"... | Read IPv6_Opts options.
Positional arguments:
* length -- int, length of options
Returns:
* dict -- extracted IPv6_Opts options | [
"Read",
"IPv6_Opts",
"options",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv6_opts.py#L237-L277 |
1,299 | JarryShaw/PyPCAPKit | src/protocols/internet/ipv6_opts.py | IPv6_Opts._read_opt_none | def _read_opt_none(self, code, *, desc):
"""Read IPv6_Opts unassigned options.
Structure of IPv6_Opts unassigned options [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
| Option Type | Opt Data Len | Option Data
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -... | python | def _read_opt_none(self, code, *, desc):
_type = self._read_opt_type(code)
_size = self._read_unpack(1)
_data = self._read_fileng(_size)
opt = dict(
desc=_IPv6_Opts_NULL.get(code, desc),
type=_type,
length=_size + 2,
data=_data,
)
... | [
"def",
"_read_opt_none",
"(",
"self",
",",
"code",
",",
"*",
",",
"desc",
")",
":",
"_type",
"=",
"self",
".",
"_read_opt_type",
"(",
"code",
")",
"_size",
"=",
"self",
".",
"_read_unpack",
"(",
"1",
")",
"_data",
"=",
"self",
".",
"_read_fileng",
"(... | Read IPv6_Opts unassigned options.
Structure of IPv6_Opts unassigned options [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
| Option Type | Opt Data Len | Option Data
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
Octets Bits ... | [
"Read",
"IPv6_Opts",
"unassigned",
"options",
"."
] | c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/ipv6_opts.py#L279-L307 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.