Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic_transport.c @ 7708:83a78cca8bce quic
Fixed build.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 19 Mar 2020 17:22:43 +0300 |
parents | db745339e54b |
children | 59e639379c7c |
comparison
equal
deleted
inserted
replaced
7707:db745339e54b | 7708:83a78cca8bce |
---|---|
395 | 395 |
396 ngx_int_t | 396 ngx_int_t |
397 ngx_quic_parse_initial_header(ngx_quic_header_t *pkt) | 397 ngx_quic_parse_initial_header(ngx_quic_header_t *pkt) |
398 { | 398 { |
399 u_char *p, *end; | 399 u_char *p, *end; |
400 uint64_t plen; | 400 uint64_t varint; |
401 | 401 |
402 p = pkt->raw->pos; | 402 p = pkt->raw->pos; |
403 | 403 |
404 end = pkt->raw->last; | 404 end = pkt->raw->last; |
405 | 405 |
406 pkt->log->action = "parsing quic initial header"; | 406 pkt->log->action = "parsing quic initial header"; |
407 | 407 |
408 p = ngx_quic_parse_int(p, end, &pkt->token.len); | 408 p = ngx_quic_parse_int(p, end, &varint); |
409 if (p == NULL) { | 409 if (p == NULL) { |
410 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "failed to parse token length"); | 410 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "failed to parse token length"); |
411 return NGX_ERROR; | 411 return NGX_ERROR; |
412 } | 412 } |
413 | 413 |
414 pkt->token.len = varint; | |
415 | |
414 p = ngx_quic_read_bytes(p, end, pkt->token.len, &pkt->token.data); | 416 p = ngx_quic_read_bytes(p, end, pkt->token.len, &pkt->token.data); |
415 if (p == NULL) { | 417 if (p == NULL) { |
416 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, | 418 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, |
417 "packet too short to read token data"); | 419 "packet too short to read token data"); |
418 return NGX_ERROR; | 420 return NGX_ERROR; |
419 } | 421 } |
420 | 422 |
421 p = ngx_quic_parse_int(p, end, &plen); | 423 p = ngx_quic_parse_int(p, end, &varint); |
422 if (p == NULL) { | 424 if (p == NULL) { |
423 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "bad packet length"); | 425 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "bad packet length"); |
424 return NGX_ERROR; | 426 return NGX_ERROR; |
425 } | 427 } |
426 | 428 |
427 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | 429 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
428 "quic packet length: %d", plen); | 430 "quic packet length: %d", varint); |
429 | 431 |
430 if (plen > (uint64_t) ((pkt->data + pkt->len) - p)) { | 432 if (varint > (uint64_t) ((pkt->data + pkt->len) - p)) { |
431 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "truncated initial packet"); | 433 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, "truncated initial packet"); |
432 return NGX_ERROR; | 434 return NGX_ERROR; |
433 } | 435 } |
434 | 436 |
435 pkt->raw->pos = p; | 437 pkt->raw->pos = p; |
436 pkt->len = plen; | 438 pkt->len = varint; |
437 | 439 |
438 ngx_quic_hexdump0(pkt->log, "DCID", pkt->dcid.data, pkt->dcid.len); | 440 ngx_quic_hexdump0(pkt->log, "DCID", pkt->dcid.data, pkt->dcid.len); |
439 ngx_quic_hexdump0(pkt->log, "SCID", pkt->scid.data, pkt->scid.len); | 441 ngx_quic_hexdump0(pkt->log, "SCID", pkt->scid.data, pkt->scid.len); |
440 ngx_quic_hexdump0(pkt->log, "token", pkt->token.data, pkt->token.len); | 442 ngx_quic_hexdump0(pkt->log, "token", pkt->token.data, pkt->token.len); |
441 | 443 |
481 | 483 |
482 ssize_t | 484 ssize_t |
483 ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end, | 485 ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end, |
484 ngx_quic_frame_t *f) | 486 ngx_quic_frame_t *f) |
485 { | 487 { |
486 u_char *p; | 488 u_char *p; |
489 uint64_t varint; | |
487 | 490 |
488 p = start; | 491 p = start; |
489 | 492 |
490 /* TODO: add a check if frame is allowed in this type of packet */ | 493 /* TODO: add a check if frame is allowed in this type of packet */ |
491 | 494 |
492 p = ngx_quic_parse_int(p, end, &f->type); | 495 p = ngx_quic_parse_int(p, end, &varint); |
493 if (p == NULL) { | 496 if (p == NULL) { |
494 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, | 497 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, |
495 "failed to obtain quic frame type"); | 498 "failed to obtain quic frame type"); |
496 return NGX_ERROR; | 499 return NGX_ERROR; |
497 } | 500 } |
501 | |
502 f->type = varint; | |
498 | 503 |
499 switch (f->type) { | 504 switch (f->type) { |
500 | 505 |
501 case NGX_QUIC_FT_CRYPTO: | 506 case NGX_QUIC_FT_CRYPTO: |
502 | 507 |