Bug 1556 - Error uses of htonl making OpenFlow‘s match field error.
Error uses of htonl making OpenFlow‘s match field error.
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: openflow
ns-3.15
PC Linux
: P3 normal
Assigned To: Blake Hurd
:
Depends on: 1456
Blocks:
  Show dependency treegraph
 
Reported: 2012-12-17 08:20 EST by Long Li
Modified: 2013-03-06 09:46 EST (History)
3 users (show)

See Also:


Attachments
path file,see this file for detail (994 bytes, application/octet-stream)
2012-12-17 08:20 EST, Long Li
Details
Patch fixing htons for TCP and UDP ports (1.50 KB, patch)
2013-01-08 17:20 EST, Tommaso Pecorella
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Long Li 2012-12-17 08:20:41 EST
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 EST
+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 EST
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 EST
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 EST
+1
Comment 5 Tom Henderson 2013-01-09 14:14:27 EST
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 EST
Fixed in changeset 9249 - 93d61b00eb6f