Beispiel #1
0
    def get_packet_out(self, set_unbuffered=False):
        """Function to return flow_entry in terms of packet out

        @param set_unbuffered set packet out to for unbuffered packet
        @return ofp_packet_out
        """
        po = pyof.ofp_packet_out()
        if set_unbuffered:
            po.buffer_id = UNBUFFERED_ID
        else:
            po.buffer_id = self.buffer_id
        po.in_port = self.match.in_port
        po.actions_len = 0
        for a in self.actions:
            po.actions_len += a.len
        po.actions = self.actions[:]

        return po
Beispiel #2
0
    def __init__(self, server, ofconn,
                 sendinterval=10, linktimeout=30):
        """Initialize

        @param server yapc core
        """
        if (sendinterval > linktimeout):
            output.warn("Probe interval of "+str(sendinterval)+\
                        "is smaller than timeout of "+str(linktimeout),
                        self.__class__.__name__)
        ##Interval to send LLDP per switch/port
        self.interval = sendinterval
        self.__minterval = sendinterval
        ##Time to wait before timing out link
        self.link_maintain = link_maintain(server, linktimeout)
        ##Reference to core
        self.server = server
        ##Reference to OpenFlow connections
        self.conn = ofconn
        ##Current list of switch/port LLDP is sent
        self.__sw_port = []
        ##Packet out template
        self.__po = pyof.ofp_packet_out()
        oao = pyof.ofp_action_output()
        self.__po.in_port = pyof.OFPP_NONE
        self.__po.actions_len = oao.len
        self.__po.actions.append(oao)

        mc.get_client()

        server.register_event_handler(ofevents.pktin.name,
                                      self)
        server.register_event_handler(ofevents.port_status.name,
                                      self)
        server.register_event_handler(ofevents.features_reply.name,
                                      self)
        server.post_event(yapc.priv_callback(self, True),
                          self.interval)