예제 #1
0
파일: test_bpdu.py 프로젝트: MrCocoaCat/ryu
    def setUp(self):
        self.protocol_id = bpdu.PROTOCOL_IDENTIFIER
        self.version_id = bpdu.TopologyChangeNotificationBPDUs.VERSION_ID
        self.bpdu_type = bpdu.TopologyChangeNotificationBPDUs.BPDU_TYPE

        self.msg = bpdu.TopologyChangeNotificationBPDUs()

        self.fmt = bpdu.bpdu._PACK_STR
        self.buf = struct.pack(self.fmt, self.protocol_id, self.version_id,
                               self.bpdu_type)
예제 #2
0
    def _generate_tcn_bpdu(self):
        src_mac = self.ofport.hw_addr
        dst_mac = bpdu.BRIDGE_GROUP_ADDRESS
        length = (bpdu.bpdu._PACK_LEN
            + bpdu.TopologyChangeNotificationBPDUs.PACK_LEN
            + llc.llc._PACK_LEN + llc.ControlFormatU._PACK_LEN)
        e = ethernet.ethernet(dst_mac, src_mac, length)
        l = llc.llc(llc.SAP_BPDU, llc.SAP_BPDU, llc.ControlFormatU())
        b = bpdu.TopologyChangeNotificationBPDUs()

        pkt = packet.Packet()
        pkt.add_protocol(e)
        pkt.add_protocol(l)
        pkt.add_protocol(b)
        pkt.serialize()

        return pkt.data