Exemple #1
0
    def __init__(self, sock, msg, stats_reply=None, reply=None):
        """Initialize

        @param sock reference to socket
        @param msg message
        """
        ofcomm.message.__init__(self, sock, msg)

        ##Stats reply header
        self.stats_reply = stats_reply
        
        remaining = reply
        if (self.stats_reply == None) or (remaining == None):
            self.stats_reply = pyof.ofp_stats_reply()
            remaining = self.stats_reply.unpack(msg)
        
        ##Flow stats of individual flows
        self.flows = []
        while (len(remaining) >= pyof.OFP_FLOW_STATS_BYTES):
            flow = pyof.ofp_flow_stats()
            flow.unpack(remaining)
            self.unpack_actions(remaining[pyof.OFP_FLOW_STATS_BYTES:flow.length], flow.actions)
            remaining = remaining[flow.length:]
            self.flows.append(flow)

        if (len(remaining) > 0):
            output.warn("Flow stats reply is of irregular length with "+\
                            str(len(remaining))+" bytes remaining.",
                        self.__class__.__name__)
        output.vdbg("Received "+str(len(self.flows))+" flow stats.",
                   self.__class__.__name__)
Exemple #2
0
 def handle_stats_reply(self, event):
     """Handle stats reply
     """
     stats_reply = pyof.ofp_stats_reply()
     reply = stats_reply.unpack(event.message)
     if (stats_reply.type == pyof.OFPST_FLOW):
         self.scheduler.post_event(flow_stats(event.sock,
                                              event.message,
                                              stats_reply, reply))