platform/upstream/libwebsockets.git
8 years agolws_client_connect_via_info
Andy Green [Tue, 12 Jan 2016 09:22:06 +0000 (17:22 +0800)]
lws_client_connect_via_info

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agotest client remove abs modulo
Andy Green [Tue, 12 Jan 2016 00:46:56 +0000 (08:46 +0800)]
test client remove abs modulo

llvm and gcc 5.3 do different things with it

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoextension permessage deflate
Andy Green [Mon, 11 Jan 2016 03:34:01 +0000 (11:34 +0800)]
extension permessage deflate

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclean libev.c style
Andy Green [Sat, 9 Jan 2016 00:13:55 +0000 (08:13 +0800)]
clean libev.c style

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolibev set events to match revents
Andy Green [Fri, 8 Jan 2016 20:12:46 +0000 (04:12 +0800)]
libev set events to match revents

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agopartial always use partial buffering if send incomplete
Andy Green [Fri, 8 Jan 2016 13:52:47 +0000 (21:52 +0800)]
partial always use partial buffering if send incomplete

After "rerelease"

https://github.com/warmcat/libwebsockets/issues/392#issuecomment-170003294

Since we introduced partial buffering a long while ago,
user code shold never see partial sends and very few
user callbsck attempt to deal with them.

Let's just eliminate the whole concept of user callback
partial send handling under any circumstances.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoproperly skip protocols with NULL name
Denis Osvald [Mon, 21 Dec 2015 15:39:59 +0000 (16:39 +0100)]
properly skip protocols with NULL name

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
8 years agofix callback typedefs and declarations
Denis Osvald [Mon, 21 Dec 2015 17:06:38 +0000 (18:06 +0100)]
fix callback typedefs and declarations

Remove declarations of callback and extension_callback as these are
functions declared in header but not defined anywhere.

Also rename typedefs callback_function and extension_callback_function
to lws_callback_function and lws_extension_callback_function so all
symbolx exported by header have lws prefix;

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
8 years agodoc improve docs around header access apis
Andy Green [Wed, 30 Dec 2015 06:53:50 +0000 (14:53 +0800)]
doc improve docs around header access apis

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoext negotiation tolerate semicolon args
Andy Green [Wed, 30 Dec 2015 04:12:58 +0000 (12:12 +0800)]
ext negotiation tolerate semicolon args

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoutf8 check compatible with extensions
Andy Green [Wed, 30 Dec 2015 03:43:36 +0000 (11:43 +0800)]
utf8 check compatible with extensions

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agooptimize utf8 check tests into state bit
Andy Green [Tue, 29 Dec 2015 04:28:48 +0000 (12:28 +0800)]
optimize utf8 check tests into state bit

Considering we go through it once per incoming char, the tests to see if we
should be checking utf-8 are too expensive... move them to a bit that lives
in the wsi and set them once per frame (except for CLOSE who has to update
after the close code has been skipped).

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agointroduce LWS_SERVER_OPTION_VALIDATE_UTF8
Andy Green [Tue, 29 Dec 2015 03:20:09 +0000 (11:20 +0800)]
introduce LWS_SERVER_OPTION_VALIDATE_UTF8

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn check utf8 on TEXT and CLOSE
Andy Green [Tue, 29 Dec 2015 01:46:03 +0000 (09:46 +0800)]
autobahn check utf8 on TEXT and CLOSE

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn reject forbidden close code ranges
Andy Green [Mon, 28 Dec 2015 10:29:06 +0000 (18:29 +0800)]
autobahn reject forbidden close code ranges

Complain like autobahn expects if we get a funny close code

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn README.test apps.md
Andy Green [Mon, 28 Dec 2015 09:11:31 +0000 (17:11 +0800)]
autobahn README.test apps.md

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn reject noncontinuation based on pending FIN state
Andy Green [Mon, 28 Dec 2015 09:05:40 +0000 (17:05 +0800)]
autobahn reject noncontinuation based on pending FIN state

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn detect disordered continuation
Andy Green [Mon, 28 Dec 2015 08:51:08 +0000 (16:51 +0800)]
autobahn detect disordered continuation

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn add same serverside rxflow cache to client
Andy Green [Mon, 28 Dec 2015 06:24:49 +0000 (14:24 +0800)]
autobahn add same serverside rxflow cache to client

Server side has had immediate RX flow control for quite a while.

But client side made do with RX continuing until what had been received was exhausted.

For what Autobahn tests, that's not enough.

