Dear Murphy:
Hello! These days I've been doing some work using POX's REST API to add some flow entries, but I have encountered some problems when I tried to add a flow entry like: curl -i -X POST -d '{"method":"set_table","params":{"dpid":"00-00-00-00-00-01","flows":[{"actions":[{"type":"OFPAT_SET_DL_SRC","dl_addr":"11:22:33:aa:bb:cc"}],"match":{}}]}}' http://localhost:8000/OF/ The Error information is: "pox/openflow/of_json.py" 331L, 8393C written File "/home/mininet/pox/pox/lib/recoco/recoco.py", line 774, in run e[0](*e[1], **e[2]) File "/home/mininet/pox/pox/openflow/webservice.py", line 78, in _do_init self._init(*args, **kw) File "/home/mininet/pox/pox/openflow/webservice.py", line 169, in _init self._con.send(fm) File "/home/mininet/pox/pox/openflow/of_01.py", line 692, in send data = data.pack() File "/home/mininet/pox/pox/openflow/libopenflow_01.py", line 2325, in pack packed += i.pack() File "/home/mininet/pox/pox/openflow/libopenflow_01.py", line 1942, in pack packed += struct.pack("!HHH", self.type, len(self), self.tp_port) error: cannot convert argument to integer The problem happens when the "type" field of "actions" in the JSON string is: OFPAT_SET_DL_DST OFPAT_SET_DL_SRC OFPAT_SET_NW_DST OFPAT_SET_NW_SRC OFPAT_SET_TP_DST OFPAT_SET_TP_SRC These problems bothered me a lot so I try to read the source code of POX, finally I found this is a bug of POX and I have solved it. In pox/pox/openflow/of_json.py, in the definition of function dict_to_action there is one line(around line 147): del d['type'] However, in pox/openflow/libopenflow_01.py the __init__ of the functions: ofp_action_dl_addr ofp_action_nw_addr ofp_action_tp_port needs the "type" field. As a result of that, an error occurs. I solve the problem by modifying the pox/pox/openflow/of_json.py, in the definition of function dict_to_action I add two lines of code(around line 150): t = of.ofp_action_type_rev_map[t] cls = of._action_type_to_class[t] if t in [4,5,6,7,9,10]: d['type'] = t return a I wish you could fix the bug latter. Thx for your excellent work. Looking forward to your reply. :) -- Alex LU