Lines Matching refs:ws
140 static CURLcode ws_send_raw_blocking(CURL *data, struct websocket *ws,
347 static void update_meta(struct websocket *ws, in update_meta() argument
353 ws->frame.age = frame_age; in update_meta()
354 ws->frame.flags = frame_flags; in update_meta()
355 ws->frame.offset = payload_offset; in update_meta()
356 ws->frame.len = cur_len; in update_meta()
357 ws->frame.bytesleft = (payload_len - payload_offset - cur_len); in update_meta()
384 struct websocket *ws; member
398 struct websocket *ws = ctx->ws; in ws_cw_dec_next() local
413 update_meta(ws, frame_age, frame_flags, payload_offset, in ws_cw_dec_next()
430 struct websocket *ws; in ws_cw_write() local
436 ws = data->conn->proto.ws; in ws_cw_write()
437 if(!ws) { in ws_cw_write()
455 pass_ctx.ws = ws; in ws_cw_write()
458 result = ws_dec_pass(&ws->dec, data, &ctx->buf, in ws_cw_write()
756 struct websocket *ws; in Curl_ws_accept() local
761 ws = data->conn->proto.ws; in Curl_ws_accept()
762 if(!ws) { in Curl_ws_accept()
764 ws = calloc(1, sizeof(*ws)); in Curl_ws_accept()
765 if(!ws) in Curl_ws_accept()
767 data->conn->proto.ws = ws; in Curl_ws_accept()
780 Curl_bufq_init2(&ws->recvbuf, chunk_size, WS_CHUNK_COUNT, in Curl_ws_accept()
782 Curl_bufq_init2(&ws->sendbuf, chunk_size, WS_CHUNK_COUNT, in Curl_ws_accept()
784 ws_dec_init(&ws->dec); in Curl_ws_accept()
785 ws_enc_init(&ws->enc); in Curl_ws_accept()
788 Curl_bufq_reset(&ws->recvbuf); in Curl_ws_accept()
789 ws_dec_reset(&ws->dec); in Curl_ws_accept()
790 ws_enc_reset(&ws->enc); in Curl_ws_accept()
813 result = Curl_rand(data, (unsigned char *)&ws->enc.mask, in Curl_ws_accept()
814 sizeof(ws->enc.mask)); in Curl_ws_accept()
818 ws->enc.mask[0], ws->enc.mask[1], ws->enc.mask[2], ws->enc.mask[3]); in Curl_ws_accept()
837 nwritten = Curl_bufq_write(&ws->recvbuf, (const unsigned char *)mem, in Curl_ws_accept()
933 struct websocket *ws; in curl_ws_recv() local
952 ws = conn->proto.ws; in curl_ws_recv()
953 if(!ws) { in curl_ws_recv()
968 if(Curl_bufq_is_empty(&ws->recvbuf)) { in curl_ws_recv()
969 ssize_t n = Curl_bufq_slurp(&ws->recvbuf, nw_in_recv, data, &result); in curl_ws_recv()
979 Curl_bufq_len(&ws->recvbuf)); in curl_ws_recv()
982 result = ws_dec_pass(&ws->dec, data, &ws->recvbuf, in curl_ws_recv()
986 ws_dec_info(&ws->dec, data, "need more input"); in curl_ws_recv()
1003 update_meta(ws, ctx.frame_age, ctx.frame_flags, ctx.payload_offset, in curl_ws_recv()
1005 *metap = &ws->frame; in curl_ws_recv()
1006 *nread = ws->frame.len; in curl_ws_recv()
1009 buflen, *nread, ws->frame.offset, ws->frame.bytesleft); in curl_ws_recv()
1013 static CURLcode ws_flush(struct Curl_easy *data, struct websocket *ws, in ws_flush() argument
1016 if(!Curl_bufq_is_empty(&ws->sendbuf)) { in ws_flush()
1021 while(Curl_bufq_peek(&ws->sendbuf, &out, &outlen)) { in ws_flush()
1023 result = ws_send_raw_blocking(data, ws, (char *)out, outlen); in ws_flush()
1036 Curl_bufq_len(&ws->sendbuf)); in ws_flush()
1045 Curl_bufq_skip(&ws->sendbuf, n); in ws_flush()
1052 static CURLcode ws_send_raw_blocking(CURL *d, struct websocket *ws, in ws_send_raw_blocking() argument
1059 (void)ws; in ws_send_raw_blocking()
1097 struct websocket *ws = data->conn->proto.ws; in ws_send_raw() local
1100 if(!ws) { in ws_send_raw()
1112 result = ws_flush(data, ws, TRUE); in ws_send_raw()
1115 result = ws_send_raw_blocking(data, ws, buffer, buflen); in ws_send_raw()
1119 result = ws_flush(data, ws, FALSE); in ws_send_raw()
1135 struct websocket *ws; in curl_ws_send() local
1155 if(!data->conn->proto.ws) { in curl_ws_send()
1160 ws = data->conn->proto.ws; in curl_ws_send()
1163 result = ws_flush(data, ws, FALSE); in curl_ws_send()
1178 space = Curl_bufq_space(&ws->sendbuf); in curl_ws_send()
1180 buflen, Curl_bufq_len(&ws->sendbuf), space); in curl_ws_send()
1189 n = ws_enc_write_head(data, &ws->enc, flags, fragsize, in curl_ws_send()
1190 &ws->sendbuf, &result); in curl_ws_send()
1195 if((curl_off_t)buflen > ws->enc.payload_remain) { in curl_ws_send()
1198 buflen, ws->enc.payload_remain); in curl_ws_send()
1202 else if(!ws->enc.payload_remain) { in curl_ws_send()
1203 n = ws_enc_write_head(data, &ws->enc, flags, (curl_off_t)buflen, in curl_ws_send()
1204 &ws->sendbuf, &result); in curl_ws_send()
1209 n = ws_enc_write_payload(&ws->enc, data, in curl_ws_send()
1210 buffer, buflen, &ws->sendbuf, &result); in curl_ws_send()
1215 while(!result && (buflen || !Curl_bufq_is_empty(&ws->sendbuf))) { in curl_ws_send()
1217 result = ws_flush(data, ws, Curl_is_in_callback(data)); in curl_ws_send()
1226 n = ws_enc_write_payload(&ws->enc, data, in curl_ws_send()
1227 buffer, buflen, &ws->sendbuf, &result); in curl_ws_send()
1230 payload_added = Curl_bufq_len(&ws->sendbuf); in curl_ws_send()
1248 result = ws_flush(data, ws, TRUE); in curl_ws_send()
1255 result = Curl_bufq_unwrite(&ws->sendbuf, 1); in curl_ws_send()
1270 if(conn && conn->proto.ws) { in ws_free()
1271 Curl_bufq_free(&conn->proto.ws->recvbuf); in ws_free()
1272 Curl_bufq_free(&conn->proto.ws->sendbuf); in ws_free()
1273 Curl_safefree(conn->proto.ws); in ws_free()
1302 data->conn->proto.ws && !data->set.ws_raw_mode) in curl_ws_meta()
1303 return &data->conn->proto.ws->frame; in curl_ws_meta()