Debian Codegraph @

stetl/filters/packetbuffer.py

raw
1 # Packet buffering.
2 #
3 # Author:Just van den Broecke
4
5 import copy
6 from stetl.util import Util
7 from stetl.filter import Filter
8 from stetl.packet import FORMAT
9
10 log = Util.get_log("packetbuffer")
11
12
13 class PacketBuffer(Filter):
14 """
15 Buffers all incoming Packets, main use is unit-testing to inspect Packets after ETL is done.
16 """
17
18 # Constructor
19 def __init__(self, configdict, section):
20 Filter.__init__(self, configdict, section, consumes=FORMAT.any, produces=FORMAT.any)
21 self.packet_list = []
22
23 def invoke(self, packet):
24 # Buffer Packet and pass-through, we need a deep copy as Packets may be cleared/reused
25 self.packet_list.append(copy.copy(packet))
26 return packet