This patch gives clientside RX flow control the same immediate effect as the server
side enjoys, re-using the same code.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn reject on reserved opcode or bits
Andy Green [Mon, 28 Dec 2015 06:12:10 +0000 (14:12 +0800)]
autobahn reject on reserved opcode or bits

Because extensions may use them, we didn't reject on reserved opc or bits set,
just ignored.  But the standard does say we should, so now we do.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn test echo extend max echo and follow message boundary
Andy Green [Mon, 28 Dec 2015 04:45:05 +0000 (12:45 +0800)]
autobahn test echo extend max echo and follow message boundary

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn extend max ping pong close payload to 125
Andy Green [Mon, 28 Dec 2015 05:40:54 +0000 (13:40 +0800)]
autobahn extend max ping pong close payload to 125

We only supported those specific control packet payloads up to 124.
125 is the correct limit.

Lws was consistent about the wrong limit so there are no other
issues.  It doesn't affect user ABI correcting it either.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn report final frag only on final rx bufload
Andy Green [Mon, 28 Dec 2015 04:45:52 +0000 (12:45 +0800)]
autobahn report final frag only on final rx bufload

If the final message fragment contains a payload that has to be
handled in multiple RX callbacks, until now we reported the ws
fragment header FIN state in lws_is_final_fragment().

That was correct, but it's kind of not useful to hear that the
intermediate bufferloads are "final".  So now we delay
reporting the logical ws fragment FIN until the final part of
his payload is delivered.

This gets us Autobahn 1.1.6 working.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn requires zero length tx allowed
Andy Green [Mon, 28 Dec 2015 03:14:04 +0000 (11:14 +0800)]
autobahn requires zero length tx allowed

Again we treat user code sending zero length things as a bug in user code.

But Autobahn insists to be able to do it, so now we allow it.

That buys us a pass on Autobahn test 1.1.1 (the first of a bazillion)

Reproduce with

libwebsockets-test-echo --client localhost --port 9001 -u "/runCase?case=1&agent=libwebsockets" -v -d 65535 -n 1

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn requires zero length rx allowed
Andy Green [Mon, 28 Dec 2015 03:11:55 +0000 (11:11 +0800)]
autobahn requires zero length rx allowed

We suppress zero length rx from getting to userland, but autobahn
requires it... oh well.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn test echo meddling
Andy Green [Mon, 28 Dec 2015 03:11:06 +0000 (11:11 +0800)]
autobahn test echo meddling

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclean windows warnings
Andy Green [Sun, 27 Dec 2015 10:16:32 +0000 (18:16 +0800)]
clean windows warnings

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agotest server libev
Andy Green [Sun, 27 Dec 2015 01:43:44 +0000 (09:43 +0800)]
test server libev

If we enabled libev support, generate a test server variant that uses it.

Libev has sets its face against fixing its warnings and says -Werror is
"stupid".  So we work around it for the problems their apis cause in
Travis.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclarify changelog
Andy Green [Sat, 26 Dec 2015 12:26:11 +0000 (20:26 +0800)]
clarify changelog

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoupdate api docs
Andy Green [Sat, 26 Dec 2015 09:36:29 +0000 (17:36 +0800)]
update api docs

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclose add api to control sent close frame contents
Andy Green [Sat, 26 Dec 2015 09:20:34 +0000 (17:20 +0800)]
close add api to control sent close frame contents

This adds an api lws_close_reason() which lets you control what will
be sent in the close frame when the connection is closed by returning
nonzero from the user callback.

The test server demo is extended to prove it works in both directions.

With this, we should have nice close support.

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclose add callback to get peer close reason
Andy Green [Sat, 26 Dec 2015 07:47:06 +0000 (15:47 +0800)]
close add callback to get peer close reason

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agombed3 remove forcing _DEBUG
Andy Green [Sat, 26 Dec 2015 07:07:45 +0000 (15:07 +0800)]
mbed3 remove forcing _DEBUG

It saves us ~4KB of lwsl_info / _debug etc strings.

The test app comes in at 114KB then, including 19KB of html, png and ico assets.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agombed3 remove unused allocations
Andy Green [Sat, 26 Dec 2015 05:23:11 +0000 (13:23 +0800)]
mbed3 remove unused allocations

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agodeprecate LWS_SEND_BUFFER_POST_PADDING
Andy Green [Sat, 26 Dec 2015 04:03:06 +0000 (12:03 +0800)]
deprecate LWS_SEND_BUFFER_POST_PADDING

The only guy who cared about this for a long while
(since I eliminated the pre-standard protocol variants)
was sending a close frame.

 - Set it to 0 so old code remains happy.  It only affects
