We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get wrong info when I used the code with the Class 'Event' on Linux.
I changed the Class Event to: (ntohl) import socket
class SfTimeval32(object): _PACK_STR = '!II' _SIZE = 8
def __init__(self, tv_sec, tv_usec): self.tv_sec = socket.ntohl(tv_sec) self.tv_usec = socket.ntohl(tv_usec)
class Event(object): _PACK_STR = '!IIIIIII' _SIZE = 36
def __init__(self, sig_generator, sig_id, sig_rev, classification, priority, event_id, event_reference, ref_time): self.sig_generator = socket.ntohl(sig_generator) self.sig_id = socket.ntohl(sig_id) self.sig_rev = socket.ntohl(sig_rev) self.classification = socket.ntohl(classification) self.priority = socket.ntohl(priority) self.event_id = socket.ntohl(event_id) self.event_reference = socket.ntohl(event_reference) self.ref_time = ref_time @classmethod def parser(cls, buf, offset): """ :param buf: :param offset: :return: """ (sig_generator, sig_id, sig_rev, classification, priority, event_id, event_reference) = struct.unpack_from( cls._PACK_STR, buf, offset) offset += calcsize(cls._PACK_STR) # removing 1 to offset to avoid crash because the buffer is smaller ref_time = SfTimeval32.parser(buf, offset**-1**) msg = cls(sig_generator, sig_id, sig_rev, classification, priority, event_id, event_reference, ref_time) return msg
class PcapPktHdr32(object): """ Class PcapPktHdr32 """ _PACK_STR = '!II' _SIZE = 16
def __init__(self, ts, caplen, len_): self.ts = ts self.caplen = socket.ntohl(caplen) self.len = socket.ntohl(len_)
In class AlertPkt(object):
@classmethod def parser(cls, buf): """ :param buf: :return: """ alertmsg = struct.unpack_from(cls._ALERTMSG_PACK_STR, buf) offset = calcsize(cls._ALERTMSG_PACK_STR) pkth = PcapPktHdr32.parser(buf, offset) offset += PcapPktHdr32._SIZE (dlthdr, nethdr, transhdr, data, val, pkt) = \ struct.unpack_from(cls._ALERTPKT_PART_PACK_STR, buf, offset) offset += calcsize(cls._ALERTPKT_PART_PACK_STR) # Adding 1 to offset to get good event values. Some problem in c++ perhaps event = Event.parser(buf, offset**+1**)
The text was updated successfully, but these errors were encountered:
My response to another reported issue (#4) might be relevant here.
Sorry, something went wrong.
Changing the time decoding from big endian to little endian solves my problem.
No branches or pull requests
I get wrong info when I used the code with the Class 'Event' on Linux.
I changed the Class Event to: (ntohl)
import socket
class SfTimeval32(object):
_PACK_STR = '!II'
_SIZE = 8
class Event(object):
_PACK_STR = '!IIIIIII'
_SIZE = 36
class PcapPktHdr32(object):
"""
Class PcapPktHdr32
"""
_PACK_STR = '!II'
_SIZE = 16
In
class AlertPkt(object):
The text was updated successfully, but these errors were encountered: