diff --git a/scapy/arch/linux.py b/scapy/arch/linux.py index 76a46fb02254a8d2838c0da55146a9227757e258..2b94cf168c7d802c6282d9d4722038d7987083ed 100644 --- a/scapy/arch/linux.py +++ b/scapy/arch/linux.py @@ -271,11 +271,16 @@ def get_if(iff,cmd): def get_if_index(iff): return int(struct.unpack("I",get_if(iff, SIOCGIFINDEX)[16:20])[0]) -def get_last_packet_timestamp(sock): - ts = ioctl(sock, SIOCGSTAMP, "12345678") - s,us = struct.unpack("II",ts) - return s+us/1000000.0 - +if os.uname()[4] == 'x86_64': + def get_last_packet_timestamp(sock): + ts = ioctl(sock, SIOCGSTAMP, "1234567890123456") + s,us = struct.unpack("QQ",ts) + return s+us/1000000.0 +else: + def get_last_packet_timestamp(sock): + ts = ioctl(sock, SIOCGSTAMP, "12345678") + s,us = struct.unpack("II",ts) + return s+us/1000000.0 def _flush_fd(fd): diff --git a/scapy/fields.py b/scapy/fields.py index a36f9f9fb133b78fae1846f8762d91b2169b9fb8..71b0422ab66143e451bff9d125e45a8658c5d209 100644 --- a/scapy/fields.py +++ b/scapy/fields.py @@ -1,4 +1,4 @@ -# This file is part of Scapy +## This file is part of Scapy ## See http://www.secdev.org/projects/scapy for more informations ## Copyright (C) Philippe Biondi <phil@secdev.org> ## This program is published under a GPLv2 license @@ -459,6 +459,19 @@ class StrFixedLenField(StrField): l = RandNum(0,200) return RandBin(l) +class StrFixedLenEnumField(StrFixedLenField): + def __init__(self, name, default, length=None, enum=None, length_from=None): + StrFixedLenField.__init__(self, name, default, length=length, length_from=length_from) + self.enum = enum + def i2repr(self, pkt, v): + r = v.rstrip("\0") + rr = repr(r) + if v in self.enum: + rr = "%s (%s)" % (rr, self.enum[v]) + elif r in self.enum: + rr = "%s (%s)" % (rr, self.enum[r]) + return rr + class NetBIOSNameField(StrFixedLenField): def __init__(self, name, default, length=31): StrFixedLenField.__init__(self, name, default, length) diff --git a/scapy/packet.py b/scapy/packet.py index 3d1dc5274a9a7b820bc6ed246e7854b0ceb05864..656645c90250e314e4ecd2df475ec7caf10786fa 100644 --- a/scapy/packet.py +++ b/scapy/packet.py @@ -937,7 +937,11 @@ A side effect is that, to obtain "{" and "}" characters, you must use def decode_payload_as(self,cls): """Reassembles the payload and decode it using another packet class""" s = str(self.payload) - self.payload = cls(s) + self.payload = cls(s, _internal=1, _underlayer=self) + pp = self + while pp.underlayer is not None: + pp = pp.underlayer + self.payload.dissection_done(pp) def libnet(self): """Not ready yet. Should give the necessary C code that interfaces with libnet to recreate the packet"""