Skip to content

Commit

Permalink
Refactor Arp header extraction to use int.from_bytes method.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccie18643 committed Jul 15, 2024
1 parent b233aad commit 454ff58
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pytcp/protocols/arp/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ArpHardwareType(ProtoEnum):

@staticmethod
def _extract(frame: bytes) -> int:
return int(struct.unpack("! H", frame[0:2])[0])
return int.from_bytes(frame[0:2])


class ArpProtocolType(ProtoEnum):
Expand All @@ -87,7 +87,7 @@ class ArpProtocolType(ProtoEnum):

@staticmethod
def _extract(frame: bytes) -> int:
return int(struct.unpack("! H", frame[2:4])[0])
return int.from_bytes(frame[2:4])


class ArpHardwareLength(ProtoEnum):
Expand All @@ -99,7 +99,7 @@ class ArpHardwareLength(ProtoEnum):

@staticmethod
def _extract(frame: bytes) -> int:
return int(frame[4])
return int.from_bytes(frame[4:5])


class ArpProtocolLength(ProtoEnum):
Expand All @@ -111,7 +111,7 @@ class ArpProtocolLength(ProtoEnum):

@staticmethod
def _extract(frame: bytes) -> int:
return int(frame[5])
return int.from_bytes(frame[5:6])


class ArpOperation(ProtoEnum):
Expand All @@ -124,7 +124,7 @@ class ArpOperation(ProtoEnum):

@staticmethod
def _extract(frame: bytes) -> int:
return int(struct.unpack("! H", frame[6:8])[0])
return int.from_bytes(frame[6:8])


@dataclass
Expand Down

0 comments on commit 454ff58

Please sign in to comment.