I'm CCing this to pox-dev, which is the more appropriate list.

The first problem is that you're sending a list of single-element lists.  
That's too many lists.  Just do:
acts = [of.ofp_action_dl_addr("OFPAT_SET_DL_SRC", srcmac),
           of.ofp_action_dl_addr("OFPAT_SET_DL_DST", dstmac),
           of.ofp_action_output(port = outputport)]    


The second problem is your rewrite actions.  You're passing the name of the 
type (e.g., OFPAT_SET_DL_SRC) as a string.  It's a constant.  You should just 
pass of.OFPAT_SET_DL_DST.

Additionally, ofp_action_dl_addr has a couple of factory methods to make this 
easier.  You can just do:
of.ofp_action_dl_addr.set_dst(dstmac)

You can find some more information about this on the wiki:
https://openflow.stanford.edu/display/ONL/POX+Wiki#POXWiki-Setsrcdstmacaddress


-- Murphy

On Aug 15, 2012, at 1:44 PM, Weiyun wrote:

> Hi,
>  
> I’m writing a controller using POX.
>  
> As the switch acting as a L3 router, when a packet first comes in, controller 
> looks up in its table and sends a message to tell the switch to modify the 
> packet’s src dst ip and forward it out.
>  
> My codes, first attempt, error 01.jpg:
>  
> acts = [[of.ofp_action_dl_addr("OFPAT_SET_DL_SRC", srcmac)],
>            [of.ofp_action_dl_addr("OFPAT_SET_DL_DST", dstmac)],
>            [of.ofp_action_output(port = outputport)]]              
> msg = of.ofp_flow_mod(command=of.OFPFC_ADD,
>                                         idle_timeout=FLOW_IDLE_TIMEOUT,
>                                         hard_timeout=of.OFP_FLOW_PERMANENT,
>                                         buffer_id=event.ofp.buffer_id,
>                                         actions=acts,
>                                         
> match=of.ofp_match.from_packet(packet, inport))
> event.connection.send(msg.pack())
>  
> <01[1].jpg>
>  
> My codes, second attempt, error 02.jpg:
>  
> msg = of.ofp_flow_mod(command=of.OFPFC_ADD,
>                                           idle_timeout=FLOW_IDLE_TIMEOUT,
>                                           hard_timeout=of.OFP_FLOW_PERMANENT,
>                                           buffer_id=event.ofp.buffer_id,
>                                           
> action=of.ofp_action_dl_addr("OFPAT_SET_DL_SRC", srcmac),
>                                           
> match=of.ofp_match.from_packet(packet, inport))
> msg.actions.append(of.ofp_action_dl_addr("OFPAT_SET_DL_DST", dstmac))
> msg.actions.append(of.ofp_action_output(port = outputport))
> event.connection.send(msg.pack())
>  
> <02[1].jpg>
>  
> I must did something wrong. Could you give me an example of sending an 
> of.ofp_flow_mod message with a list of actions?
>  
> Thank you very much.
>  
> Weiyun

Reply via email to