Commit f8058288 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Device component - Ryu Driver:

- Fixed composition of add/del flow rule.
parent 58cef5a3
Loading
Loading
Loading
Loading
+18 −19
Original line number Diff line number Diff line
@@ -143,19 +143,20 @@ class RyuApiClient:
        return result

    def add_flow_rule(
        self, dpid : int, in_port : int, out_port : int,
        eth_type : int, ip_src_addr : str, ip_dst_addr : str,
        self, dpid : int, in_port : Optional[int], out_port : int,
        eth_type : Optional[int], ip_src_addr : Optional[str], ip_dst_addr : Optional[str],
        priority : int = 65535,
    ) -> Union[bool, Exception]:
        match = dict()
        if in_port     is not None: match['in_port' ] = in_port
        if eth_type    is not None: match['eth_type'] = eth_type
        if ip_src_addr is not None: match['ipv4_src'] = ip_src_addr
        if ip_dst_addr is not None: match['ipv4_dst'] = ip_dst_addr

        flow_entry = {
            "dpid"    : dpid,
            "priority": priority,
            "match"   : {
                "in_port" : in_port,
                "eth_type": eth_type,
                "ipv4_src": ip_src_addr,
                "ipv4_dst": ip_dst_addr,
            },
            "match"   : match,
            "instructions": [
                {
                    "type": "APPLY_ACTIONS",
@@ -191,22 +192,20 @@ class RyuApiClient:


    def del_flow_rule(
        self, dpid : int, in_port : int, out_port : int,
        eth_type : int, ip_src_addr : str, ip_dst_addr : str,
        self, dpid : int, in_port : Optional[int], out_port : int,
        eth_type : Optional[int], ip_src_addr : Optional[str], ip_dst_addr : Optional[str],
        priority : int = 65535,
    ) -> Union[bool, Exception]:
        match = dict(table_id=0, cookie=0, cookie_mask=0)
        if in_port     is not None: match['in_port' ] = in_port
        if eth_type    is not None: match['eth_type'] = eth_type
        if ip_src_addr is not None: match['ipv4_src'] = ip_src_addr
        if ip_dst_addr is not None: match['ipv4_dst'] = ip_dst_addr

        flow_entry = {
            "dpid"    : dpid,
            "priority": priority,
            "match"   : {
                "in_port" : in_port,
                "eth_type": eth_type,
                "ipv4_src": ip_src_addr,
                "ipv4_dst": ip_dst_addr,
                "table_id"   : 0,
                "cookie"     : 0,
                "cookie_mask": 0,
            },
            "match"   : match,
            "instructions": [
                {
                    "type": "APPLY_ACTIONS",