user code buffer commit, if there's overcommit no harm
done so no effect directly on user ABI.

 - Remove all uses inside the library.  The sample apps
don't have it any more and that's the recommendation now.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agooutput eliminate redundant post calculation
Andy Green [Sat, 26 Dec 2015 02:07:17 +0000 (10:07 +0800)]
output eliminate redundant post calculation

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoremove MAX_MUX_RECURSION from PRE padding
Andy Green [Sat, 26 Dec 2015 01:08:06 +0000 (09:08 +0800)]
remove MAX_MUX_RECURSION from PRE padding

The old google mux thing is long dead

This only affects app buffer sizing, if old apps overcommit, no worries.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agorearrange private struct packing 2
Andy Green [Sat, 26 Dec 2015 00:56:58 +0000 (08:56 +0800)]
rearrange private struct packing 2

Further reduces lws size to 512 on x86_64 "for free"

Both this and the last patch only rearrange private struct members.

Also convert win32-specific member from BOOL to bitfield:1.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoRecognize Debian GNU/kFreeBSD as FreeBSD-ish.
Peter Pentchev [Fri, 25 Dec 2015 11:35:40 +0000 (13:35 +0200)]
Recognize Debian GNU/kFreeBSD as FreeBSD-ish.

Some of the FreeBSD-specific code in libwebsockets is related to
the FreeBSD kernel, not the general build environment.  Thus, it is
important to make this distinction, especially when building on
platforms that have a FreeBSD kernel and a non-FreeBSD userland build
environment, such as Debian GNU/kFreeBSD.

When checking for FreeBSD kernel features, also check for the newly
introduced __FreeBSD_kernel__ preprocessor constant; it is present in
the GNU/kFreeBSD kernel and also in FreeBSD itself since the 9.1 release
about three years ago.

8 years agorearrange struct packing
Andy Green [Fri, 25 Dec 2015 05:48:20 +0000 (13:48 +0800)]
rearrange struct packing

Surprisingly it's enough to reduce wsi from 536 to 520 on x86_64

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agohttp header malloc pool implement pool
Andy Green [Fri, 25 Dec 2015 04:44:12 +0000 (12:44 +0800)]
http header malloc pool implement pool

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agohttp header malloc pool allow listen accept flow control
Andy Green [Fri, 25 Dec 2015 01:12:08 +0000 (09:12 +0800)]
http header malloc pool allow listen accept flow control

Add a private api to enable and disable server listen socket POLLIN

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agows ping buffer allocate in wsi ws union member
Andy Green [Fri, 25 Dec 2015 05:14:09 +0000 (13:14 +0800)]
ws ping buffer allocate in wsi ws union member

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoinfo struct add padding pool
Andy Green [Fri, 25 Dec 2015 01:17:15 +0000 (09:17 +0800)]
info struct add padding pool

The info struct is too fragile against additions being able to keep soname.

Because if we add something, the library can't count on the user code being
built against latest headers with largest info struct size.  Then the user
code may not have zeroed down enough of the struct and give us junk in the
new members.

Add a pool at the end of the info struct that exists so it will be zeroed
down even though no current use for those future members, then later
library versions can compatibly use them without breaking soname if it is
understood 0 means default.

Because keeping sizeof info straight if you add something is now a thing,
also add an lwsl_info letting you confirm it easily.

It's fine if the size of info differs on different platforms.  But when
we add things to the struct we need to balance the padding using a scheme
like

       short  new_member;
       unsigned char _padding1[sizeof(void *) - sizeof(short)];

which is immune to differences in platform differences in sizeof void *.

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agodetect service tid once and use wsi with valid context to do it
Andy Green [Thu, 24 Dec 2015 05:00:54 +0000 (13:00 +0800)]
detect service tid once and use wsi with valid context to do it

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolibev complete unix plat context init
Andy Green [Wed, 23 Dec 2015 03:55:06 +0000 (11:55 +0800)]
libev complete unix plat context init

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolibev context destroy
gaby64 [Tue, 22 Dec 2015 04:41:12 +0000 (12:41 +0800)]
libev context destroy

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

8 years agotest ping android compatibility
Andy Green [Tue, 22 Dec 2015 00:17:34 +0000 (08:17 +0800)]
test ping android compatibility

After "emptyVoid" at

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoSubject: [PATCH] Typo in macro name.
Roger A. Light [Sat, 19 Dec 2015 01:26:53 +0000 (01:26 +0000)]
Subject: [PATCH] Typo in macro name.

