Skip to content

Commit

Permalink
Ipv6 fragemntation fixed, preparing for Ip6 frag refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ccie18643 committed Jul 7, 2024
1 parent 35ab313 commit 510d9cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pytcp/protocols/ip6_ext_frag/fpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def assemble(self, *, frame: memoryview, pshdr_sum: int = 0) -> None:
f"! BBH L {self._dlen}s",
frame,
0,
self._next,
int(self._next),
0,
self._offset | self._flag_mf,
self._id,
Expand Down
13 changes: 5 additions & 8 deletions pytcp/protocols/ip6_ext_frag/fpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@
from typing import TYPE_CHECKING

from pytcp.lib.errors import PacketIntegrityError, PacketSanityError
from pytcp.protocols.ip6_ext_frag.ps import (
IP6_EXT_FRAG_HEADER_LEN,
IP6_EXT_FRAG_NEXT_HEADER_TABLE,
)
from pytcp.protocols.ip6.ps import Ip6Next
from pytcp.protocols.ip6_ext_frag.ps import IP6_EXT_FRAG_HEADER_LEN

if TYPE_CHECKING:
from pytcp.lib.packet import PacketRx
Expand Down Expand Up @@ -99,16 +97,15 @@ def __str__(self) -> str:
"""
return (
f"IPv6_FRAG id {self.id}{', MF' if self.flag_mf else ''}, "
f"offset {self.offset}, next {self.next} "
f"({IP6_EXT_FRAG_NEXT_HEADER_TABLE.get(self.next, '???')})"
f"offset {self.offset}, next {self.next}"
)

@property
def next(self) -> int:
def next(self) -> Ip6Next:
"""
Read the 'Next' field.
"""
return self._frame[0]
return Ip6Next(self._frame[0])

@property
def offset(self) -> int:
Expand Down
2 changes: 1 addition & 1 deletion pytcp/protocols/ip6_ext_frag/phrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def __defragment_ip6_packet(
)
del self.ip6_frag_flows[flow_id]
struct.pack_into("!H", header, 4, len(data))
header[6] = packet_rx.ip6_ext_frag.next
header[6] = int(packet_rx.ip6_ext_frag.next)
packet_rx = PacketRx(bytes(header) + data)
__debug__ and log(
"ip6",
Expand Down

0 comments on commit 510d9cd

Please sign in to comment.