Skip to content
Extraits de code Groupes Projets
Valider 274de259 rédigé par François De Keersmaeker's avatar François De Keersmaeker
Parcourir les fichiers

Keep old timestamp when rebuilding packet

parent d76d9a38
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -187,9 +187,11 @@ class Packet: ...@@ -187,9 +187,11 @@ class Packet:
def rebuild(self) -> None: def rebuild(self) -> None:
""" """
Rebuild packet. Rebuild packet, but keep old timestamp.
""" """
timestamp = self.packet.time
self.packet = self.packet.__class__(bytes(self.packet)) self.packet = self.packet.__class__(bytes(self.packet))
self.packet.time = timestamp
def update_checksums(self) -> None: def update_checksums(self) -> None:
...@@ -302,7 +304,7 @@ class Packet: ...@@ -302,7 +304,7 @@ class Packet:
# Set new value for field # Set new value for field
self.layer.setfieldval(field, new_value) self.layer.setfieldval(field, new_value)
# Update checksums, if needed # Update checksums
self.update_checksums() self.update_checksums()
# Return value: dictionary containing tweak information # Return value: dictionary containing tweak information
......
...@@ -47,12 +47,16 @@ def must_edit_packet(i: int, packet_numbers: list, random_range: int) -> bool: ...@@ -47,12 +47,16 @@ def must_edit_packet(i: int, packet_numbers: list, random_range: int) -> bool:
def rebuild_packet(packet: scapy.Packet) -> scapy.Packet: def rebuild_packet(packet: scapy.Packet) -> scapy.Packet:
""" """
Rebuild a Scapy packet from its bytes representation. Rebuild a Scapy packet from its bytes representation,
but keep its old timestamp.
:param packet: Scapy packet :param packet: Scapy packet
:return: Rebuilt Scapy packet :return: Rebuilt Scapy packet, with old timestamp
""" """
return packet.__class__(bytes(packet)) timestamp = packet.time
new_packet = packet.__class__(bytes(packet))
new_packet.time = timestamp
return new_packet
def tweak_pcaps(pcaps: list, output: str, random_range: int = 1, packet_numbers: list = None, dry_run: bool = False) -> None: def tweak_pcaps(pcaps: list, output: str, random_range: int = 1, packet_numbers: list = None, dry_run: bool = False) -> None:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter