Hi Kyle, It might help to explain "it seemed to be not work". Did NOX segfault as a result? Was the a OpenFlow flow_mod sent? Was an error received? What switch are you using? These would be useful information.
Regards KK On 18 January 2011 04:15, Kyle Wang <ese.kylew...@gmail.com> wrote: > Hi, > how can I use function send_openflow_packet(const datapathid& datapath_id, > uint32_t buffer_id, const ofp_action_header actions[], uint16_t > actions_len, uint16_t in_port, bool block) to change the destination MAC > address of the 1st packet of some flow, and then send this modified packet > to the desired out_port ? > I had tried using action_list to do this, but it seemed to be not work. The > following is partial code. > ofp_action_list ofpall; > ofp_action *ofp1 = new ofp_action(); > ofp1->action_raw.reset(new uint8_t[sizeof(ofp_action_dl_addr)]); > of_action_dl_addr oada; > oada.type = OFPAT_SET_DL_DST; > oada.len = sizeof(ofp_action_dl_addr); > memcpy(oada.dl_addr, fns_server_attr.dl_src, ethernetaddr::LEN); > oada.pack((ofp_action_dl_addr*) > openflow_pack::get_header(ofp1->action_raw)); > ofpall.action_list.push_back(*ofp1); > ofp_action *ofp2 = new ofp_action(); > ofp2->action_raw.reset(new uint8_t[sizeof(ofp_action_output)]); > of_action_output oao; > oao.type = OFPAT_OUTPUT; > oao.len = sizeof(ofp_action_output); > oao.port = fns_server_attr.in_port; > oao.max_len = 0; > oao.pack((ofp_action_output*) > openflow_pack::get_header(ofp2->action_raw)); > ofpall.action_list.push_back(*ofp2); > size_t size = sizeof(ofp_flow_mod) + ofpall.mem_size(); > boost::shared_array<uint8_t> of_raw(new uint8_t[size]); > of_raw.reset(new uint8_t[size]); > of_flow_mod ofm; > ofm.header = openflow_pack::header(OFPT_FLOW_MOD, size); > ofm.match = flow.get_exact_match(); > ofm.match.wildcards = htonl(0); > ofm.match.in_port = flow.in_port; > ofm.command = OFPFC_ADD; > ofm.buffer_id = htonl(-1); > ofm.idle_timeout = htons(5); > ofm.hard_timeout = htons(OFP_FLOW_PERMANENT); > ofm.priority = htons(OFP_DEFAULT_PRIORITY); > ofm.flags = htons(ofd_flow_mod_flags()); > ofm.pack((ofp_flow_mod*) openflow_pack::get_pointer(of_raw)); > ofpall.pack(openflow_pack::get_pointer(of_raw, > sizeof(ofp_flow_mod))); > send_openflow_command(pi.datapath_id, of_raw, true); > if (buffer_id == UINT32_MAX) { > send_openflow_packet(pi.datapath_id, *pi.get_buffer(), > ofm.actions, ofpall.mem_size(), > pi.in_port, true); > } else { > send_openflow_packet(pi.datapath_id, buffer_id, > ofm.actions, ofpall.mem_size(), > pi.in_port, true); > } > > > _______________________________________________ > nox-dev mailing list > nox-dev@noxrepo.org > http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org > > _______________________________________________ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org