Bug 1556

Summary: Error uses of htonl making OpenFlow‘s match field error.
Product: ns-3 Reporter: Long Li <lilong>
Component: openflowAssignee: Blake Hurd <naimorai>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, tomh, tommaso.pecorella
Priority: P3    
Version: ns-3.15   
Hardware: PC   
OS: Linux   
Bug Depends on: 1456    
Bug Blocks:    
Attachments: path file,see this file for detail
Patch fixing htons for TCP and UDP ports

Description Long Li 2012-12-17 08:20:41 UTC
Created attachment 1488 [details]
path file,see this file for detail

In function OpenFlowSwitchNetDevice::BufferFromPacket() of file openflow-switch-netdevice.cc, udp_h->udp_src = htonl (udp_hd.GetSourcePort ()) uses htonl to convert source port from network order to host order, the field udp_src is defined as uint16_t, however. Using htonl will always make the value of udp_h->udp_src to be zero in little-endian machine. The correct function should be htons().
Comment 1 Tommaso Pecorella 2012-12-19 17:55:32 UTC
+1, however...

A few lines above there is the very same error about TCP:
      tcp_h->tcp_src = htonl (tcp_hd.GetSourcePort ());         // Source Port
      tcp_h->tcp_dst = htonl (tcp_hd.GetDestinationPort ());    // Destination Port

I can't be sure if the same issue isn't elsewhere as well.

T.
Comment 2 Long Li 2012-12-19 20:57:42 UTC
yeah, the same process should be done for the tcp lines
      tcp_h->tcp_src = htonl (tcp_hd.GetSourcePort ());         // Source Port
      tcp_h->tcp_dst = htonl (tcp_hd.GetDestinationPort ());    // Destination
Apologize for forgetting it.
Comment 3 Tommaso Pecorella 2013-01-08 17:20:03 UTC
Created attachment 1493 [details]
Patch fixing htons for TCP and UDP ports

This patch fixes both TCP and UDP ports wrong htonl calls.
Comment 4 Tom Henderson 2013-01-09 00:23:50 UTC
+1
Comment 5 Tom Henderson 2013-01-09 14:14:27 UTC
I believe that once the openflow repo is updated, this patch can be applied to it.  See bug 1456.
Comment 6 Tommaso Pecorella 2013-03-06 09:46:20 UTC
Fixed in changeset 9249 - 93d61b00eb6f