Lines Matching refs:dec

111 static void ws_dec_info(struct ws_decoder *dec, struct Curl_easy *data,  in ws_dec_info()  argument
114 switch(dec->head_len) { in ws_dec_info()
119 ws_frame_name_of_op(dec->head[0]), in ws_dec_info()
120 (dec->head[0] & WSBIT_FIN) ? "" : " NON-FINAL"); in ws_dec_info()
123 if(dec->head_len < dec->head_total) { in ws_dec_info()
125 ws_frame_name_of_op(dec->head[0]), in ws_dec_info()
126 (dec->head[0] & WSBIT_FIN) ? "" : " NON-FINAL", in ws_dec_info()
127 dec->head_len, dec->head_total); in ws_dec_info()
132 msg, ws_frame_name_of_op(dec->head[0]), in ws_dec_info()
133 (dec->head[0] & WSBIT_FIN) ? "" : " NON-FINAL", in ws_dec_info()
134 dec->payload_offset, dec->payload_len); in ws_dec_info()
151 static void ws_dec_reset(struct ws_decoder *dec) in ws_dec_reset() argument
153 dec->frame_age = 0; in ws_dec_reset()
154 dec->frame_flags = 0; in ws_dec_reset()
155 dec->payload_offset = 0; in ws_dec_reset()
156 dec->payload_len = 0; in ws_dec_reset()
157 dec->head_len = dec->head_total = 0; in ws_dec_reset()
158 dec->state = WS_DEC_INIT; in ws_dec_reset()
161 static void ws_dec_init(struct ws_decoder *dec) in ws_dec_init() argument
163 ws_dec_reset(dec); in ws_dec_init()
166 static CURLcode ws_dec_read_head(struct ws_decoder *dec, in ws_dec_read_head() argument
174 if(dec->head_len == 0) { in ws_dec_read_head()
175 dec->head[0] = *inbuf; in ws_dec_read_head()
178 dec->frame_flags = ws_frame_op2flags(dec->head[0]); in ws_dec_read_head()
179 if(!dec->frame_flags) { in ws_dec_read_head()
180 failf(data, "WS: unknown opcode: %x", dec->head[0]); in ws_dec_read_head()
181 ws_dec_reset(dec); in ws_dec_read_head()
184 dec->head_len = 1; in ws_dec_read_head()
188 else if(dec->head_len == 1) { in ws_dec_read_head()
189 dec->head[1] = *inbuf; in ws_dec_read_head()
191 dec->head_len = 2; in ws_dec_read_head()
193 if(dec->head[1] & WSBIT_MASK) { in ws_dec_read_head()
196 ws_dec_reset(dec); in ws_dec_read_head()
200 if(dec->head[1] == 126) { in ws_dec_read_head()
201 dec->head_total = 4; in ws_dec_read_head()
204 else if(dec->head[1] == 127) { in ws_dec_read_head()
205 dec->head_total = 10; in ws_dec_read_head()
209 dec->head_total = 2; in ws_dec_read_head()
213 if(dec->head_len < dec->head_total) { in ws_dec_read_head()
214 dec->head[dec->head_len] = *inbuf; in ws_dec_read_head()
216 ++dec->head_len; in ws_dec_read_head()
217 if(dec->head_len < dec->head_total) { in ws_dec_read_head()
223 DEBUGASSERT(dec->head_len == dec->head_total); in ws_dec_read_head()
224 switch(dec->head_total) { in ws_dec_read_head()
226 dec->payload_len = dec->head[1]; in ws_dec_read_head()
229 dec->payload_len = (dec->head[2] << 8) | dec->head[3]; in ws_dec_read_head()
232 if(dec->head[2] > 127) { in ws_dec_read_head()
236 dec->payload_len = ((curl_off_t)dec->head[2] << 56) | in ws_dec_read_head()
237 (curl_off_t)dec->head[3] << 48 | in ws_dec_read_head()
238 (curl_off_t)dec->head[4] << 40 | in ws_dec_read_head()
239 (curl_off_t)dec->head[5] << 32 | in ws_dec_read_head()
240 (curl_off_t)dec->head[6] << 24 | in ws_dec_read_head()
241 (curl_off_t)dec->head[7] << 16 | in ws_dec_read_head()
242 (curl_off_t)dec->head[8] << 8 | in ws_dec_read_head()
243 dec->head[9]; in ws_dec_read_head()
252 dec->frame_age = 0; in ws_dec_read_head()
253 dec->payload_offset = 0; in ws_dec_read_head()
254 ws_dec_info(dec, data, "decoded"); in ws_dec_read_head()
260 static CURLcode ws_dec_pass_payload(struct ws_decoder *dec, in ws_dec_pass_payload() argument
270 curl_off_t remain = dec->payload_len - dec->payload_offset; in ws_dec_pass_payload()
276 nwritten = write_payload(inbuf, inlen, dec->frame_age, dec->frame_flags, in ws_dec_pass_payload()
277 dec->payload_offset, dec->payload_len, in ws_dec_pass_payload()
282 dec->payload_offset += (curl_off_t)nwritten; in ws_dec_pass_payload()
283 remain = dec->payload_len - dec->payload_offset; in ws_dec_pass_payload()
291 static CURLcode ws_dec_pass(struct ws_decoder *dec, in ws_dec_pass() argument
302 switch(dec->state) { in ws_dec_pass()
304 ws_dec_reset(dec); in ws_dec_pass()
305 dec->state = WS_DEC_HEAD; in ws_dec_pass()
308 result = ws_dec_read_head(dec, data, inraw); in ws_dec_pass()
319 dec->state = WS_DEC_PAYLOAD; in ws_dec_pass()
320 if(dec->payload_len == 0) { in ws_dec_pass()
324 nwritten = write_payload(&tmp, 0, dec->frame_age, dec->frame_flags, in ws_dec_pass()
328 dec->state = WS_DEC_INIT; in ws_dec_pass()
333 result = ws_dec_pass_payload(dec, data, inraw, write_payload, write_ctx); in ws_dec_pass()
334 ws_dec_info(dec, data, "passing"); in ws_dec_pass()
338 dec->state = WS_DEC_INIT; in ws_dec_pass()
458 result = ws_dec_pass(&ws->dec, data, &ctx->buf, in ws_cw_write()
784 ws_dec_init(&ws->dec); in Curl_ws_accept()
789 ws_dec_reset(&ws->dec); in Curl_ws_accept()
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()