From 7f796fe1b27aa7f2e8af5f4b1b69dac5de0a3baa Mon Sep 17 00:00:00 2001 From: Steve Markgraf Date: Sun, 13 May 2012 23:06:09 +0200 Subject: [PATCH] rtl_tcp_source: convert commands from host to network byteorder Signed-off-by: Steve Markgraf --- lib/rtl_tcp/rtl_tcp_source_f.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/rtl_tcp/rtl_tcp_source_f.cc b/lib/rtl_tcp/rtl_tcp_source_f.cc index 6dfa6ab..3fa65e8 100644 --- a/lib/rtl_tcp/rtl_tcp_source_f.cc +++ b/lib/rtl_tcp/rtl_tcp_source_f.cc @@ -27,6 +27,12 @@ #include #include +#ifndef _WIN32 +#include +#else +#include +#endif + #define USE_SELECT 1 // non-blocking receive on all platforms #define USE_RCV_TIMEO 0 // non-blocking receive on all but Cygwin #define SRC_VERBOSE 0 @@ -246,30 +252,30 @@ struct command{ void rtl_tcp_source_f::set_freq(int freq) { - struct command cmd = { 0x01, freq }; + struct command cmd = { 0x01, htonl(freq) }; send(d_socket, (const char*)&cmd, sizeof(cmd), 0); } void rtl_tcp_source_f::set_sample_rate(int sample_rate) { - struct command cmd = { 0x02, sample_rate }; + struct command cmd = { 0x02, htonl(sample_rate) }; send(d_socket, (const char*)&cmd, sizeof(cmd), 0); } void rtl_tcp_source_f::set_gain_mode(int manual) { - struct command cmd = { 0x03, manual }; + struct command cmd = { 0x03, htonl(manual) }; send(d_socket, (const char*)&cmd, sizeof(cmd), 0); } void rtl_tcp_source_f::set_gain(int gain) { - struct command cmd = { 0x04, gain }; + struct command cmd = { 0x04, htonl(gain) }; send(d_socket, (const char*)&cmd, sizeof(cmd), 0); } void rtl_tcp_source_f::set_freq_corr(int ppm) { - struct command cmd = { 0x05, ppm }; + struct command cmd = { 0x05, htonl(ppm) }; send(d_socket, (const char*)&cmd, sizeof(cmd), 0); }