Exemple #1
0
    def _producer_threadproc(self):
        while core.running:
            data = self.tx_q.get()
            if data is None:
                # Signal to quit
                break
            (in_port, packet_data) = data

            if self.policy:
                state = self.policy.get()

                if state.header[Field('DRP')].value == 1:
                    pass
                elif state.header[Field('CTR')].value == 1:
                    reason = (str(state.reason.reason), str(state.reason.description))
                    data = {'type': 'in', 'operation': 'packet-in',
                            'data': (in_port, packet_data, reason)}
                    self._tx_vendor(of.ofp_vendor_generic(data=str(data)))
                else:
                    out_ports = bitmap_to_ports(state.header[Field('outport_bitmap')].value)
                    packet_data = state.packet.bytes

                    for out_port in out_ports:
                        self.tx_packet(packet_data, out_port)
            else:
                continue
Exemple #2
0
    def _producer_threadproc(self):
        while core.running:
            data = self.tx_q.get()
            if data is None:
                # Signal to quit
                break
            (in_port, packet_data) = data

            if self.policy:
                state = self.policy.get()

                if state.header[Field('DRP')].value == 1:
                    pass
                elif state.header[Field('CTR')].value == 1:
                    reason = (str(state.reason.reason), str(state.reason.description))
                    data = {'type': 'in', 'operation': 'packet-in',
                            'data': (in_port, packet_data, reason)}
                    self._tx_vendor(of.ofp_vendor_generic(data=str(data)))
                else:
                    out_ports = bitmap_to_ports(state.header[Field('outport_bitmap')].value)
                    packet_data = state.packet.bytes

                    for out_port in out_ports:
                        self.tx_packet(packet_data, out_port)
            else:
                continue
Exemple #3
0
    def _handle_query_message(self, message, connection):
        if message['operation'] == 'query-table-entry':
            t_name = message['data'][0]
            t_index = message['data'][1]

            if self.policy:
                t_id = TableId(t_name)
                t_entry = self.policy.query_table_entry(t_id, t_index)

                data = {'type': 'in', 'operation': 'query-table-entry',
                        'data': (t_name, t_index, t_entry)}
                self._tx_vendor(of.ofp_vendor_generic(data=str(data)))
        elif message['operation'] == 'query-table-list':
            if self.policy:
                t_list = self.policy.query_table_list()

                data = {'type': 'in', 'operation': 'query-table-list',
                        'data': t_list}
                self._tx_vendor(of.ofp_vendor_generic(data=str(data)))
        else:
            raise RuntimeError("Invalid message from the controller")
Exemple #4
0
    def _handle_query_message(self, message, connection):
        if message['operation'] == 'query-table-entry':
            t_name = message['data'][0]
            t_index = message['data'][1]

            if self.policy:
                t_id = TableId(t_name)
                t_entry = self.policy.query_table_entry(t_id, t_index)

                data = {'type': 'in', 'operation': 'query-table-entry',
                        'data': (t_name, t_index, t_entry)}
                self._tx_vendor(of.ofp_vendor_generic(data=str(data)))
        elif message['operation'] == 'query-table-list':
            if self.policy:
                t_list = self.policy.query_table_list()

                data = {'type': 'in', 'operation': 'query-table-list',
                        'data': t_list}
                self._tx_vendor(of.ofp_vendor_generic(data=str(data)))
        else:
            raise RuntimeError("Invalid message from the controller")