diff --git a/research/tests_common.py b/research/tests_common.py index 22abfb8ef..5c1bf8827 100644 --- a/research/tests_common.py +++ b/research/tests_common.py @@ -14,6 +14,20 @@ class PingTest(Test): self.padding = None if opt == None else opt.padding self.to_self = False if opt == None else opt.to_self + self.parse_meta_actions() + + def parse_meta_actions(self): + # Create list of fragment numbers to be used + self.fragnums = [] + next_fragnum = 0 + for act in self.actions: + if act.is_meta(Action.MetaDrop): + next_fragnum += 1 + elif act.action == Action.Inject: + self.fragnums.append(next_fragnum) + next_fragnum += 1 + self.actions = list(filter(lambda act: not act.is_meta(Action.MetaDrop), self.actions)) + def prepare(self, station): log(STATUS, "Generating ping test", color="green") @@ -29,17 +43,6 @@ class PingTest(Test): # Set A-MSDU flag but include a normal payload (fake A-MSDU) header.Reserved = 1 - # Create list of fragment numbers to be used - fragnums = [] - next_fragnum = 0 - for act in self.actions: - if act.is_meta(Action.MetaDrop): - next_fragnum += 1 - elif act.action == Action.Inject: - fragnums.append(next_fragnum) - next_fragnum += 1 - self.actions = list(filter(lambda act: not act.is_meta(Action.MetaDrop), self.actions)) - # Generate all the individual (fragmented) frames num_frags = len(self.get_actions(Action.Inject)) frames = create_fragments(header, request, num_frags) @@ -55,7 +58,7 @@ class PingTest(Test): frame.addr1 = "ff:ff:ff:ff:ff:ff" # Assign fragment numbers according to MetaDrop rules - frame.SC = (frame.SC & 0xfff0) | fragnums.pop(0) + frame.SC = (frame.SC & 0xfff0) | self.fragnums.pop(0) frag.frame = frame