MCPcopy Create free account
hub / github.com/secdev/scapy / i2m

Method i2m

scapy/fields.py:1939–1956  ·  view source on GitHub ↗
(self, pkt, y)

Source from the content-addressed store, hash-verified

1937 return x
1938
1939 def i2m(self, pkt, y):
1940 # type: (Optional[Packet], Optional[bytes]) -> bytes
1941 if pkt:
1942 len_pkt = self.length_from(pkt) // 2
1943 else:
1944 len_pkt = 0
1945 x = bytes_encode(y or b"") # type: bytes
1946 x += b" " * len_pkt
1947 x = x[:len_pkt]
1948 x = b"".join(
1949 struct.pack(
1950 "!BB",
1951 0x41 + (b >> 4),
1952 0x41 + (b & 0xf),
1953 )
1954 for b in x
1955 )
1956 return b" " + x
1957
1958 def m2i(self, pkt, x):
1959 # type: (Optional[Packet], bytes) -> bytes

Callers

nothing calls this directly

Calls 3

bytes_encodeFunction · 0.90
joinMethod · 0.80
length_fromMethod · 0.45

Tested by

no test coverage detected