diff --git a/lib/client-handshake.c b/lib/client-handshake.c index 8bfec2d2..7c642eba 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -308,7 +308,7 @@ oom4: return NULL; failed: - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return NULL; } diff --git a/lib/client-parser.c b/lib/client-parser.c index 567f5cac..07959262 100644 --- a/lib/client-parser.c +++ b/lib/client-parser.c @@ -21,7 +21,7 @@ #include "private-libwebsockets.h" -int libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c) +int lws_client_rx_sm(struct libwebsocket *wsi, unsigned char c) { int callback_action = LWS_CALLBACK_CLIENT_RECEIVE; int handled; diff --git a/lib/client.c b/lib/client.c index 29ee3c95..293df31b 100644 --- a/lib/client.c +++ b/lib/client.c @@ -32,7 +32,7 @@ int lws_handshake_client(struct libwebsocket *wsi, unsigned char **buf, size_t l case LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT: case LWS_CONNMODE_WS_CLIENT: for (n = 0; n < len; n++) - if (libwebsocket_client_rx_sm(wsi, *(*buf)++)) { + if (lws_client_rx_sm(wsi, *(*buf)++)) { lwsl_debug("client_rx_sm failed\n"); return 1; } @@ -78,7 +78,7 @@ int lws_client_socket_service(struct libwebsocket_context *context, lwsl_warn("Proxy connection %p (fd=%d) dead\n", (void *)wsi, pollfd->fd); - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return 0; } @@ -93,7 +93,7 @@ int lws_client_socket_service(struct libwebsocket_context *context, return 0; } - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); lwsl_err("ERROR reading from proxy socket\n"); return 0; @@ -103,7 +103,7 @@ int lws_client_socket_service(struct libwebsocket_context *context, if (strcmp((char *)context->service_buffer, "HTTP/1.0 200 ") && strcmp((char *)context->service_buffer, "HTTP/1.1 200 ") ) { - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); lwsl_err("ERROR proxy: %s\n", context->service_buffer); return 0; @@ -336,7 +336,7 @@ some_wait: } else { lwsl_err("server's cert didn't look good, X509_V_ERR = %d: %s\n", n, ERR_error_string(n, (char *)context->service_buffer)); - libwebsocket_close_and_free_session(context, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return 0; } @@ -354,10 +354,10 @@ some_wait: /* fallthru */ case LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE2: - p = libwebsockets_generate_client_handshake(context, wsi, p); + p = lws_generate_client_handshake(context, wsi, p); if (p == NULL) { lwsl_err("Failed to generate handshake for client\n"); - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return 0; } @@ -371,7 +371,7 @@ some_wait: switch (n) { case LWS_SSL_CAPABLE_ERROR: lwsl_debug("ERROR writing to client socket\n"); - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return 0; case LWS_SSL_CAPABLE_MORE_SERVICE: @@ -433,7 +433,7 @@ some_wait: return 0; } - if (libwebsocket_parse(context, wsi, c)) { + if (lws_parse(context, wsi, c)) { lwsl_warn("problems parsing header\n"); goto bail3; } @@ -459,7 +459,7 @@ some_wait: bail3: lwsl_info( "closing connection at LWS_CONNMODE...SERVER_REPLY\n"); - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return -1; @@ -724,7 +724,7 @@ check_accept: } /* allocate the per-connection user memory (if any) */ - if (libwebsocket_ensure_user_space(wsi)) { + if (lws_ensure_user_space(wsi)) { lwsl_err("Problem allocating wsi user mem\n"); goto bail2; } @@ -825,14 +825,14 @@ bail2: lws_free2(wsi->u.hdr.ah); - libwebsocket_close_and_free_session(context, wsi, close_reason); + lws_close_and_free_session(context, wsi, close_reason); return 1; } char * -libwebsockets_generate_client_handshake(struct libwebsocket_context *context, +lws_generate_client_handshake(struct libwebsocket_context *context, struct libwebsocket *wsi, char *pkt) { char buf[128]; @@ -853,7 +853,7 @@ libwebsockets_generate_client_handshake(struct libwebsocket_context *context, if (n != 16) { lwsl_err("Unable to read from random dev %s\n", SYSTEM_RANDOM_FILEPATH); - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return NULL; } diff --git a/lib/context.c b/lib/context.c index 71154a14..5ef85a21 100644 --- a/lib/context.c +++ b/lib/context.c @@ -292,7 +292,7 @@ lws_context_destroy(struct libwebsocket_context *context) wsi_from_fd(context, context->fds[n].fd); if (!wsi) continue; - libwebsocket_close_and_free_session(context, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS_CONTEXT_DESTROY /* no protocol close */); n--; } diff --git a/lib/handshake.c b/lib/handshake.c index d1e3f9cd..229fb8c0 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -191,7 +191,7 @@ http_postbody: switch (wsi->mode) { case LWS_CONNMODE_WS_SERVING: - if (libwebsocket_interpret_incoming_packet(wsi, buf, len) < 0) { + if (lws_interpret_incoming_packet(wsi, buf, len) < 0) { lwsl_info("interpret_incoming_packet has bailed\n"); goto bail; } @@ -226,8 +226,7 @@ http_complete: bail: lwsl_debug("closing connection at lws_read bail:\n"); - libwebsocket_close_and_free_session(context, wsi, - LWS_CLOSE_STATUS_NOSTATUS); + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return -1; } diff --git a/lib/hpack.c b/lib/hpack.c index 3ac01b03..63c7595c 100644 --- a/lib/hpack.c +++ b/lib/hpack.c @@ -540,7 +540,7 @@ pre_data: if (lws_frag_append(wsi, c1)) return 1; } else { /* name */ - if (libwebsocket_parse(context, wsi, c1)) + if (lws_parse(context, wsi, c1)) return 1; } diff --git a/lib/http2.c b/lib/http2.c index ffedb785..b73d8bf2 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -54,7 +54,7 @@ lws_http2_wsi_from_id(struct libwebsocket *wsi, unsigned int sid) struct libwebsocket * lws_create_server_child_wsi(struct libwebsocket_context *context, struct libwebsocket *parent_wsi, unsigned int sid) { - struct libwebsocket *wsi = libwebsocket_create_new_server_wsi(context); + struct libwebsocket *wsi = lws_create_new_server_wsi(context); if (!wsi) return NULL; @@ -80,7 +80,7 @@ lws_create_server_child_wsi(struct libwebsocket_context *context, struct libwebs wsi->mode = parent_wsi->mode; wsi->protocol = &context->protocols[0]; - libwebsocket_ensure_user_space(wsi); + lws_ensure_user_space(wsi); lwsl_info("%s: %p new child %p, sid %d, user_space=%p\n", __func__, parent_wsi, wsi, sid, wsi->user_space); diff --git a/lib/libev.c b/lib/libev.c index 203a0fb9..323e2aaa 100644 --- a/lib/libev.c +++ b/lib/libev.c @@ -30,7 +30,7 @@ void lws_feature_status_libev(struct lws_context_creation_info *info) } static void -libwebsocket_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents) +lws_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents) { struct libwebsocket_pollfd eventfd; struct lws_io_watcher *lws_io = container_of(watcher, struct lws_io_watcher, watcher); @@ -92,7 +92,7 @@ lws_initloop( * Initialize the accept w_accept with the listening socket * and register a callback for read operations: */ - ev_io_init(w_accept, libwebsocket_accept_cb, + ev_io_init(w_accept, lws_accept_cb, context->listen_service_fd, EV_READ); ev_io_start(context->io_loop,w_accept); @@ -144,8 +144,8 @@ lws_libev_accept(struct libwebsocket_context *context, new_wsi->w_read.context = context; new_wsi->w_write.context = context; - ev_io_init(r, libwebsocket_accept_cb, accept_fd, EV_READ); - ev_io_init(w, libwebsocket_accept_cb, accept_fd, EV_WRITE); + ev_io_init(r, lws_accept_cb, accept_fd, EV_READ); + ev_io_init(w, lws_accept_cb, accept_fd, EV_WRITE); } LWS_VISIBLE void diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 9cdd29a2..a4fb792b 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -61,7 +61,7 @@ lws_free_wsi(struct libwebsocket *wsi) } void -libwebsocket_close_and_free_session(struct libwebsocket_context *context, +lws_close_and_free_session(struct libwebsocket_context *context, struct libwebsocket *wsi, enum lws_close_status reason) { int n, m, ret; @@ -324,7 +324,7 @@ just_kill_connection: } LWS_VISIBLE int -libwebsockets_get_addresses(struct libwebsocket_context *context, +lws_get_addresses(struct libwebsocket_context *context, void *ads, char *name, int name_len, char *rip, int rip_len) { @@ -456,7 +456,7 @@ lws_get_peer_addresses(struct libwebsocket_context *context, goto bail; } - ret = libwebsockets_get_addresses(context, p, name, name_len, rip, rip_len); + ret = lws_get_addresses(context, p, name, name_len, rip, rip_len); bail: lws_latency(context, wsi, "lws_get_peer_addresses", ret, 1); @@ -782,7 +782,7 @@ lws_get_reserved_bits(struct libwebsocket *wsi) } int -libwebsocket_ensure_user_space(struct libwebsocket *wsi) +lws_ensure_user_space(struct libwebsocket *wsi) { lwsl_info("%s: %p protocol %p\n", __func__, wsi, wsi->protocol); if (!wsi->protocol) diff --git a/lib/lws-plat-mbed3.cpp b/lib/lws-plat-mbed3.cpp index e0f5b935..7d5ddc2f 100644 --- a/lib/lws-plat-mbed3.cpp +++ b/lib/lws-plat-mbed3.cpp @@ -299,7 +299,7 @@ void lws_conn_listener::onError(Socket *s, socket_error_t err) void lws_conn::onDisconnect(TCPStream *s) { (void)s; - libwebsocket_close_and_free_session(wsi->protocol->owning_server, wsi, + lws_close_and_free_session(wsi->protocol->owning_server, wsi, LWS_CLOSE_STATUS_NOSTATUS); } diff --git a/lib/output.c b/lib/output.c index 16fd1e9d..42261cdc 100644 --- a/lib/output.c +++ b/lib/output.c @@ -22,7 +22,7 @@ #include "private-libwebsockets.h" static int -libwebsocket_0405_frame_mask_generate(struct libwebsocket *wsi) +lws_0405_frame_mask_generate(struct libwebsocket *wsi) { int n; @@ -411,7 +411,7 @@ do_more_inside_frame: if (wsi->mode == LWS_CONNMODE_WS_CLIENT) { if (!wsi->u.ws.inside_frame) - if (libwebsocket_0405_frame_mask_generate(wsi)) { + if (lws_0405_frame_mask_generate(wsi)) { lwsl_err("frame mask generation failed\n"); return -1; } diff --git a/lib/parsers.c b/lib/parsers.c index 83124ffe..c7b47d47 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -206,7 +206,7 @@ static int issue_char(struct libwebsocket *wsi, unsigned char c) return 1; } -int libwebsocket_parse( +int lws_parse( struct libwebsocket_context *context, struct libwebsocket *wsi, unsigned char c) { @@ -281,7 +281,7 @@ int libwebsocket_parse( issue_char(wsi, '%'); wsi->u.hdr.ues = URIES_IDLE; /* regurgitate + assess */ - if (libwebsocket_parse(context, wsi, wsi->u.hdr.esc_stash) < 0) + if (lws_parse(context, wsi, wsi->u.hdr.esc_stash) < 0) return -1; /* continue on to assess c */ break; @@ -578,7 +578,7 @@ LWS_VISIBLE int lws_frame_is_binary(struct libwebsocket *wsi) } int -libwebsocket_rx_sm(struct libwebsocket *wsi, unsigned char c) +lws_rx_sm(struct libwebsocket *wsi, unsigned char c) { struct lws_tokens eff_buf; int ret = 0; diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index b24354fa..01fcbea9 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -459,7 +459,7 @@ struct lws_signal_watcher { #ifdef _WIN32 #define LWS_FD_HASH(fd) ((fd ^ (fd >> 8) ^ (fd >> 16)) % FD_HASHTABLE_MODULUS) -struct libwebsocket_fd_hashtable { +struct lws_fd_hashtable { struct libwebsocket **wsi; int length; }; @@ -472,7 +472,7 @@ struct libwebsocket_context { struct libwebsocket_pollfd *fds; #ifdef _WIN32 /* different implementation between unix and windows */ - struct libwebsocket_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS]; + struct lws_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS]; #else struct libwebsocket **lws_lookup; /* fd to wsi */ #endif @@ -922,7 +922,7 @@ struct libwebsocket { LWS_EXTERN int log_level; LWS_EXTERN void -libwebsocket_close_and_free_session(struct libwebsocket_context *context, +lws_close_and_free_session(struct libwebsocket_context *context, struct libwebsocket *wsi, enum lws_close_status); LWS_EXTERN int @@ -949,10 +949,10 @@ LWS_EXTERN void lws_set_protocol_write_pending(struct libwebsocket_context *cont struct libwebsocket *wsi, enum lws_pending_protocol_send pend); LWS_EXTERN int -libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c); +lws_client_rx_sm(struct libwebsocket *wsi, unsigned char c); LWS_EXTERN int -libwebsocket_parse(struct libwebsocket_context *context, +lws_parse(struct libwebsocket_context *context, struct libwebsocket *wsi, unsigned char c); LWS_EXTERN int @@ -993,10 +993,10 @@ lws_client_connect_2(struct libwebsocket_context *context, struct libwebsocket *wsi); LWS_EXTERN struct libwebsocket * -libwebsocket_create_new_server_wsi(struct libwebsocket_context *context); +lws_create_new_server_wsi(struct libwebsocket_context *context); LWS_EXTERN char * -libwebsockets_generate_client_handshake(struct libwebsocket_context *context, +lws_generate_client_handshake(struct libwebsocket_context *context, struct libwebsocket *wsi, char *pkt); LWS_EXTERN int @@ -1037,7 +1037,7 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context, struct libwebsocket *wsi); LWS_EXTERN int -libwebsocket_rx_sm(struct libwebsocket *wsi, unsigned char c); +lws_rx_sm(struct libwebsocket *wsi, unsigned char c); LWS_EXTERN int lws_issue_raw_ext_access(struct libwebsocket *wsi, @@ -1116,7 +1116,7 @@ lws_hdr_simple_create(struct libwebsocket *wsi, enum lws_token_indexes h, const char *s); LWS_EXTERN int -libwebsocket_ensure_user_space(struct libwebsocket *wsi); +lws_ensure_user_space(struct libwebsocket *wsi); LWS_EXTERN int lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or); @@ -1127,14 +1127,14 @@ int lws_context_init_server(struct lws_context_creation_info *info, LWS_EXTERN int handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi); LWS_EXTERN int -libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi, +lws_interpret_incoming_packet(struct libwebsocket *wsi, unsigned char *buf, size_t len); LWS_EXTERN void lws_server_get_canonical_hostname(struct libwebsocket_context *context, struct lws_context_creation_info *info); #else #define lws_context_init_server(_a, _b) (0) -#define libwebsocket_interpret_incoming_packet(_a, _b, _c) (0) +#define lws_interpret_incoming_packet(_a, _b, _c) (0) #define lws_server_get_canonical_hostname(_a, _b) #endif @@ -1236,7 +1236,7 @@ lws_ssl_pending_no_ssl(struct libwebsocket *wsi); #endif LWS_EXTERN int lws_handshake_client(struct libwebsocket *wsi, unsigned char **buf, size_t len); LWS_EXTERN void - libwebsockets_decode_ssl_error(void); + lws_decode_ssl_error(void); #else #define lws_context_init_client_ssl(_a, _b) (0) #define lws_handshake_client(_a, _b, _c) (0) @@ -1254,7 +1254,7 @@ lws_ssl_pending_no_ssl(struct libwebsocket *wsi); #define lws_handshake_server(_a, _b, _c, _d) (0) #endif -LWS_EXTERN int libwebsockets_get_addresses(struct libwebsocket_context *context, +LWS_EXTERN int lws_get_addresses(struct libwebsocket_context *context, void *ads, char *name, int name_len, char *rip, int rip_len); diff --git a/lib/server-handshake.c b/lib/server-handshake.c index 2e2cf5cd..5962cd8d 100644 --- a/lib/server-handshake.c +++ b/lib/server-handshake.c @@ -196,7 +196,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi) } /* allocate the per-connection user memory (if any) */ - if (libwebsocket_ensure_user_space(wsi)) + if (lws_ensure_user_space(wsi)) goto bail; /* create the response packet */ diff --git a/lib/server.c b/lib/server.c index 7522ef52..d295fcd8 100644 --- a/lib/server.c +++ b/lib/server.c @@ -234,7 +234,7 @@ int lws_http_action(struct libwebsocket_context *context, goto bail_nuke_ah; } - if (libwebsocket_ensure_user_space(wsi)) + if (lws_ensure_user_space(wsi)) goto bail_nuke_ah; for (n = 0; n < ARRAY_SIZE(methods); n++) @@ -356,15 +356,15 @@ int lws_handshake_server(struct libwebsocket_context *context, /* LWS_CONNMODE_WS_SERVING */ while (len--) { - if (libwebsocket_parse(context, wsi, *(*buf)++)) { - lwsl_info("libwebsocket_parse failed\n"); + if (lws_parse(context, wsi, *(*buf)++)) { + lwsl_info("lws_parse failed\n"); goto bail_nuke_ah; } if (wsi->u.hdr.parser_state != WSI_PARSING_COMPLETE) continue; - lwsl_parser("libwebsocket_parse sees parsing complete\n"); + lwsl_parser("lws_parse sees parsing complete\n"); wsi->mode = LWS_CONNMODE_PRE_WS_SERVING_ACCEPT; lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0); @@ -520,7 +520,7 @@ upgrade_ws: } /* allocate wsi->user storage */ - if (libwebsocket_ensure_user_space(wsi)) + if (lws_ensure_user_space(wsi)) goto bail_nuke_ah; /* @@ -597,7 +597,7 @@ bail_nuke_ah: } struct libwebsocket * -libwebsocket_create_new_server_wsi(struct libwebsocket_context *context) +lws_create_new_server_wsi(struct libwebsocket_context *context) { struct libwebsocket *new_wsi; @@ -737,7 +737,7 @@ int lws_server_socket_service(struct libwebsocket_context *context, lws_free_header_table(wsi); /* fallthru */ case LWS_SSL_CAPABLE_ERROR: - libwebsocket_close_and_free_session( + lws_close_and_free_session( context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return 0; @@ -836,7 +836,7 @@ try_pollout: break; } - new_wsi = libwebsocket_create_new_server_wsi(context); + new_wsi = lws_create_new_server_wsi(context); if (new_wsi == NULL) { compatible_close(accept_fd); break; @@ -885,7 +885,7 @@ try_pollout: return 0; fail: - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return 1; } @@ -963,7 +963,7 @@ LWS_VISIBLE int lws_serve_http_file( } -int libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi, +int lws_interpret_incoming_packet(struct libwebsocket *wsi, unsigned char *buf, size_t len) { size_t n = 0; @@ -991,7 +991,7 @@ int libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi, wsi->rxflow_pos++; /* process the byte */ - m = libwebsocket_rx_sm(wsi, buf[n++]); + m = lws_rx_sm(wsi, buf[n++]); if (m < 0) return -1; } diff --git a/lib/service.c b/lib/service.c index cc230d0c..34303993 100644 --- a/lib/service.c +++ b/lib/service.c @@ -263,7 +263,7 @@ user_service: wsi2->u.http2.requested_POLLOUT = 0; if (lws_calllback_as_writeable(context, wsi2)) { lwsl_debug("Closing POLLOUT child\n"); - libwebsocket_close_and_free_session(context, wsi2, + lws_close_and_free_session(context, wsi2, LWS_CLOSE_STATUS_NOSTATUS); } wsi2 = wsi; @@ -307,7 +307,7 @@ lws_service_timeout_check(struct libwebsocket_context *context, * cleanup like flush partials. */ wsi->socket_is_permanently_unusable = 1; - libwebsocket_close_and_free_session(context, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); return 1; } @@ -632,7 +632,7 @@ handle_pending: close_and_handled: lwsl_debug("Close and handled\n"); - libwebsocket_close_and_free_session(context, wsi, + lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS); // pollfd points to something else after the close return 1; diff --git a/lib/ssl.c b/lib/ssl.c index 9a51cd80..21d1a3c8 100644 --- a/lib/ssl.c +++ b/lib/ssl.c @@ -264,7 +264,7 @@ lws_ssl_destroy(struct libwebsocket_context *context) } LWS_VISIBLE void -libwebsockets_decode_ssl_error(void) +lws_decode_ssl_error(void) { char buf[256]; u_long err; @@ -550,7 +550,7 @@ lws_server_socket_service_ssl(struct libwebsocket_context *context, if (new_wsi->ssl == NULL) { lwsl_err("SSL_new failed: %s\n", ERR_error_string(SSL_get_error(new_wsi->ssl, 0), NULL)); - libwebsockets_decode_ssl_error(); + lws_decode_ssl_error(); // TODO: Shouldn't the caller handle this? compatible_close(accept_fd);