8 years agouridecoding lws_hdr_fragment_length
Andy Green [Fri, 18 Dec 2015 23:35:23 +0000 (07:35 +0800)]
uridecoding lws_hdr_fragment_length

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agowhitespace tidy
Andy Green [Fri, 18 Dec 2015 23:18:55 +0000 (07:18 +0800)]
whitespace tidy

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agouridecode no need to require length plus 2
Andy Green [Fri, 18 Dec 2015 08:40:02 +0000 (16:40 +0800)]
uridecode no need to require length plus 2

length + 1 (for the '\0' is enough)

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agouridecoding disallow uriencoded equals in name part
Andy Green [Fri, 18 Dec 2015 07:40:03 +0000 (15:40 +0800)]
uridecoding disallow uriencoded equals in name part

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agouridecoding handle plus chars as space
Andy Green [Fri, 18 Dec 2015 07:23:31 +0000 (15:23 +0800)]
uridecoding handle plus chars as space

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agouridecoding support optional semicolon as delimiter
Andy Green [Fri, 18 Dec 2015 07:20:09 +0000 (15:20 +0800)]
uridecoding support optional semicolon as delimiter

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoversion 1.6.0
Andy Green [Fri, 18 Dec 2015 02:35:11 +0000 (10:35 +0800)]
version 1.6.0

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoapi doc v1.6.0
Andy Green [Fri, 18 Dec 2015 03:18:56 +0000 (11:18 +0800)]
api doc v1.6.0

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agochangelog pre v1.6.0
Andy Green [Fri, 18 Dec 2015 03:01:03 +0000 (11:01 +0800)]
changelog pre v1.6.0

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclean uri arg dump
Andy Green [Fri, 18 Dec 2015 02:46:24 +0000 (10:46 +0800)]
clean uri arg dump

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agocontext protocol destroy provide nonnull wsi with context
Andy Green [Thu, 17 Dec 2015 17:08:14 +0000 (01:08 +0800)]
context protocol destroy provide nonnull wsi with context

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoserver check cb return during establish
Andy Green [Thu, 17 Dec 2015 16:56:31 +0000 (00:56 +0800)]
server check cb return during establish

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclient check cb return during establish
Andy Green [Thu, 17 Dec 2015 16:50:14 +0000 (00:50 +0800)]
client check cb return during establish

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolws_get_context not _ctx
Andy Green [Thu, 17 Dec 2015 10:25:25 +0000 (18:25 +0800)]
lws_get_context not _ctx

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclean internal refactor
Andy Green [Thu, 17 Dec 2015 09:03:59 +0000 (17:03 +0800)]
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>
8 years agowin cover clearing sock_send_blocking when external poll
Andy Green [Thu, 17 Dec 2015 07:35:41 +0000 (15:35 +0800)]
win cover clearing sock_send_blocking when external poll

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agowin solve various cranky problems with msvc
Andy Green [Thu, 17 Dec 2015 07:15:12 +0000 (15:15 +0800)]
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>
8 years agoclean misc 1
Andy Green [Thu, 17 Dec 2015 00:09:13 +0000 (08:09 +0800)]
clean misc 1

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agopublic api remove context from user callback API BREAK
Andy Green [Wed, 16 Dec 2015 23:54:44 +0000 (07:54 +0800)]
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>
8 years agowindows fix wsapoll conflict on some toolchains
Andy Green [Wed, 16 Dec 2015 11:51:12 +0000 (19:51 +0800)]
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>
8 years agopublic api remove superfluous context params API BREAK
Andy Green [Wed, 16 Dec 2015 10:19:08 +0000 (18:19 +0800)]
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>
8 years agoadd LWS_INLINE to deal with crappy msvc
Andy Green [Wed, 16 Dec 2015 07:02:47 +0000 (15:02 +0800)]
add LWS_INLINE to deal with crappy msvc

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agohttp uri arguments process in fragments
Andy Green [Tue, 15 Dec 2015 14:57:19 +0000 (22:57 +0800)]
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>
8 years agoURIPS_ARGUMENTS is redundant
Andy Green [Tue, 15 Dec 2015 15:05:23 +0000 (23:05 +0800)]
URIPS_ARGUMENTS is redundant

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agodocument how the header fragments work
Andy Green [Tue, 15 Dec 2015 15:03:29 +0000 (23:03 +0800)]
document how the header fragments work

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agointroduce lws_hdr_copy_fragment
Andy Green [Tue, 15 Dec 2015 14:59:23 +0000 (22:59 +0800)]
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>
8 years agorefactor needless context with wsi paramater passing
Andy Green [Tue, 15 Dec 2015 13:15:58 +0000 (21:15 +0800)]
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>
8 years agoSubject: [PATCH] Add LWS_LIBRARY_VERSION_NUMBER to lws_config.h.
Roger A. Light [Mon, 14 Dec 2015 17:25:29 +0000 (17:25 +0000)]
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.

