Commit graph

395 commits

Author SHA1 Message Date
Andy Green
71e267574d clean misc 1
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 08:30:06 +08:00
Andy Green
00c6d1579c public api remove context from user callback API BREAK
Since struct lws (wsi) now has his own context pointer,
we were able to remove the need for passing context
almost everywhere in the apis.

In turn, that means there's no real use for context being
passed to every callback; in the rare cases context is
needed user code can get it with lws_get_ctx(wsi)

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 07:54:44 +08:00
Andy Green
11c05bfa09 public api remove superfluous context params API BREAK
Extend the cleanout caused by wsi having a context pointer
into the public api.

There's no point keeping the 1.5 compatibility work,
we have changed the api in several places and
rebuilt wasn't going to be enough a while ago.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-16 18:19:08 +08:00
Andy Green
4eb36373d7 http uri arguments process in fragments
This makes the URI argument processing split each parameter into
a "fragment".  Processing header content as fragments already exists
in lws, because it's legal to deliver header content by repeating
the header.

Now there's an api to access individual fragments, also add the
code to the test server to print each URI argument separately.

Adapt attack.sh to parse the fragments.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 23:07:31 +08:00
Andy Green
38f3225b22 uriencoding deal with0uriencoded question mark properly
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 19:42:26 +08:00
Andy Green
ab4a94dd46 win align to recent changes
These were warnings seen on Appveyor

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 12:00:20 +08:00
Andy Green
40110e84ab whitespace trailing mass cleanout
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 08:52:03 +08:00
Andy Green
891628b33c lws_plat_fd add wsi to fops and helpers
Having the lws_context alone doesn't let us track state or act different
by wsi, which is the most interesting usecase.  Eg not only simply track
file position / decompression state per wsi but also act differently
according to wsi authentication state / associated cookies.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:43:35 +08:00
Andy Green
d2ac22c27a make protocols const require explicit context API BREAK
The user protocols struct has not been const until now.

This has been painful for a while because the semantics of the protocols
struct look like it's going to be treated as const.

At context creation, the protocols struct has been getting marked with the context,
and three apis exploited that to only need to be passed a pointer to a protocol to
get access to the context.

This patch removes the two writeable members in the context (these were never directly
used by user code), changes all pointers to protocols to be const, and adds an explicit
first argument to the three affected apis so they can have access to context.

The three affected apis are these

 LWS_VISIBLE LWS_EXTERN int
-lws_callback_on_writable_all_protocol(const struct lws_protocols *protocol);
+lws_callback_on_writable_all_protocol(const struct lws_context *context,
+                                     const struct lws_protocols *protocol);

 LWS_VISIBLE LWS_EXTERN int
-lws_callback_all_protocol(const struct lws_protocols *protocol, int reason);
+lws_callback_all_protocol(struct lws_context *context,
+                         const struct lws_protocols *protocol, int reason);

 LWS_VISIBLE LWS_EXTERN void
-lws_rx_flow_allow_all_protocol(const struct lws_protocols *protocol);
+lws_rx_flow_allow_all_protocol(const struct lws_context *context,
+                              const struct lws_protocols *protocol);

unfortunately the original apis can no longer be emulated and users of them must update.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:43:26 +08:00
Andy Green
cca0d7d27f LWS_O_RDONLY to hide perversions
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 13:03:10 +08:00
Andy Green
4812551234 osx fix unsigned signed compare error 2
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 13:00:15 +08:00
Andy Green
4e442b7743 lws_plat_fd implement platform default handlers
This is a rewrite of the patch from Soapyman here

https://github.com/warmcat/libwebsockets/pull/363

The main changes compared to Soapyman's original patch are

 - There's no new stuff in the info struct user code does any overrides
   it may want to do explicitly after lws_context_create returns

 - User overrides for file ops can call through (subclass) to the original
   platform implementation using lws_get_fops_plat()

 - A typedef is provided for plat-specific fd type

 - Public helpers are provided to allow user code to be platform-independent
   about file access, using the lws platform file operations underneath:

