/* Responsible for reading the request * * if returns >= 0 : the connection will be released * * if returns < 0 : the connection will be released as BAD / broken */ static int wss_read_req(struct tcp_connection* con, int* bytes_read) { int size; /* we need to fix the SSL connection before doing anything */ if (tls_fix_read_conn(con) < 0) { LM_ERR("cannot fix read connection\n"); goto error; } if (WS_STATE(con) != WS_CON_HANDSHAKE_DONE) { size = ws_server_handshake(con); if (size < 0) { LM_ERR("cannot complete WebSocket handshake\n"); goto error; } if (size == 0) goto done; } if (WS_STATE(con) == WS_CON_HANDSHAKE_DONE && ws_process(con) < 0) goto error; done: return 0; error: /* connection will be released as ERROR */ return -1; }
/* Responsible for reading the request * * if returns >= 0 : the connection will be released * * if returns < 0 : the connection will be released as BAD / broken */ static int ws_read_req(struct tcp_connection* con, int* bytes_read) { int size; if (WS_STATE(con) != WS_CON_HANDSHAKE_DONE) { size = ws_server_handshake(con); if (size < 0) { LM_ERR("cannot complete WebSocket handshake\n"); goto error; } if (size == 0) goto done; } if (WS_STATE(con) == WS_CON_HANDSHAKE_DONE && ws_process(con) < 0) goto error; done: return 0; error: /* connection will be released as ERROR */ return -1; }
/* Responsible for reading the request * * if returns >= 0 : the connection will be released * * if returns < 0 : the connection will be released as BAD / broken */ static int wss_read_req(struct tcp_connection* con, int* bytes_read) { int size; struct ws_data* d; /* we need to fix the SSL connection before doing anything */ if (tls_fix_read_conn(con) < 0) { LM_ERR("cannot fix read connection\n"); if ( (d=con->proto_data) && d->dest && d->tprot ) { if ( d->message ) { send_trace_message( d->message, t_dst); d->message = NULL; /* don't allow future traces for this connection */ d->tprot = 0; d->dest = 0; } } goto error; } d=con->proto_data; if (WS_STATE(con) != WS_CON_HANDSHAKE_DONE) { size = ws_server_handshake(con); if (size < 0) { LM_ERR("cannot complete WebSocket handshake\n"); goto error; } d = con->proto_data; /* there is a corner case when the TLS handhskae is traced * but the connection is closed with * EOF before reaching this code if the certificate is not * validated by the client */ if ( con->flags&F_CONN_ACCEPTED && (WS_STATE(con)==WS_CON_HANDSHAKE_DONE || con->state==S_CONN_EOF) && d && d->dest && d->tprot ) { if ( d->message ) { send_trace_message( d->message, t_dst); d->message = NULL; } /* don't allow future traces for this connection */ d->tprot = 0; d->dest = 0; } if (size == 0) goto done; } if (WS_STATE(con) == WS_CON_HANDSHAKE_DONE && ws_process(con) < 0) goto error; done: return 0; error: /* connection will be released as ERROR */ return -1; }