Mercurial > hg > nginx
comparison src/event/ngx_event_quic.c @ 8251:c217a907ce42 quic
Added checks for permitted frame types.
+ cleanup in macros for packet types
+ some style fixes in quic_transport.h (case, indentation)
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Fri, 20 Mar 2020 20:03:44 +0300 |
parents | e9891e8ee975 |
children | c955b7eaa2d9 |
comparison
equal
deleted
inserted
replaced
8250:8f9cb6d66662 | 8251:c217a907ce42 |
---|---|
334 | 334 |
335 if (ngx_quic_parse_long_header(pkt) != NGX_OK) { | 335 if (ngx_quic_parse_long_header(pkt) != NGX_OK) { |
336 return NGX_ERROR; | 336 return NGX_ERROR; |
337 } | 337 } |
338 | 338 |
339 if ((pkt->flags & 0xf0) != NGX_QUIC_PKT_INITIAL) { | 339 if (!ngx_quic_pkt_in(pkt->flags)) { |
340 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 340 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
341 "invalid initial packet: 0x%xi", pkt->flags); | 341 "invalid initial packet: 0x%xi", pkt->flags); |
342 return NGX_ERROR; | 342 return NGX_ERROR; |
343 } | 343 } |
344 | 344 |
561 ngx_memzero(&pkt, sizeof(ngx_quic_header_t)); | 561 ngx_memzero(&pkt, sizeof(ngx_quic_header_t)); |
562 pkt.raw = b; | 562 pkt.raw = b; |
563 pkt.data = p; | 563 pkt.data = p; |
564 pkt.len = b->last - p; | 564 pkt.len = b->last - p; |
565 pkt.log = c->log; | 565 pkt.log = c->log; |
566 | 566 pkt.flags = p[0]; |
567 if (p[0] == 0) { | 567 |
568 if (pkt.flags == 0) { | |
568 /* XXX: no idea WTF is this, just ignore */ | 569 /* XXX: no idea WTF is this, just ignore */ |
569 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "FIREFOX: ZEROES"); | 570 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "FIREFOX: ZEROES"); |
570 break; | 571 break; |
571 } | 572 } |
572 | 573 |
573 // TODO: check current state | 574 // TODO: check current state |
574 if (p[0] & NGX_QUIC_PKT_LONG) { | 575 if (ngx_quic_long_pkt(pkt.flags)) { |
575 | 576 |
576 if ((p[0] & 0xf0) == NGX_QUIC_PKT_INITIAL) { | 577 if (ngx_quic_pkt_in(pkt.flags)) { |
577 rc = ngx_quic_initial_input(c, &pkt); | 578 rc = ngx_quic_initial_input(c, &pkt); |
578 | 579 |
579 } else if ((p[0] & 0xf0) == NGX_QUIC_PKT_HANDSHAKE) { | 580 } else if (ngx_quic_pkt_hs(pkt.flags)) { |
580 rc = ngx_quic_handshake_input(c, &pkt); | 581 rc = ngx_quic_handshake_input(c, &pkt); |
581 | 582 |
582 } else { | 583 } else { |
583 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 584 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
584 "BUG: unknown quic state"); | 585 "BUG: unknown quic state"); |
663 if (ngx_memcmp(pkt->scid.data, qc->scid.data, qc->scid.len) != 0) { | 664 if (ngx_memcmp(pkt->scid.data, qc->scid.data, qc->scid.len) != 0) { |
664 ngx_log_error(NGX_LOG_INFO, c->log, 0, "unexpected quic scid"); | 665 ngx_log_error(NGX_LOG_INFO, c->log, 0, "unexpected quic scid"); |
665 return NGX_ERROR; | 666 return NGX_ERROR; |
666 } | 667 } |
667 | 668 |
668 if ((pkt->flags & 0xf0) != NGX_QUIC_PKT_HANDSHAKE) { | 669 if (!ngx_quic_pkt_hs(pkt->flags)) { |
669 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 670 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
670 "invalid packet type: 0x%xi", pkt->flags); | 671 "invalid packet type: 0x%xi", pkt->flags); |
671 return NGX_ERROR; | 672 return NGX_ERROR; |
672 } | 673 } |
673 | 674 |
732 do_close = 0; | 733 do_close = 0; |
733 | 734 |
734 while (p < end) { | 735 while (p < end) { |
735 | 736 |
736 len = ngx_quic_parse_frame(pkt, p, end, &frame); | 737 len = ngx_quic_parse_frame(pkt, p, end, &frame); |
738 | |
739 if (len == NGX_DECLINED) { | |
740 /* TODO: handle protocol violation: | |
741 * such frame not allowed in this packet | |
742 */ | |
743 return NGX_ERROR; | |
744 } | |
745 | |
737 if (len < 0) { | 746 if (len < 0) { |
738 return NGX_ERROR; | 747 return NGX_ERROR; |
739 } | 748 } |
740 | 749 |
741 p += len; | 750 p += len; |