Hi all,


to get straight to the point: while using nox I discovered a problem concerning rules to insert into a switch's flow table from a python script. When the list of actions contained the change of the ip_src / ip_dst header fields, I got some kind of type mismatch error in the nox output. It seemed to be caused in the make_action_array function in core.py. This change worked well for me:


...

elif action[0] == openflow.OFPAT_SET_NW_SRC or action[0] == openflow.OFPAT_SET_NW_DST:
    iaddr = convert_to_ipaddr(action[1])
    if iaddr == None:
        print 'invalid ip addr'
        return None

    # ipaddr already in network byte order
---      a = struct.pack("HHI", htons(action[0]), htons(8), iaddr.addr)
+++   a = struct.pack("HHI", htons(action[0]), htons(8), htonl(ipaddr(iaddr).addr))

...


I'm by no means a python expert, but obviously (to me) the C++ struct had to be casted to the right object type (ipaddr) as well as to be set into network byte order. I don't know if this is depending on the package versions you use (swig, python, ...) or if the mentioned change has been omitted in the code.


If so, I'm glad to help.


Best regards,


Samuel Schuhmacher

_______________________________________________
nox-dev mailing list
[email protected]
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org

Reply via email to