struct protoent* tcp_proto;
#endif
- fprintf(stderr, "__libwebsocket_client_connect_2\n");
+ debug("__libwebsocket_client_connect_2\n");
wsi->candidate_children_list = NULL;
* prepare the actual connection (to the proxy, if any)
*/
- fprintf(stderr, "__libwebsocket_client_connect_2: address %s", wsi->c_address);
+ debug("__libwebsocket_client_connect_2: address %s", wsi->c_address);
server_hostent = gethostbyname(wsi->c_address);
if (server_hostent == NULL) {
goto oom4;
}
- fprintf(stderr, "connected\n");
+ debug("connected\n");
/* into fd -> wsi hashtable */
}
if (handled) {
- fprintf(stderr, "libwebsocket_client_connect: "
- "ext handling conn\n");
+ debug("libwebsocket_client_connect: ext handling conn\n");
libwebsocket_set_timeout(wsi,
PENDING_TIMEOUT_AWAITING_EXTENSION_CONNECT_RESPONSE, 5);
return wsi;
}
- fprintf(stderr, "libwebsocket_client_connect: direct conn\n");
+ debug("libwebsocket_client_connect: direct conn\n");
return __libwebsocket_client_connect_2(context, wsi);
fprintf(stderr, "deflateInit returned %d\n", n);
return 1;
}
- fprintf(stderr, "zlibs constructed\n");
+ debug("zlibs constructed\n");
break;
case LWS_EXT_CALLBACK_DESTROY:
(void)inflateEnd(&conn->zs_in);
(void)deflateEnd(&conn->zs_out);
- fprintf(stderr, "zlibs destructed\n");
+ debug("zlibs destructed\n");
break;
case LWS_EXT_CALLBACK_PACKET_RX_PREPARSE:
unsigned char *start = pb;
if (channel == 0) {
- fprintf(stderr, "lws_mux_subcommand_header: given ch 0\n");
+ muxdebug("lws_mux_subcommand_header: given ch 0\n");
*((int *)0) = 0;
}
int n;
if (channel == 0) {
- fprintf(stderr, "lws_ext_x_google_mux__send_addchannel: given ch 0\n");
+ muxdebug("lws_ext_x_google_mux__send_addchannel: given ch 0\n");
*((int *)0) = 0;
}
muxdebug("Client LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS in %c\n", c);
if (conn->block_subchannel == 1) {
- fprintf(stderr, "adding ch1\n");
+ muxdebug("adding ch1\n");
wsi_child = wsi;
child_conn = conn;
} else
wsi_child->mode = LWS_CONNMODE_WS_CLIENT;
if (wsi_child->protocol)
- fprintf(stderr, "mux handshake OK for protocol %s\n",
+ muxdebug("mux handshake OK for protocol %s\n",
wsi_child->protocol->name);
else
- fprintf(stderr, "mux child handshake ends up with no protocol!\n");
+ muxdebug("mux child handshake ends up with no protocol!\n");
/*
* inform all extensions, not just active ones since they
default:
// fprintf(stderr, " server\n");
if (libwebsocket_rx_sm(wsi_child, c) < 0) {
- fprintf(stderr, "probs\n");
+ muxdebug("probs\n");
libwebsocket_close_and_free_session(
context,
wsi_child,
wsi_parent->candidate_children_list = wsi;
wsi->mode = LWS_CONNMODE_WS_CLIENT_PENDING_CANDIDATE_CHILD;
- fprintf(stderr, "attaching to existing mux\n");
+ muxdebug("attaching to existing mux\n");
conn = parent_conn;
wsi = wsi_parent;
if (done)
return 1;
- fprintf(stderr, "x-google-mux: unable to mux connection\n");
+ muxdebug("x-google-mux: unable to mux connection\n");
break;
parent_conn = lws_get_extension_user_matching_ext(conn->wsi_parent, ext);
if (parent_conn == 0) {
- fprintf(stderr, "failed to get parent conn\n");
+ muxdebug("failed to get parent conn\n");
break;
}
}
wsi_parent = conn->wsi_parent;
parent_conn = lws_get_extension_user_matching_ext(conn->wsi_parent, ext);
if (parent_conn == 0) {
- fprintf(stderr, "failed to get parent conn\n");
+ muxdebug("failed to get parent conn\n");
break;
}
for (n = 0; n < parent_conn->highest_child_subchannel; n++)
parent_conn = lws_get_extension_user_matching_ext(conn->wsi_parent, ext);
if (parent_conn == 0) {
- fprintf(stderr, "failed to get parent conn\n");
+ muxdebug("failed to get parent conn\n");
return 0;
}
parent_conn->count_children_needing_POLLOUT++;
muxdebug(" count_children_needing_POLLOUT bumped\n");
} else
- fprintf(stderr, "unable to identify parent conn\n");
+ muxdebug("unable to identify parent conn\n");
}
muxdebug(" requesting on parent %p\n", (void *)conn->wsi_parent);
libwebsocket_callback_on_writable(context, conn->wsi_parent);
case LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX:
- fprintf(stderr, "LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX %p\n", (void *)wsi->extension_handles);
+ muxdebug("LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX %p\n",
+ (void *)wsi->extension_handles);
/* send raw if we're not a child */
conn->wsi_children[n]->active_extensions_user[m];
if (!child_conn) {
- fprintf(stderr, "unable to identify child conn\n");
+ muxdebug("unable to identify child conn\n");
continue;
}
if (strcmp(in, "deflate-stream") == 0 &&
client_handshake_generation_is_for_mux_child) {
- fprintf(stderr, "mux banned deflate-stream on child connection\n");
+ muxdebug("mux banned deflate-stream on child connection\n");
return 1; /* disallow */
}
break;
*/
c = wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token;
- fprintf(stderr, "wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token = %s\n", wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token);
+ debug("wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token = %s\n", wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token);
wsi->count_active_extensions = 0;
n = 0;
while (more) {
wsi->count_active_extensions], NULL, 0);
wsi->count_active_extensions++;
- fprintf(stderr, "wsi->count_active_extensions <- %d", wsi->count_active_extensions);
+ debug("wsi->count_active_extensions <- %d",
+ wsi->count_active_extensions);
ext++;
}
if (wsi->parser_state != WSI_PARSING_COMPLETE)
break;
- fprintf(stderr, "seem to be serving, mode is %d\n", wsi->mode);
+ debug("seem to be serving, mode is %d\n", wsi->mode);
- fprintf(stderr, "libwebsocket_parse sees parsing complete\n");
+ debug("libwebsocket_parse sees parsing complete\n");
/* is this websocket protocol or normal http 1.0? */
return 0;
}
- if (!wsi->protocol) {
+ if (!wsi->protocol)
fprintf(stderr, "NULL protocol coming on libwebsocket_read\n");
- }
/*
* It's websocket
goto bail;
}
- fprintf(stderr, "accepted v%02d connection\n",
+ debug("accepted v%02d connection\n",
wsi->ietf_spec_revision);
break;
*/
if (m) {
- fprintf(stderr, "extension vetoed close\n");
+ debug("extension vetoed close\n");
return;
}
}
if (old_state == WSI_STATE_ESTABLISHED &&
reason != LWS_CLOSE_STATUS_NOSTATUS) {
- fprintf(stderr, "sending close indication...\n");
+ debug("sending close indication...\n");
n = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING],
0, LWS_WRITE_CLOSE);
libwebsocket_set_timeout(wsi,
PENDING_TIMEOUT_CLOSE_ACK, 5);
- fprintf(stderr, "sent close indication, awaiting ack\n");
+ debug("sent close indication, awaiting ack\n");
return;
}
just_kill_connection:
- fprintf(stderr, "libwebsocket_close_and_free_session: just_kill_connection\n");
+ debug("libwebsocket_close_and_free_session: just_kill_connection\n");
/*
* we won't be servicing or receiving anything further from this guy
((old_state == WSI_STATE_ESTABLISHED) ||
(old_state == WSI_STATE_RETURNED_CLOSE_ALREADY) ||
(old_state == WSI_STATE_AWAITING_CLOSE_ACK))) {
- fprintf(stderr, "calling back CLOSED\n");
+ debug("calling back CLOSED\n");
wsi->protocol->callback(context, wsi, LWS_CALLBACK_CLOSED,
wsi->user_space, NULL, 0);
- } else {
- fprintf(stderr, "not calling back closed due to old_state=%d\n", old_state);
- }
+ } else
+ debug("not calling back closed due to old_state=%d\n",
+ old_state);
+
/* deallocate any active extension contexts */
/* no we could add more */
continue;
- fprintf(stderr, "choked in POLLOUT service\n");
+ debug("choked in POLLOUT service\n");
/*
* Yes, he's choked. Leave the POLLOUT masked on so we will
*/
if (sec > wsi->pending_timeout_limit) {
- fprintf(stderr, "TIMEDOUT WAITING\n");
+ debug("TIMEDOUT WAITING\n");
libwebsocket_close_and_free_session(context,
wsi, LWS_CLOSE_STATUS_NOSTATUS);
}
if (n) {
/* an extension vetos us */
- fprintf(stderr, "ext %s vetoed\n", (char *)ext->name);
+ debug("ext %s vetoed\n", (char *)ext->name);
ext++;
continue;
}
issue_hdr:
- puts(pkt);
+// puts(pkt);
/* done with these now */
!wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len ||
(!wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len &&
wsi->c_protocol != NULL)) {
- fprintf(stderr, "libwebsocket_client_handshake "
+ debug("libwebsocket_client_handshake "
"missing required header(s)\n");
pkt[len] = '\0';
- fprintf(stderr, "%s", pkt);
+ debug("%s", pkt);
goto bail3;
}
wsi->utf8_token[
WSI_TOKEN_CHALLENGE].token_len);
pkt[len] = '\0';
- fprintf(stderr, "%s", pkt);
+ debug("%s", pkt);
goto bail3;
}
wsi->ietf_spec_revision == 4) ||
(!wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len &&
wsi->c_protocol != NULL)) {
- fprintf(stderr, "libwebsocket_client_handshake "
+ debug("libwebsocket_client_handshake "
"missing required header(s)\n");
pkt[len] = '\0';
- fprintf(stderr, "%s", pkt);
+ debug("%s", pkt);
goto bail3;
}
if (pc == NULL)
fprintf(stderr, "lws_client_interpret_server_handshake: NULL c_protocol\n");
else
- fprintf(stderr, "lws_client_interpret_server_handshake: cPprotocol='%s'\n", pc);
+ debug("lws_client_interpret_server_handshake: cPprotocol='%s'\n", pc);
/*
* confirm the protocol the server wants to talk was in the list
/* instantiate the accepted extensions */
if (!wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token_len) {
- fprintf(stderr, "no client extenstions allowed by server \n");
+ debug("no client extenstions allowed by server \n");
goto check_accept;
}
/* check we actually support it */
- fprintf(stderr, "checking client ext %s\n", ext_name);
+ debug("checking client ext %s\n", ext_name);
n = 0;
ext = wsi->protocol->owning_server->extensions;
n = 1;
- fprintf(stderr, "instantiating client ext %s\n", ext_name);
+ debug("instantiating client ext %s\n", ext_name);
/* instantiate the extension on this conn */
if ((context->protocols[0].callback)(context, wsi,
LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
(void*)(long)accept_fd, NULL, 0)) {
- fprintf(stderr, "Callback denied network connection\n");
+ debug("Callback denied network connection\n");
#ifdef WIN32
closesocket(accept_fd);
#else
wsi->utf8_token[wsi->parser_state].token[
wsi->utf8_token[wsi->parser_state].token_len] = '\0';
wsi->parser_state = WSI_TOKEN_SKIPPING_SAW_CR;
- fprintf(stderr, "*\n");
+ debug("*\n");
break;
}
fprintf(stderr, "seen client close ack\n");
return -1;
}
- fprintf(stderr, "server sees client close packet\n");
+ debug("server sees client close packet\n");
/* parrot the close packet payload back */
n = libwebsocket_write(wsi, (unsigned char *)
&wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING],
* fine he has told us he is closing too, let's
* finish our close
*/
- fprintf(stderr, "seen server's close ack\n");
+ debug("seen server's close ack\n");
return -1;
}
fprintf(stderr, "client sees server close packet len = %d\n", wsi->rx_user_buffer_head);
default:
- fprintf(stderr, "Reserved opcode 0x%2X\n", wsi->opcode);
+ debug("Reserved opcode 0x%2X\n", wsi->opcode);
/*
* It's something special we can't understand here.
* Pass the payload up to the extension's parsing
/* no we could add more */
continue;
- fprintf(stderr, "choked\n");
+ debug("choked\n");
/*
* Yes, he's choked. Don't spill the rest now get a callback