static inline lws_filefd_type
lws_plat_file_open(struct lws_plat_file_ops *fops, const char *filename,
		   unsigned long *filelen, int flags)

static inline int
lws_plat_file_close(struct lws_plat_file_ops *fops, lws_filefd_type fd)

static inline unsigned long
lws_plat_file_seek_cur(struct lws_plat_file_ops *fops, lws_filefd_type fd,
		       long offset_from_cur_pos)

static inline int
lws_plat_file_read(struct lws_plat_file_ops *fops, lws_filefd_type fd,
		   unsigned long *amount, unsigned char *buf, unsigned long len)

static inline int
lws_plat_file_write(struct lws_plat_file_ops *fops, lws_filefd_type fd,
		    unsigned long *amount, unsigned char *buf, unsigned long len)

There's example documentation and implementation in the test server.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 11:01:59 +08:00
Andy Green
4e512dd3a9 test client remove spamming delays
Chrome seems to be able to deal with this (or my machine is now
muscular enough it doesn't care, anyway)

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 11:01:20 +08:00
Andy Green
cb0cbfaec1 test client bit more cleaning
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-09 08:07:38 +08:00
Andy Green
e97378960f test client reconnect if server disappears
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-09 07:10:03 +08:00
Andy Green
dc8a3a817a clean more whitespace 4
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 09:15:27 +08:00
Andy Green
9c9f2180f3 attack.sh update for test server changes
Currently he can survive all the tests correctly

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 12:04:59 +08:00
Andy Green
4b85c1d4ac api rationalization: eliminate all libwebsocket[s]_ prefixes
This nukes all the oldstyle prefixes except in the compatibility code.

struct libwebsockets becomes struct lws too.

The api docs are updated accordingly as are the READMEs that mention
those apis.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 11:08:32 +08:00
Andy Green
6230476455 api rationalization use new names internally
Change all internal uses of rationalized public apis to reflect the
new names.

Theer are a few things that got changed as side effect of search/replace
matches, but these are almost all internal.  I added a compatibility define
for the public enum that got renamed.

Theoretically existing code should not notice the difference from these
two patches.  And new code will find the new names.

https://github.com/warmcat/libwebsockets/issues/357

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 08:43:54 +08:00
Andrew Canaday
f411d8e1d8 Define 'daemonize' flag if LWS_NO_DAEMONIZE is not defined. 2015-11-29 19:32:02 +08:00
Andy Green
c78fe91564 test server h add newline
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-25 12:46:08 +08:00
Andy Green
b7fed3532a test server pthreads
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-20 09:51:42 +08:00
Andy Green
adf9059d82 windows crappy tools dont know __func__
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-19 17:14:35 +08:00
Andy Green
eb15ea0198 refactor test server
Split test-server into four C files and a header

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-19 13:55:47 +08:00
Andy Green
0779964ec1 test echo initial delay
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-17 09:30:36 +08:00
Andy Green
974bed41b8 test html add open close buttons
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-15 09:24:25 +08:00
Stephan Eberle
b820e2c2cc Implemented fixes allowing libwebsockets to be built under Windows using MinGM/MSYS
Improvemed patches to address travis and appveyor build errors

Reduced WINVER and _WIN32_WINNT to 0x0501 to be less restrictive

Refined CMakeLists.txt to allow for normal Windows and MinGW-specific OpenSSL certificate generation

Simplified include path to gettimeofday.h

Removed unnecessary list(APPEND LWS_LIBRARIES zlib_internal) export

Added back #include <windows.h> to gettimeofday.c to fix build for normal Windows

Made sure that pollfd gets defined on libwebsockets side when _WIN32_WINNT < 0x0600

Made sure that WINVER and _WIN32_WINNT don't get overridden by libwebsockets headers when already set to something greater than 0x0501

Added missing declaration of WSAPoll function for WINVER < 0x0600 in libwebsockets.h, eliminated invalid usages of pollfd instead of libwebsocket_pollfd in test-server.c

Cleaned up duplicate content in gettimeofday.c, removed header inclusions from gettimeofday.h and fixed include order in test-echo.c, test-ping.c and test-server.c to enable build with normal Windows and MinGW

Re-enabled debug_level in test-echo.c and made sure that the call to lws_set_log_level() is also active under Windows (just like in test-server.c); replaced all WIN32 occurrences by _WIN32 in test-echo.c, test-ping.c, and test-server.c

Removed build-msys.sh and added new section about how to build libwebsockets using MinGW to README.build.md
2015-10-30 00:16:40 +01:00
Peter Pentchev
91fe5aa64f Use bash as a script interpreter
The test-server/attack.sh script makes use of several features only
available in the Bash shell, so mark it accordingly.
2015-10-15 11:47:38 +08:00
Roger A. Light
7a474b4e2d Separate private defines in lws_config_private.h
So we don't expose all HAVE_ macros and such to the world.
2015-10-12 10:10:20 +08:00
wonder-mice
41802c7a98 From 04da2ccd1e8c5b582c4e2a77ee53f929ae8f22a0 Mon Sep 17 00:00:00 2001
Subject: [PATCH] Always include lws_config.h since now we have only CMake
 build
2015-04-23 06:10:51 +08:00
Andy Green
15ac07f1a0 test echo put proper origin
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-04-07 07:52:23 +08:00
Andy Green
16fb0132ce prepare for v1.4
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-03-28 11:35:40 +08:00
Andy Green
7d62eb066e test server only mention pollfd if EXTERNAL_POLL
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-03-05 17:06:16 +08:00
Andy Green
6d91d5f8a1 test ping correct type for fprintf
Reported-by: Michael Habeler <mail17@mah.priv.at>
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-12-02 08:42:47 +08:00
Andy Green
613bc32f73 test echo unbreak no server
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-12-01 22:16:17 +08:00
Andy Green
303f65fbe2 test echo versa + uri
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-12-01 21:46:35 +08:00
Andy Green
fb8f2b0a73 test echo add port to server host
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-12-01 21:02:55 +08:00
Andy Green
453a9b34fd coverity 83669 remove random from fraggle
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 13:55:40 +08:00
Andy Green
cbd98ed1e4 coverity 83663 remove random from test client
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 13:53:19 +08:00
Andy Green
b743623ff4 coverity 83683 test ping more uint64_t needed
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 13:37:23 +08:00
Andy Green
d7b0a72953 coverity 83658 test server check fstat return
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 13:10:26 +08:00
Andy Green
b17598bea2 coverity 83662 test server check lseek return
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 13:10:26 +08:00
Andy Green
0f59c9e75c coverity 83668 test echo nesting level bug
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 12:50:12 +08:00
Andy Green
6a33759bb1 83675 test echo param could bust bounds
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 12:42:14 +08:00
Andy Green
31fc6ff5b5 coverity 83682 suspicous signed bytewise reassembly
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 12:27:47 +08:00
Andy Green
56686d784c coverity 83683 shift greater than 31 technically undefined
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 12:25:36 +08:00
Andy Green
745a69e7ce test echo initialize listen port
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-26 14:36:17 +08:00
Andy Green
ba4e415006 clean test server a bit
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-26 12:04:29 +08:00
Joakim Soderberg
bf3e8a998e Subject: [PATCH] BUGFIX: Failed to get proper output dir for test-server
When creating the directory where to put the files needed by the test-server CMake would fail because it tried to create the directory /../share/libwebsockets-test-server, which is not possible. This happens since the TARGET_FILE_DIR for the test-server is not fetched properly.

Also mentioned in this trac ticket:
http://libwebsockets.org/trac/libwebsockets/ticket/84
2014-11-25 05:49:11 +08:00
Andy Green
752963da00 test-echo: enable for ssl cert serving and verification 2014-11-18 09:28:35 +08:00