def handle_packet_in_event(self, logical_port_no, packet): self.log.debug('handle-packet-in', logical_port_no=logical_port_no) packet_in = ofp.ofp_packet_in( # buffer_id=0, reason=ofp.OFPR_ACTION, # table_id=0, # cookie=0, match=ofp.ofp_match( type=ofp.OFPMT_OXM, oxm_fields=[ ofp.ofp_oxm_field( oxm_class=ofp.OFPXMC_OPENFLOW_BASIC, ofb_field=in_port(logical_port_no) ) ] ), data=packet ) packet_in = ofp.PacketIn(id=self.device.data_model.logical_device_id, packet_in=packet_in) ''' # FIXME - change this to use kafka lh = self.device.data_model.adapter_agent.core.get_local_handler() lh.core.packet_in_queue.put(packet_in) ''' kafka_send_pb('voltha.pktin', packet_in)
def mk_oxm_fields(match_fields): oxm_fields = [ ofp.ofp_oxm_field(oxm_class=ofp.OFPXMC_OPENFLOW_BASIC, ofb_field=field) for field in match_fields ] return oxm_fields
def set_field(field): return action( type=SET_FIELD, set_field=ofp.ofp_action_set_field( field=ofp.ofp_oxm_field( oxm_class=ofp.OFPXMC_OPENFLOW_BASIC, ofb_field=field)) )
def mk_simple_flow_mod(match_fields, actions, command=ofp.OFPFC_ADD, next_table_id=None, meter_id=None, metadata=None, **kw): """ Convenience function to generare ofp_flow_mod message with OXM BASIC match composed from the match_fields, and single APPLY_ACTIONS instruction with a list if ofp_action objects. :param match_fields: list(ofp_oxm_ofb_field) :param actions: list(ofp_action) :param command: one of OFPFC_* :param kw: additional keyword-based params to ofp_flow_mod :return: initialized ofp_flow_mod object """ instructions = [ ofp.ofp_instruction( type=ofp.OFPIT_APPLY_ACTIONS, actions=ofp.ofp_instruction_actions(actions=actions)) ] if meter_id is not None: instructions.append( ofp.ofp_instruction( type=ofp.OFPIT_METER, meter=ofp.ofp_instruction_meter(meter_id=meter_id))) if next_table_id is not None: instructions.append( ofp.ofp_instruction(type=ofp.OFPIT_GOTO_TABLE, goto_table=ofp.ofp_instruction_goto_table( table_id=next_table_id))) if metadata is not None: instructions.append( ofp.ofp_instruction( type=ofp.OFPIT_WRITE_METADATA, write_metadata=ofp.ofp_instruction_write_metadata( metadata=metadata))) return ofp.ofp_flow_mod( command=command, match=ofp.ofp_match(type=ofp.OFPMT_OXM, oxm_fields=[ ofp.ofp_oxm_field( oxm_class=ofp.OFPXMC_OPENFLOW_BASIC, ofb_field=field) for field in match_fields ]), instructions=instructions, **kw)
def handle_packet_in_event(self, _, msg): self.log.debug('handle-packet-in', msg=msg) logical_port_no, packet = msg packet_in = ofp.ofp_packet_in( # buffer_id=0, reason=ofp.OFPR_ACTION, # table_id=0, # cookie=0, match=ofp.ofp_match(type=ofp.OFPMT_OXM, oxm_fields=[ ofp.ofp_oxm_field( oxm_class=ofp.OFPXMC_OPENFLOW_BASIC, ofb_field=in_port(logical_port_no)) ]), data=packet) self.packet_in(packet_in)
def handle_packet_in_event(self, _, msg): self.log.debug('handle-packet-in', msg=msg) logical_port_no, packet = msg packet_in = ofp.ofp_packet_in( # buffer_id=0, reason=ofp.OFPR_ACTION, # table_id=0, # cookie=0, match=ofp.ofp_match( type=ofp.OFPMT_OXM, oxm_fields=[ ofp.ofp_oxm_field( oxm_class=ofp.OFPXMC_OPENFLOW_BASIC, ofb_field=in_port(logical_port_no) ) ] ), data=packet ) self.packet_in(packet_in)
def mk_simple_flow_mod(match_fields, actions, command=ofp.OFPFC_ADD, next_table_id=None, **kw): """ Convenience function to generare ofp_flow_mod message with OXM BASIC match composed from the match_fields, and single APPLY_ACTIONS instruction with a list if ofp_action objects. :param match_fields: list(ofp_oxm_ofb_field) :param actions: list(ofp_action) :param command: one of OFPFC_* :param kw: additional keyword-based params to ofp_flow_mod :return: initialized ofp_flow_mod object """ instructions = [ ofp.ofp_instruction( type=ofp.OFPIT_APPLY_ACTIONS, actions=ofp.ofp_instruction_actions(actions=actions) ) ] if next_table_id is not None: instructions.append(ofp.ofp_instruction( type=ofp.OFPIT_GOTO_TABLE, goto_table=ofp.ofp_instruction_goto_table(table_id=next_table_id) )) return ofp.ofp_flow_mod( command=command, match=ofp.ofp_match( type=ofp.OFPMT_OXM, oxm_fields=[ ofp.ofp_oxm_field( oxm_class=ofp.OFPXMC_OPENFLOW_BASIC, ofb_field=field ) for field in match_fields ] ), instructions=instructions, **kw )