Пример #1
0
    def _mod_flow_termmac(self, msg):
        re_id = msg["re_id"]
        cmd = msg["cmd"]
        for arg in msg["args"]:
            match = pb.TerminationMacFlow.Match(eth_type=arg["eth_type"], eth_dst=arg["eth_dst"])
            flow = pb.TerminationMacFlow(match=match, actions=[], goto_table=arg["goto"])
            mod = pb.FlowMod(cmd=cmd, re_id=re_id, table="TERM_MAC", term_mac=flow)
            evt = fibcevt.EventFIBCFlowMod(mod)

            self.app.send_event_to_observers(evt)
Пример #2
0
    def _mod_flow_unicast(self, msg):
        re_id = msg["re_id"]
        cmd = msg["cmd"]
        for arg in msg["args"]:
            match = pb.UnicastRoutingFlow.Match(ip_dst=arg["dst"], vrf=arg["vrf"])
            flow = pb.UnicastRoutingFlow(match=match,
                                         action=None,
                                         g_type=arg.get("g_type", "UNSPEC"),
                                         g_id=arg.get("g_id", 0))
            mod = pb.FlowMod(cmd=cmd, re_id=re_id, table="UNICAST_ROUTING", unicast=flow)
            evt = fibcevt.EventFIBCFlowMod(mod)

            self.app.send_event_to_observers(evt)
Пример #3
0
    def _mod_flow_acl(self, msg):
        re_id = msg["re_id"]
        cmd = msg["cmd"]
        for arg in msg["args"]:
            match = pb.PolicyACLFlow.Match(ip_dst=arg["dst"],
                                           vrf=arg.get("vrf", 0))
            action = pb.PolicyACLFlow.Action(name="OUTPUT", value=0)
            flow = pb.PolicyACLFlow(match=match, action=action)
            mod = pb.FlowMod(cmd=cmd,
                             re_id=re_id,
                             table="POLICY_ACL",
                             acl=flow)
            evt = fibcevt.EventFIBCFlowMod(mod)

            self.app.send_event_to_observers(evt)
Пример #4
0
    def _mod_flow_mpls1(self, msg):
        re_id = msg["re_id"]
        cmd = msg["cmd"]
        for arg in msg["args"]:
            match = pb.MPLSFlow.Match(bos=arg["bos"], label=arg["label"])
            actions = []
            for name in ("SET_VRF", "POP_LABEL"):
                if name in arg:
                    actions.append(pb.MPLSFlow.Action(name=name, value=arg[name]))
            flow = pb.MPLSFlow(match=match,
                               actions=actions,
                               g_type=arg.get("g_type", "UNSPEC"),
                               g_id=arg.get("g_id", 0),
                               goto_table=arg["goto"])
            mod = pb.FlowMod(cmd=cmd, re_id=re_id, table="MPLS1", mpls1=flow)
            evt = fibcevt.EventFIBCFlowMod(mod)

            self.app.send_event_to_observers(evt)
Пример #5
0
    def _mod_flow_vlan(self, msg):
        re_id = msg["re_id"]
        cmd = msg["cmd"]
        for arg in msg["args"]:
            match = pb.VLANFlow.Match(in_port=arg["port"],
                                      vid=arg.get("vid", 0),
                                      vid_mask=arg.get("mask", 0))

            actions = []
            if arg["vrf"] != 0:
                actions.append(pb.VLANFlow.Action(name="SET_VRF", value=arg["vrf"]))
            if "new_vid" in arg:
                actions.append(pb.VLANFlow.Action(name="PUSH_VLAN", value=arg["new_vid"]))

            flow = pb.VLANFlow(match=match, actions=actions, goto_table=20)
            mod = pb.FlowMod(cmd=cmd, re_id=re_id, table="VLAN", vlan=flow)
            evt = fibcevt.EventFIBCFlowMod(mod)

            self.app.send_event_to_observers(evt)
Пример #6
0
    def dispatch(self, hdr, data):
        """
        Dispatch mmessage.
        """
        mtype = hdr[0]
        if mtype == pb.PORT_CONFIG:
            port_conf = fibcapi.parse_port_config(data)
            port_conf_evt = fibcevt.EventFIBCPortConfig(port_conf)
            self._send_evt(port_conf_evt)

        elif mtype == pb.FLOW_MOD:
            flow_mod = fibcapi.parse_flow_mod(data)
            flow_mod_evt = fibcevt.EventFIBCFlowMod(flow_mod)
            self._send_evt(flow_mod_evt)

        elif mtype == pb.GROUP_MOD:
            group_mod = fibcapi.parse_group_mod(data)
            group_mod_evt = fibcevt.EventFIBCGroupMod(group_mod)
            self._send_evt(group_mod_evt)

        else:
            _LOG.warn("Unknown message %s", hdr)
            if fibclog.dump_msg():
                _LOG.debug("%s", data)