Lines Matching refs:actstr
288 def parse_attrs(actstr, attr_desc): argument
303 def parse_attr(actstr, key, func): argument
304 actstr = actstr[len(key) :]
307 return None, actstr
309 delim = actstr[0]
310 actstr = actstr[1:]
313 pos = strcspn(actstr, ",)")
314 ret = func(actstr[:pos])
316 ret = func(actstr)
319 (datum, actstr) = ret
322 actstr = actstr[strcspn(actstr, ",)"):]
325 if not actstr or actstr[0] != ")":
328 actstr = actstr[1:]
330 actstr = actstr[strspn(actstr, ", ") :]
332 return datum, actstr
336 while actstr and actstr[0] != ")" and attr_desc:
339 if actstr.startswith(key):
340 datum, actstr = parse_attr(actstr, key, func)
346 raise ValueError("Unknown attribute: '%s'" % actstr)
348 actstr = actstr[strspn(actstr, ", ") :]
350 if actstr[0] != ")":
352 "unbalanced parenthesis: '%s'" % actstr)
354 return attrs, actstr[1:]
416 def parse(self, actstr): argument
423 attrs, actstr = parse_attrs(actstr, desc)
428 return actstr
452 def parse(self, actstr): argument
453 def parse_nested_actions(actstr): argument
455 parsed_len = subacts.parse(actstr)
456 return subacts, actstr[parsed_len :]
466 attrs, actstr = parse_attrs(actstr, desc)
471 return actstr
601 def parse(self, actstr): argument
609 attrs, actstr = parse_attrs(actstr, attrs_desc)
613 return actstr
668 def parse(self, actstr): argument
669 totallen = len(actstr)
670 while len(actstr) != 0:
673 if actstr.startswith("drop"):
677 if actstr.startswith("drop("):
680 actstr, reason = parse_extract_field(
681 actstr,
693 actstr = actstr[len("drop"): ]
694 return (totallen - len(actstr))
696 elif parse_starts_block(actstr, r"^(\d+)", False, True):
697 actstr, output = parse_extract_field(
698 actstr, None, r"(\d+)", lambda x: int(x), False, "0"
702 elif parse_starts_block(actstr, "recirc(", False):
703 actstr, recircid = parse_extract_field(
704 actstr,
723 if parse_starts_block(actstr, flat_act[0], False):
724 actstr = actstr[len(flat_act[0]):]
726 actstr = actstr[strspn(actstr, ", ") :]
729 if parse_starts_block(actstr, "clone(", False):
732 actstr = actstr[len("clone("):]
733 parsedLen = subacts.parse(actstr)
736 actstr = actstr[parsedLen:]
738 elif parse_starts_block(actstr, "set(", False):
741 actstr = actstr[len("set("):]
742 actstr = k.parse(actstr, None)
744 if not actstr.startswith(")"):
745 actstr = ")" + actstr
747 elif parse_starts_block(actstr, "set_masked(", False):
751 actstr = actstr[len("set_masked("):]
752 actstr = k.parse(actstr, m)
754 if not actstr.startswith(")"):
755 actstr = ")" + actstr
757 elif parse_starts_block(actstr, "ct(", False):
759 actstr = actstr[len("ct(") :]
770 if actstr.startswith(scan[0]):
771 actstr = actstr[len(scan[0]) :]
773 if actstr[0] != "=":
775 actstr = actstr[1:]
776 pos = strcspn(actstr, ",)")
777 datum = scan[2](actstr[:pos], 0)
779 actstr = actstr[pos:]
782 actstr = actstr[strspn(actstr, ", ") :]
785 if actstr.startswith("nat"):
786 actstr = actstr[3:]
789 if actstr.startswith("("):
792 actstr = actstr[1:]
793 if actstr.startswith("src"):
795 actstr = actstr[3:]
796 elif actstr.startswith("dst"):
798 actstr = actstr[3:]
800 actstr, ip_block_min = parse_extract_field(
801 actstr, "=", r"([0-9a-fA-F\.]+)", str, False
803 actstr, ip_block_max = parse_extract_field(
804 actstr, "-", r"([0-9a-fA-F\.]+)", str, False
807 actstr, proto_min = parse_extract_field(
808 actstr, ":", r"(\d+)", int, False
810 actstr, proto_max = parse_extract_field(
811 actstr, "-", r"(\d+)", int, False
839 if actstr.startswith(natscan[0]):
840 actstr = actstr[len(natscan[0]) :]
842 actstr = actstr[strspn(actstr, ", ") :]
845 actstr = actstr[strspn(actstr, ", ") :]
850 elif parse_starts_block(actstr, "sample(", False):
852 actstr = sampleact.parse(actstr[len("sample(") : ])
856 elif parse_starts_block(actstr, "psample(", False):
858 actstr = psampleact.parse(actstr[len("psample(") : ])
862 elif parse_starts_block(actstr, "userspace(", False):
864 actstr = uact.parse(actstr[len("userspace(") : ])
868 elif parse_starts_block(actstr, "trunc(", False):
870 actstr, val = parse_extract_field(
871 actstr,
881 actstr = actstr[strspn(actstr, ", ") :]
884 actstr = actstr[strspn(actstr, " "):]
885 if len(actstr) and actstr[0] != ")":
886 raise ValueError("Action str: '%s' unbalanced" % actstr)
887 actstr = actstr[1:]
889 if len(actstr) and actstr[0] == ")":
890 return (totallen - len(actstr))
892 actstr = actstr[strspn(actstr, ", ") :]
895 raise ValueError("Action str: '%s' not supported" % actstr)
897 return (totallen - len(actstr))
2308 def parse(self, flowstr, actstr, dpidx=0): argument
2359 a.parse(actstr)