diff --git a/SConstruct b/SConstruct index f8192198e6..d188dea174 100644 --- a/SConstruct +++ b/SConstruct @@ -37,8 +37,8 @@ def boostlibs(libnames): return [] else: libs = [] - prefix = 'SHLIBPREFIX' if boost_linkshared else 'LIBPREFIX' - suffix = 'SHLIBSUFFIX' if boost_linkshared else 'LIBSUFFIX' + prefix = env['SHLIBPREFIX'] if boost_linkshared else env['LIBPREFIX'] + suffix = env['SHLIBSUFFIX'] if boost_linkshared else env['LIBSUFFIX'] for name in libnames: lib = File(os.path.join(env['BOOST_LIBS'], '%sboost_%s%s' % (prefix, name, suffix))) libs.append(lib) @@ -66,7 +66,7 @@ else: platform_libs = [] if env['PLATFORM'] == 'posix': - platform_libs = ['pthread', 'rt'] + platform_libs = ['pthread', 'rt'] elif env['PLATFORM'].startswith('win'): # Win/VC++ supports autolinking. nothing to do. pass diff --git a/examples/wsperf/generic.hpp b/examples/wsperf/generic.hpp index 77e6f884b2..88ab45d4c1 100644 --- a/examples/wsperf/generic.hpp +++ b/examples/wsperf/generic.hpp @@ -38,7 +38,6 @@ enum correctness_mode { LENGTH = 1 }; -// test class for 9.1.* and 9.2.* class message_test : public case_handler { public: message_test(uint64_t message_size, @@ -75,7 +74,7 @@ public: m_rtts = extract_bool(cmd,"rtts"); // specific to message_test - m_message_count = extract_number(cmd,"size"); + m_message_count = extract_number(cmd,"size"); m_message_size = extract_number(cmd,"count"); m_timeout = extract_number(cmd,"timeout"); @@ -118,7 +117,9 @@ public: } void on_message(connection_ptr con,websocketpp::message::data_ptr msg) { - if ((m_mode == LENGTH && msg->get_payload().size() == m_data.size()) || (m_mode == EXACT && msg->get_payload() == m_data)) { + if ((m_mode == LENGTH && msg->get_payload().size() == m_data.size()) || + (m_mode == EXACT && msg->get_payload() == m_data)) + { m_acks++; m_bytes += m_message_size; mark(); diff --git a/src/connection.hpp b/src/connection.hpp index a4432a0c95..e47b304af4 100644 --- a/src/connection.hpp +++ b/src/connection.hpp @@ -578,7 +578,7 @@ public: m_write_buf.push_back(boost::asio::buffer(m_write_queue.front()->get_header())); m_write_buf.push_back(boost::asio::buffer(m_write_queue.front()->get_payload())); - m_endpoint.alog().at(log::alevel::DEVEL) << "write header: " << to_hex(m_write_queue.front()->get_header()) << log::endl; + m_endpoint.alog().at(log::alevel::DEVEL) << "write header: " << zsutil::to_hex(m_write_queue.front()->get_header()) << log::endl; boost::asio::async_write( socket_type::get_socket(), diff --git a/src/network_utilities.cpp b/src/network_utilities.cpp index f5ea279a1c..30cc9f9166 100644 --- a/src/network_utilities.cpp +++ b/src/network_utilities.cpp @@ -27,7 +27,9 @@ #include "network_utilities.hpp" -uint64_t htonll(uint64_t src) { + + +uint64_t zsutil::htonll(uint64_t src) { static int typ = TYP_INIT; unsigned char c; union { @@ -48,11 +50,11 @@ uint64_t htonll(uint64_t src) { return x.ull; } -uint64_t ntohll(uint64_t src) { +uint64_t zsutil::ntohll(uint64_t src) { return htonll(src); } -std::string lookup_ws_close_status_string(uint16_t code) { +std::string zsutil::lookup_ws_close_status_string(uint16_t code) { switch (code) { case 1000: return "Normal closure"; @@ -76,12 +78,14 @@ std::string lookup_ws_close_status_string(uint16_t code) { return "Message too large"; case 1010: return "Missing required extensions"; + case 1011: + return "Internal server error"; default: return "Unknown"; } } -std::string to_hex(const std::string& input) { +std::string zsutil::to_hex(const std::string& input) { std::string output; std::string hex = "0123456789ABCDEF"; diff --git a/src/network_utilities.hpp b/src/network_utilities.hpp index 7d247502e9..465fb14a3d 100644 --- a/src/network_utilities.hpp +++ b/src/network_utilities.hpp @@ -35,6 +35,8 @@ // TODO: impliment stuff from here: // http://stackoverflow.com/questions/809902/64-bit-ntohl-in-c +namespace zsutil { + #define TYP_INIT 0 #define TYP_SMLE 1 #define TYP_BIGE 2 @@ -46,4 +48,6 @@ std::string lookup_ws_close_status_string(uint16_t code); std::string to_hex(const std::string& input); +} // namespace zsutil + #endif // NETWORK_UTILITIES_HPP diff --git a/src/processors/hybi_header.cpp b/src/processors/hybi_header.cpp index 49a89888df..053f75a489 100644 --- a/src/processors/hybi_header.cpp +++ b/src/processors/hybi_header.cpp @@ -76,7 +76,7 @@ void hybi_header::consume(std::istream& input) { default: break; } - //std::cout << "header so far: " << to_hex(std::string(m_header,MAX_HEADER_LENGTH)) << std::endl; + //std::cout << "header so far: " << zsutil::to_hex(std::string(m_header,MAX_HEADER_LENGTH)) << std::endl; } uint64_t hybi_header::get_bytes_needed() const { return m_bytes_needed; @@ -136,7 +136,7 @@ void hybi_header::set_payload_size(uint64_t size) { m_header[1] |= BASIC_PAYLOAD_64BIT_CODE; } m_payload_size = size; - *(reinterpret_cast(&m_header[BASIC_HEADER_LENGTH])) = htonll(size); + *(reinterpret_cast(&m_header[BASIC_HEADER_LENGTH])) = zsutil::htonll(size); } else { throw processor::exception("set_payload_size called with value that was too large (>2^63)",processor::error::MESSAGE_TOO_BIG); } @@ -245,8 +245,8 @@ void hybi_header::process_extended_header() { // reinterpret the second two bytes as a 16 bit integer in network // byte order. Convert to host byte order and store locally. m_payload_size = ntohs(*( - reinterpret_cast(&m_header[BASIC_HEADER_LENGTH]) - )); + reinterpret_cast(&m_header[BASIC_HEADER_LENGTH]) + )); if (m_payload_size < s) { std::stringstream err; @@ -257,9 +257,9 @@ void hybi_header::process_extended_header() { } else if (s == BASIC_PAYLOAD_64BIT_CODE) { // reinterpret the second eight bytes as a 64 bit integer in // network byte order. Convert to host byte order and store. - m_payload_size = ntohll(*( - reinterpret_cast(&m_header[BASIC_HEADER_LENGTH]) - )); + m_payload_size = zsutil::ntohll(*( + reinterpret_cast(&m_header[BASIC_HEADER_LENGTH]) + )); if (m_payload_size <= frame::limits::PAYLOAD_SIZE_EXTENDED) { throw processor::exception("payload length not minimally encoded", diff --git a/src/websocket_frame.hpp b/src/websocket_frame.hpp index 86c3a6219d..3c39f620ca 100644 --- a/src/websocket_frame.hpp +++ b/src/websocket_frame.hpp @@ -397,7 +397,7 @@ public: *reinterpret_cast(&m_header[BASIC_HEADER_LENGTH]) = htons(s); } else if (s <= limits::PAYLOAD_SIZE_JUMBO) { m_header[1] = BASIC_PAYLOAD_64BIT_CODE; - *reinterpret_cast(&m_header[BASIC_HEADER_LENGTH]) = htonll(s); + *reinterpret_cast(&m_header[BASIC_HEADER_LENGTH]) = zsutil::htonll(s); } else { throw processor::exception("payload size limit is 63 bits",processor::error::PROTOCOL_VIOLATION); } @@ -498,7 +498,7 @@ public: } else if (s == BASIC_PAYLOAD_64BIT_CODE) { // reinterpret the second eight bytes as a 64 bit integer in // network byte order. Convert to host byte order and store. - payload_size = ntohll(*( + payload_size = zsutil::ntohll(*( reinterpret_cast(&m_header[BASIC_HEADER_LENGTH]) )); diff --git a/websocketpp.xcodeproj/project.pbxproj b/websocketpp.xcodeproj/project.pbxproj index 9f9bcff609..c2c49f7059 100644 --- a/websocketpp.xcodeproj/project.pbxproj +++ b/websocketpp.xcodeproj/project.pbxproj @@ -372,6 +372,7 @@ B6E56D6F150457B8007E1707 /* wscmd.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = wscmd.hpp; path = examples/wsperf/wscmd.hpp; sourceTree = ""; }; B6E56D7E150644A3007E1707 /* request.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = request.cpp; path = examples/wsperf/request.cpp; sourceTree = ""; }; B6E56D7F150644A3007E1707 /* request.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = request.hpp; path = examples/wsperf/request.hpp; sourceTree = ""; }; + B6E56D821508EACA007E1707 /* SConstruct */ = {isa = PBXFileReference; lastKnownFileType = text; path = SConstruct; sourceTree = ""; }; B6E7E7731505532E00394909 /* wsperf */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = wsperf; sourceTree = BUILT_PRODUCTS_DIR; }; B6E7E78A150553D000394909 /* libboost_chrono.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libboost_chrono.dylib; path = usr/local/lib/libboost_chrono.dylib; sourceTree = SDKROOT; }; B6FE8CE2144DE17F00B32547 /* readme.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = readme.txt; sourceTree = ""; }; @@ -749,6 +750,7 @@ B6DF1CC51435ECE40029A1B1 /* libraries */, B6138791145CA6F700ED9B19 /* Makefile */, B6DE901314C4D875009A1591 /* readme.txt */, + B6E56D821508EACA007E1707 /* SConstruct */, B64E12D014BDE132006F20F0 /* test */, B6DF1C7F1434ABB70029A1B1 /* src */, B6DF1C6A1434A7A30029A1B1 /* Products */,