2 * libwebsockets-test-server - libwebsockets test implementation
4 * Copyright (C) 2010-2016 Andy Green <andy@warmcat.com>
6 * This file is made available under the Creative Commons CC0 1.0
7 * Universal Public Domain Dedication.
9 * The person who associated a work with this deed has dedicated
10 * the work to the public domain by waiving all of his or her rights
11 * to the work worldwide under copyright law, including all related
12 * and neighboring rights, to the extent allowed by law. You can copy,
13 * modify, distribute and perform the work, even for commercial purposes,
14 * all without asking permission.
16 * The test apps are intended to be adapted for use in your code, which
17 * may be proprietary. So unlike the library itself, they are licensed
21 #if defined(_WIN32) && defined(EXTERNAL_POLL)
23 #define _WIN32_WINNT 0x0600
24 #define poll(fdArray, fds, timeout) WSAPoll((LPWSAPOLLFD)(fdArray), (ULONG)(fds), (INT)(timeout))
27 #include "lws_config.h"
38 #include "../lib/libwebsockets.h"
42 #include "gettimeofday.h"
49 extern int close_testing;
50 extern int max_poll_elements;
53 extern struct lws_pollfd *pollfds;
54 extern int *fd_lookup;
55 extern int count_pollfds;
57 extern volatile int force_exit;
58 extern struct lws_context *context;
59 extern char *resource_path;
60 #if defined(LWS_OPENSSL_SUPPORT) && defined(LWS_HAVE_SSL_CTX_set1_param)
61 extern char crl_path[1024];
64 extern void test_server_lock(int care);
65 extern void test_server_unlock(int care);
68 #define __func__ __FUNCTION__
71 struct per_session_data__http {
73 char post_string[256];
75 struct lws_cgi_args args;
77 #if defined(LWS_WITH_CGI) || !defined(LWS_NO_CLIENT)
80 unsigned int client_finished:1;
84 * one of these is auto-created for each connection and a pointer to the
85 * appropriate instance is passed to the callback in the user parameter
87 * for this example protocol we use it to individualize the count for each
91 struct per_session_data__dumb_increment {
95 struct per_session_data__lws_mirror {
100 struct per_session_data__echogen {
108 struct per_session_data__lws_status {
109 struct per_session_data__lws_status *list;
110 struct timeval tv_established;
113 char user_agent[512];
119 callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
120 void *in, size_t len);
122 callback_lws_mirror(struct lws *wsi, enum lws_callback_reasons reason,
123 void *user, void *in, size_t len);
125 callback_dumb_increment(struct lws *wsi, enum lws_callback_reasons reason,
126 void *user, void *in, size_t len);
128 callback_lws_echogen(struct lws *wsi, enum lws_callback_reasons reason,
129 void *user, void *in, size_t len);
131 callback_lws_status(struct lws *wsi, enum lws_callback_reasons reason,
132 void *user, void *in, size_t len);
136 dump_handshake_info(struct lws *wsi);