Esempio n. 1
        def __init__(self, priority, ethertype, protocol, in_port, dl_src, dl_dst, nw_src, nw_dst, tp_dst):
            assert isinstance(priority, int)

            assert ethertype is None or (ethertype >= 0 and ethertype < 65535)
            assert protocol is None or (protocol >= 0 and protocol < 256)
            assert dl_src is None or  is_mac_address(dl_src)
            assert dl_dst is None or is_mac_address(dl_dst)
            assert nw_src is None or is_ip_address(nw_src) or is_ip_subnet(nw_src)
            assert nw_dst is None or is_ip_address(nw_dst) or is_ip_subnet(nw_dst)
            assert in_port is None or isinstance(in_port, str)
            assert tp_dst is None or (isinstance(tp_dst, int) and tp_dst >= 0 and tp_dst < 65536)

            self.priority = priority
            self.ethertype = ethertype
            self.protocol = protocol
            self.dl_src, self.dl_dst = dl_src, dl_dst
            self.nw_src, self.nw_dst = nw_src, nw_dst
            self.in_port = in_port
            self.tp_dst = tp_dst
            self.act_list = []
Esempio n. 2
        def __init__(self, act_enum, new_value):
            assert act_enum == self.ACTION_MOD_DL_DST or self.ACTION_MOD_DL_SRC or \
                    act_enum == self.ACTION_MOD_NW_DST or act_enum == self.ACTION_MOD_NW_SRC
            self.act_enum = act_enum

            if act_enum == self.ACTION_MOD_NW_DST or act_enum == self.ACTION_MOD_NW_SRC:
                assert is_ip_address(new_value) or is_ip_subnet(new_value)
            elif act_enum == self.ACTION_MOD_DL_DST or act_enum == self.ACTION_MOD_DL_SRC:
                assert is_mac_address(new_value)
                raise ValueError("Unusual modification")

            self.new_value = new_value