Commit graph

1643 commits

Author SHA1 Message Date
Andy Green
6d64539fcb lws_get_context not _ctx
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 18:25:25 +08:00
Andy Green
54806b1541 clean internal refactor
- Mainly symbol length reduction
 - Whitespace clean
 - Code refactor for linear flow
 - Audit @Context for API docs vs changes

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 17:03:59 +08:00
Andy Green
ddd79cbbb5 win cover clearing sock_send_blocking when external poll
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 15:35:41 +08:00
Andy Green
eee0d8af5f win solve various cranky problems with msvc
After emptyVoid at --->

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

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 15:15:12 +08:00
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
375a193ff4 windows fix wsapoll conflict on some toolchains
After EmptyVoid at github

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

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-16 19:51:12 +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
8a97c06cd1 add LWS_INLINE to deal with crappy msvc
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-16 15:02:47 +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
f35801b19d URIPS_ARGUMENTS is redundant
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 23:05:23 +08:00
Andy Green
fac92eb7cb document how the header fragments work
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 23:03:29 +08:00
Andy Green
566eb4381c introduce lws_hdr_copy_fragment
This adds a public API variant of the header copy api that lets you
choose which fragment you want copied.

Normally you want the existing one that aggregates the fragments.

But it can be useful to get each part in turn (that corresponds to
the content provided by each duplicated header normally).

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 22:59:23 +08:00
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
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
3f62870e67 introduce lws_wsi_user
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 07:16:32 +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
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
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
Alexander Bruines
8266450ba2 Access to wsi->ssl at LWS_CALLBACK_ESTABLISHED 2015-12-09 07:27:15 +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
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
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
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