parent
32b28e3ae2
commit
84b41342da
|
@ -173,6 +173,39 @@ class TestAddRule(BaseTest):
|
||||||
},
|
},
|
||||||
id="test_comment",
|
id="test_comment",
|
||||||
),
|
),
|
||||||
|
pytest.param(
|
||||||
|
{
|
||||||
|
"in": "add tcp-setmss 123 ip from any to 1.2.3.4",
|
||||||
|
"out": {
|
||||||
|
"objs": [
|
||||||
|
NTlv(IpFwTlvType.IPFW_TLV_EACTION, idx=1, name="tcp-setmss"),
|
||||||
|
],
|
||||||
|
"insns": [
|
||||||
|
InsnIp(IpFwOpcode.O_IP_DST, ip="1.2.3.4"),
|
||||||
|
Insn(IpFwOpcode.O_EXTERNAL_ACTION, arg1=1),
|
||||||
|
Insn(IpFwOpcode.O_EXTERNAL_DATA, arg1=123),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
id="test_eaction_tcp-setmss",
|
||||||
|
),
|
||||||
|
pytest.param(
|
||||||
|
{
|
||||||
|
"in": "add eaction ntpv6 AAA ip from any to 1.2.3.4",
|
||||||
|
"out": {
|
||||||
|
"objs": [
|
||||||
|
NTlv(IpFwTlvType.IPFW_TLV_EACTION, idx=1, name="ntpv6"),
|
||||||
|
NTlv(0, idx=2, name="AAA"),
|
||||||
|
],
|
||||||
|
"insns": [
|
||||||
|
InsnIp(IpFwOpcode.O_IP_DST, ip="1.2.3.4"),
|
||||||
|
Insn(IpFwOpcode.O_EXTERNAL_ACTION, arg1=1),
|
||||||
|
Insn(IpFwOpcode.O_EXTERNAL_INSTANCE, arg1=2),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
id="test_eaction_ntp",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_add_rule(self, rule):
|
def test_add_rule(self, rule):
|
||||||
|
|
|
@ -90,6 +90,11 @@ class BaseTlv(object):
|
||||||
for obj in self.obj_list:
|
for obj in self.obj_list:
|
||||||
obj.print_obj(prepend)
|
obj.print_obj(prepend)
|
||||||
|
|
||||||
|
def print_obj_hex(self, prepend=""):
|
||||||
|
print(prepend)
|
||||||
|
print()
|
||||||
|
print(" ".join(["x{:02X}".format(b) for b in bytes(self)]))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _validate(cls, data):
|
def _validate(cls, data):
|
||||||
if len(data) < sizeof(IpFwObjTlv):
|
if len(data) < sizeof(IpFwObjTlv):
|
||||||
|
@ -487,6 +492,7 @@ rule_attrs = prepare_attrs_map(
|
||||||
[
|
[
|
||||||
AttrDescr(IpFwTlvType.IPFW_TLV_TBL_NAME, NTlv),
|
AttrDescr(IpFwTlvType.IPFW_TLV_TBL_NAME, NTlv),
|
||||||
AttrDescr(IpFwTlvType.IPFW_TLV_STATE_NAME, NTlv),
|
AttrDescr(IpFwTlvType.IPFW_TLV_STATE_NAME, NTlv),
|
||||||
|
AttrDescr(IpFwTlvType.IPFW_TLV_EACTION, NTlv),
|
||||||
],
|
],
|
||||||
True,
|
True,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue