예제 #1
0
    def create_flow_mod(dp, config):
        #
        matches_config = ConfigParser.get_matches(config)
        matches = Matches.create_matches(dp, matches_config)
        #
        instr_config = ConfigParser.get_instr_config(config)
        instructions = Instructions.create_instructions(dp, instr_config)
        #

        mod = dp.ofproto_parser.OFPFlowMod (
            dp,
            cookie = 0,
            cookie_mask = 0,
            table_id = Utils.get_table(config["table"]),
            command = Utils.get_mod_command(dp, config["cmd"]),
            idle_timeout = 0,
            hard_timeout = 0,
            priority = 0,
            buffer_id = 0,
            out_port = Utils.get_mod_port(dp, config["port"]),
            out_group = Utils.get_mod_group(dp, config["group"]),
            flags=0,
            match=matches,
            instructions=instructions
        )
        return mod
예제 #2
0
    def create_buckets(dp, config):
        #
        buckets = []
        #
        # print "@@@@@@@@@@@@@@@@@@@@@@"
        # print "buckets config: %s" % config
        # print "@@@@@@@@@@@@@@@@@@@@@@"
        #
        for entry in config:
            #
            print "entry: %s " % entry

            actions = Actions.create_actions(dp, entry["actions"])

            bucket = dp.ofproto_parser.OFPBucket(
                weight=Utils.to_int(entry["weight"]),
                watch_port=Utils.get_mod_port(dp, entry["watch_port"]),
                watch_group=Utils.get_mod_group(dp, entry["watch_group"]),
                actions=actions
                #entry[]
            )
            print "bucket: %s" % bucket
            buckets.append(bucket)
            print "buckets: %s" % buckets
        return buckets
예제 #3
0
파일: mods.py 프로젝트: zoomis/of-dpa
    def create_flow_mod(dp, config):
        #
        matches_config = ConfigParser.get_matches(config)
        matches = Matches.create_matches(dp, matches_config)
        #
        instr_config = ConfigParser.get_instr_config(config)
        instructions = Instructions.create_instructions(dp, instr_config)
        #

        mod = dp.ofproto_parser.OFPFlowMod(
            dp,
            cookie=0,
            cookie_mask=0,
            table_id=Utils.get_table(config["table"]),
            command=Utils.get_mod_command(dp, config["cmd"]),
            idle_timeout=0,
            hard_timeout=0,
            priority=0,
            buffer_id=0,
            out_port=Utils.get_mod_port(dp, config["port"]),
            out_group=Utils.get_mod_group(dp, config["group"]),
            flags=0,
            match=matches,
            instructions=instructions)
        return mod
예제 #4
0
 def delete_group_mod(dp, config):
     #
     mod = dp.ofproto_parser.OFPGroupMod(
         dp,
         Utils.get_group_mod_command(dp, config["cmd"]),
         Utils.get_mod_type(dp, config["type"]),
         Utils.get_mod_group(dp, config["group_id"])
         )
     return mod
예제 #5
0
파일: mods.py 프로젝트: zoomis/of-dpa
    def create_group_mod(dp, config):
        #
        buckets_config = ConfigParser.get_buckets_config(config)
        buckets = Buckets.create_buckets(dp, buckets_config)
        #

        mod = dp.ofproto_parser.OFPGroupMod(
            dp, Utils.get_mod_command(dp, config["cmd"]),
            Utils.get_mod_type(dp, config["type"]),
            Utils.get_mod_group(dp, config["group_id"]), buckets)
        return mod
예제 #6
0
    def create_group_mod(dp, config):
        #
        buckets_config= ConfigParser.get_buckets_config(config)
        buckets = Buckets.create_buckets(dp, buckets_config)
        #

        mod = dp.ofproto_parser.OFPGroupMod(
            dp,
            Utils.get_mod_command(dp, config["cmd"]),
            Utils.get_mod_type(dp, config["type"]),
            Utils.get_mod_group(dp, config["group_id"]),
            buckets
            )
        return mod
예제 #7
0
 def delete_flow_mod(dp, config):
     #
     mod = dp.ofproto_parser.OFPFlowMod (
         dp,
         cookie = 0,
         cookie_mask = 0,
         table_id = Utils.get_table(config["table"]),
         command = Utils.get_mod_command(dp, config["cmd"]),
         idle_timeout = 0,
         hard_timeout = 0,
         priority = 0,
         buffer_id = 0,
         out_port = Utils.get_mod_port(dp, config["port"]),
         out_group = Utils.get_mod_group(dp, config["group"]),
         flags=0
     )
     return mod
예제 #8
0
파일: buckets.py 프로젝트: jpillora/of-dpa
    def create_buckets(dp, config):
        #
        buckets = []
        #
        print "buckets config: %s" % config
        #
        for entry in config:
            #
            print "entry: %s " % entry

            actions = Actions.create_actions(dp, entry["actions"])

            bucket = dp.ofproto_parser.OFPBucket(
                weight=Utils.to_int(entry["weight"]),
                watch_port=Utils.get_mod_port(dp, entry["watch_port"]),
                watch_group=Utils.get_mod_group(dp, entry["watch_group"]),
                actions=actions
                # entry[]
            )
            print "bucket: %s" % bucket
            buckets.append(bucket)
            print "buckets: %s" % buckets
        return buckets
예제 #9
0
    def add_ofdpa_flow(self, datapath, priority, vlan_vid, dst, out_port):
        #prerequisite
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser
        
        #the group id will be generated by increment
        group_id = generate_group_id()
        
        #vlan table
        match = parser.OFPMatch(in_port=in_port, vlan_vid=vlan_vid)
        type = ofproto.OFPIT_GOTO_TABLE
        inst = [parser.OFPInstructionGotoTable(type, Utils.get_table("TABLE_MAC"))]
        mod = parser.OFPFlowMod(datapath=datapath,
                                cookie = 0,
                                cookie_mask = 0,
                                table_id=Utils.get_table("TABLE_VLAN"),
                                command = Utils.get_mod_command(datapath, "add"),
                                idle_timeout = 0,
                                hard_timeout = 0,
                                priority=priority,
                                buffer_id = 0,
                                match=match,
                                out_port = Utils.get_mod_port(datapath, "any"),
                                out_group = Utils.get_mod_group(datapath, "any"),
                                flags=0,
                                instructions=inst
                                )
        datapath.send_msg(mod)
        
        #bridging table
        match = parser.OFPMatch(eth_dst=dst, vlan_vid=vlan_vid)
        mask = mac.haddr_to_bin("ff:ff:ff:ff:ff:ff")
        match.set_dl_dst_masked(dst,mask)
        actions = [parser.OFPActionGroup(Utils.to_int(group_id))]
        type = ofproto.OFPIT_WRITE_ACTIONS
        inst = [parser.OFPInstructionActions(type, actions)]
        mod = parser.OFPFlowMod(datapath=datapath,
                                cookie = 0,
                                cookie_mask = 0,
                                table_id=Utils.get_table("TABLE_BRIDGING"),
                                command = Utils.get_mod_command(datapath, "add"),
                                idle_timeout = 0,
                                hard_timeout = 0,
                                priority=priority,
                                buffer_id = 0,
                                match=match,
                                out_port = Utils.get_mod_port(datapath, "any"),
                                out_group = Utils.get_mod_group(datapath, "any"),
                                flags=0,
                                instructions=inst
                                )
        datapath.send_msg(mod)
        
        #L2 Group table
        actions = [parser.OFPActionOutput(out_port)]
        buckets = []
        bucket = datapath.ofproto_parser.OFPBucket(
                     weight = Utils.to_int("0"),
                     watch_port = Utils.get_mod_port("any"),
                     watch_group = Utils.get_mod_group("any"),
                     actions = actions
                 )
        buckets.append(bucket)
        print "buckets: %s" % buckets

        mod = datapath.ofproto_parser.OFPGroupMod(
            datapath,
            Utils.get_mod_command(datapath, "add"),
            Utils.get_mod_type(datapath, "indirect"),
            Utils.get_mod_group(datapath, group_id),
            buckets
            )
        datapath.send_msg(mod)