Пример #1
0
    def send_flowmod(self, flowlist):
        self.logger.debug("")

        flowmod = dispatch(
            type_=const.CON_FLOW_MOD, datapathid=None, data=flowlist)
        self.logger.debug("flowmod[data] : %s", str(flowmod["data"]))
        self.send_packet_to_ryu(flowmod)
Пример #2
0
    def send_packetout(self, report_info, vid, datapathid, port):
        self.logger.debug("")

        mld = self.create_mldreport(report_info)

        # packetのsrcはMLD処理部のものを使用する
        sendpkt = self.create_packet(vid, mld)
        # エッジスイッチにp-out
        pout = self.create_packetout(
            datapathid=datapathid, port=port, packet=sendpkt)
        packetout = dispatch(
            type_=const.CON_PACKET_OUT, datapathid=datapathid, data=pout)
        self.logger.debug("packetout: %s", str(packetout))
        self.send_packet_to_ryu(packetout)
Пример #3
0
    def _main_dispacher_handler(self, ev):
        self.logger.debug("")

        try:
            datapath = ev.datapath
            self.logger.info("OFPStateChange(MAIN).[ver]:%s [dpid]:%s ",
                             datapath.ofproto.OFP_VERSION, datapath.id)

            dispatch_ = dispatch(type_=const.CON_MAIN_DISPATCHER,
                                 datapathid=datapath.id)

            self.logger.debug("dispatch[type_]:%s", const.CON_MAIN_DISPATCHER)
            self.logger.debug("dispatch[datapathid]:%s", datapath.id)

            self.send_to_mld(dispatch_)

        except:
            self.logger.error("%s ", traceback.print_exc())
Пример #4
0
    def _packet_in_handler(self, ev):
        self.logger.debug("")
        try:
            msg = ev.msg
            pkt = packet.Packet(msg.data)

            self.logger.info("OFPPacketIn.[ver]:%s [dpid]:%s [xid]:%s",
                             msg.version, msg.datapath.id, msg.xid)
            self.logger.debug("OFPPacketIn.[data]:%s", str(pkt))

            # CHECK VLAN
            pkt_vlan = None
            if CHECK_VLAN_FLG:
                pkt_vlan = pkt.get_protocol(vlan.vlan)
                if not pkt_vlan:
                    self.logger.debug("check vlan:None \n")
                    return False

            # CHECK ICMPV6
            pkt_icmpv6 = pkt.get_protocol(icmpv6.icmpv6)
            if not pkt_icmpv6:
                self.logger.debug("check icmpv6:None \n")
                return False

            # CHECK MLD TYPE
            if pkt_icmpv6.type_ not in [icmpv6.MLDV2_LISTENER_REPORT,
                                        icmpv6.MLD_LISTENER_QUERY]:
                self.logger.debug("check icmpv6.TYPE:%s \n",
                                  str(pkt_icmpv6.type_))
                return False

            # CHECK FILTER_MODE
            if pkt_icmpv6.type_ in [icmpv6.MLDV2_LISTENER_REPORT]:

                if pkt_icmpv6.data.record_num == 0:
                    self.logger.debug("check data.record_num:%s \n",
                                      str(pkt_icmpv6.data.record_num))
                    return False

                for mldv2_report_group in pkt_icmpv6.data.records:

                    if mldv2_report_group.type_ \
                        not in [icmpv6.MODE_IS_INCLUDE,
                                icmpv6.CHANGE_TO_INCLUDE_MODE,
                                icmpv6.ALLOW_NEW_SOURCES,
                                icmpv6.BLOCK_OLD_SOURCES]:
                        self.logger.debug("check report_group.[type_]:%s \n",
                                          str(mldv2_report_group.type_))

            # CHECK_VLAN_ID
            vid = pkt_vlan.vid if pkt_vlan else 0

            # SET dispatch
            dispatch_ = dispatch(type_=const.CON_PACKET_IN,
                                 datapathid=msg.datapath.id,
                                 cid=vid,
                                 in_port=msg.match[const.DISP_IN_PORT],
                                 data=pkt_icmpv6)

            self.logger.debug("dispatch [type_]:%s", const.CON_PACKET_IN)
            self.logger.debug("dispatch [datapathid]:%s", msg.datapath.id)
            self.logger.debug("dispatch [cid]:%s", str(vid))
            self.logger.debug("dispatch [in_port]:%s",
                              msg.match[const.DISP_IN_PORT])
            self.logger.debug("dispatch [data]:%s", pkt_icmpv6)

            self.send_to_mld(dispatch_)

        except:
            self.logger.error("%s ", traceback.print_exc())