Commit graph

1351 commits

Author SHA1 Message Date
Andy Green
6b5de70f4f refactor needless context with wsi paramater passing
Now we bit the bullet and gave each wsi an lws_context *, many
internal apis that take both a context and wsi parameter only
need the wsi.

Also simplify parser code by making a temp var for
allocated_headers * instead of the longwinded
dereference chain everywhere.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 21:15:58 +08:00
Roger A. Light
e59908e7fc Subject: [PATCH] Add LWS_LIBRARY_VERSION_NUMBER to lws_config.h.
This changeset adds a few preprocessor macros to lws_config.h to allow
a user of libwebsockets to determine at compile time which version of
lws they are compiling against.

This exposes the already existing LWS_LIBRARY_VERSION_MAJOR and _MINOR
values, and adds LWS_LIBRARY_VERSION_PATCH. This suggests that future
minor bugfix release versions of lws would be e.g. 1.6.0 -> 1.6.1 rather
than the style used previously: 1.2 -> 1.21.

The way this is currently set up means new minor revisions (with
_PATCH==0) always end with .0 but I could change this if preferred.

The most important addition is LWS_LIBRARY_VERSION_NUMBER, which
produces a number of the form 1005001 for version 1.5.1 - i.e. each part
major, minor, patch can extend from 0-999. This macro allows a very easy
compile time comparison of version numbers.
2015-12-15 19:49:55 +08:00
Andrejs Hanins
ea592fa869 Fix corruption of close reason code in close frame
According to specification, close reason code is part of body
2015-12-15 19:46:33 +08:00
Andy Green
3decfe60ab mbed3 use new upstream mbed3 nagle disable
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 19:46:28 +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
1fa7685a28 mbed3 align to recent changes
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 11:17:16 +08:00
wmarquesr
c718ff30d8 Refactoring conditional directives for if wrappers 2015-12-14 09:39:56 +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
a01fb52d09 libev take care about const context where possible
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 07:51:15 +08:00
Andy Green
3f59996e67 changelog update file api about wsi
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 07:21:42 +08:00
Andy Green
3f62870e67 introduce lws_wsi_user
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 07:16:32 +08:00
Andy Green
1a366bf946 changelog explain protocols related api changes
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 07:02:51 +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
8203be6742 lws_get_ctx conversion
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:43:24 +08:00
Andy Green
0161f01082 win open flags 3 lsb are not bitfields
https://github.com/warmcat/libwebsockets/issues/367

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:40:53 +08:00
Yusuke Ishiguro
a951396cc2 Revert using AI_V4MAPPED flag to getaddrinfo for Android
Because getaddrinfo will return error on Android when
AI_V4MAPPED is specified. So we should use old implemntation.
Android support of IPv6 is very poor.
2015-12-11 17:37:49 +08:00
Andy Green
21da5613c6 windows fcntl.h
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 13:21:07 +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
d1c6d0bb06 windows use right perversion flgs
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 12:56:46 +08:00
Andy Green
95181d96a7 osx fix unsigned signed compare error
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 12:50:10 +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
SoapyMan
11260dac18 lws_plat_fd introduce struct
Originally from

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

Modified by AG to change the emphasis to exporting lws plat
handlers for use by the user code portably
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
510c3c86c0 clean comment style in libwebsockets.h
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 07:50:51 +08:00
Andy Green
4fd5ce3361 armour libwebsockets.h also put notices on abi structs in there
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 07:24:20 +08:00
Andy Green
4386e36b0b plat combine inits into single lws_plat_init and provide info
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 07:14:16 +08:00
Yusuke Ishiguro
4fee9de6bc Subject: [PATCH] fixed not to use IPv4-mapped address for IPv6 only node
Since IPv6 only node can not connect with IPv4-mapped address.
2015-12-09 19:04:17 +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
Alexander Bruines
8266450ba2 Access to wsi->ssl at LWS_CALLBACK_ESTABLISHED 2015-12-09 07:27:15 +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
Yusuke Ishiguro
ee435adb7c fixed to initialize sockaddr_in6 by zero
Some environment has field of sin6_scope_id inside sockaddr_in6
and it should be set to zero.
2015-12-08 19:57:00 +08:00
Andy Green
ac19bf6801 soname bump
See

http://ml.libwebsockets.org/pipermail/libwebsockets/2015-December/002052.html

for the reason

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-08 11:06:28 +08:00
Andy Green
dc0731b3a5 armour libwebsockets.h against careless enum changes affecting abi
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-08 11:04:19 +08:00
Charles Prevot
90a0dd6b75 cmake additionally install cmake config 2015-12-08 10:26:57 +08:00
Andy Green
0fd63763f6 coverity 155650 medium possible write to null pointer
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 11:07:41 +08:00
Andy Green
e96b2c680a coverity 155649 medium possible write to null pointer
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 11:04:05 +08:00
Andy Green
ef951221d6 coverity 155648 low dead code daemonize disabled
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 11:00:36 +08:00
Andy Green
9b780806f0 travis coverity update
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 10:43:02 +08:00
Andy Green
576d3ec0df clean more whitespace 5
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 10:05:37 +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
d478fb8c38 clean more whitespace 3
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 08:40:00 +08:00
Andy Green
1cc03887f4 clean reduce windows build warnings
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 08:00:03 +08:00
Andy Green
6ab6ee2c0f more server close processing error handling precisions
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 06:39:51 +08:00
Andy Green
819d418bf2 server socket service close when detected do right thing
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 05:55:52 +08:00
Andy Green
d607bb9bfe clean more whitespace 2
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 05:52:09 +08:00
Andy Green
e53f2ed5e6 clean more whitespace
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-05 21:52:41 +08:00
Andy Green
f012c4423c server socket service close fix fail detect
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-05 21:52:16 +08:00