8 years agoFix corruption of close reason code in close frame
Andrejs Hanins [Tue, 15 Dec 2015 11:31:23 +0000 (13:31 +0200)]
Fix corruption of close reason code in close frame

According to specification, close reason code is part of body

8 years agombed3 use new upstream mbed3 nagle disable
Andy Green [Tue, 15 Dec 2015 11:46:28 +0000 (19:46 +0800)]
mbed3 use new upstream mbed3 nagle disable

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agouriencoding deal with0uriencoded question mark properly
Andy Green [Mon, 14 Dec 2015 11:42:26 +0000 (19:42 +0800)]
uriencoding deal with0uriencoded question mark properly

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agowin align to recent changes
Andy Green [Mon, 14 Dec 2015 03:34:00 +0000 (11:34 +0800)]
win align to recent changes

These were warnings seen on Appveyor

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agombed3 align to recent changes
Andy Green [Mon, 14 Dec 2015 03:17:16 +0000 (11:17 +0800)]
mbed3 align to recent changes

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoRefactoring conditional directives for if wrappers
wmarquesr [Sun, 13 Dec 2015 23:36:41 +0000 (20:36 -0300)]
Refactoring conditional directives for if wrappers

8 years agowhitespace trailing mass cleanout
Andy Green [Mon, 14 Dec 2015 00:52:03 +0000 (08:52 +0800)]
whitespace trailing mass cleanout

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolibev take care about const context where possible
Andy Green [Sun, 13 Dec 2015 23:51:15 +0000 (07:51 +0800)]
libev take care about const context where possible

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agochangelog update file api about wsi
Andy Green [Sun, 13 Dec 2015 23:21:42 +0000 (07:21 +0800)]
changelog update file api about wsi

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agointroduce lws_wsi_user
Andy Green [Sun, 13 Dec 2015 23:16:32 +0000 (07:16 +0800)]
introduce lws_wsi_user

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agochangelog explain protocols related api changes
Andy Green [Sun, 13 Dec 2015 23:02:51 +0000 (07:02 +0800)]
changelog explain protocols related api changes

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolws_plat_fd add wsi to fops and helpers
Andy Green [Fri, 11 Dec 2015 05:12:58 +0000 (13:12 +0800)]
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>
8 years agomake protocols const require explicit context API BREAK
Andy Green [Fri, 11 Dec 2015 02:45:35 +0000 (10:45 +0800)]
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>
8 years agolws_get_ctx conversion
Andy Green [Fri, 11 Dec 2015 01:36:14 +0000 (09:36 +0800)]
lws_get_ctx conversion

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agowin open flags 3 lsb are not bitfields
Andy Green [Sun, 13 Dec 2015 22:40:53 +0000 (06:40 +0800)]
win open flags 3 lsb are not bitfields

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoRevert using AI_V4MAPPED flag to getaddrinfo for Android
Yusuke Ishiguro [Fri, 11 Dec 2015 09:10:02 +0000 (18:10 +0900)]
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.

8 years agowindows fcntl.h
Andy Green [Thu, 10 Dec 2015 05:21:07 +0000 (13:21 +0800)]
windows fcntl.h

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoLWS_O_RDONLY to hide perversions
Andy Green [Thu, 10 Dec 2015 05:03:10 +0000 (13:03 +0800)]
LWS_O_RDONLY to hide perversions

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoosx fix unsigned signed compare error 2
Andy Green [Thu, 10 Dec 2015 05:00:15 +0000 (13:00 +0800)]
osx fix unsigned signed compare error 2

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agowindows use right perversion flgs
Andy Green [Thu, 10 Dec 2015 04:56:46 +0000 (12:56 +0800)]
windows use right perversion flgs

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoosx fix unsigned signed compare error
Andy Green [Thu, 10 Dec 2015 04:50:10 +0000 (12:50 +0800)]
osx fix unsigned signed compare error

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolws_plat_fd implement platform default handlers
Andy Green [Wed, 9 Dec 2015 23:58:58 +0000 (07:58 +0800)]
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>
8 years agolws_plat_fd introduce struct
SoapyMan [Wed, 9 Dec 2015 23:52:31 +0000 (07:52 +0800)]
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