comparison src/event/quic/ngx_event_quic.c @ 8953:03b40440c13d quic

QUIC: renamed input handling functions. Now these functions have names ngx_quic_handle_XXX(): - ngx_quic_process_stateless_reset() -> ngx_quic_handle_stateless_reset() - ngx_quic_input() -> ngx_quic_handle_datagram() - ngx_quic_process_packet() -> ngx_quic_handle_packet() - ngx_quic_process_payload() -> ngx_quic_handle_payload()
author Roman Arutyunyan <arut@nginx.com>
date Mon, 27 Dec 2021 16:15:28 +0300
parents 19e063e955bf
children 1e2f4e9c8195
comparison
equal deleted inserted replaced
8952:d78972cf4bac 8953:03b40440c13d
10 #include <ngx_event_quic_connection.h> 10 #include <ngx_event_quic_connection.h>
11 11
12 12
13 static ngx_quic_connection_t *ngx_quic_new_connection(ngx_connection_t *c, 13 static ngx_quic_connection_t *ngx_quic_new_connection(ngx_connection_t *c,
14 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt); 14 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt);
15 static ngx_int_t ngx_quic_process_stateless_reset(ngx_connection_t *c, 15 static ngx_int_t ngx_quic_handle_stateless_reset(ngx_connection_t *c,
16 ngx_quic_header_t *pkt); 16 ngx_quic_header_t *pkt);
17 static void ngx_quic_input_handler(ngx_event_t *rev); 17 static void ngx_quic_input_handler(ngx_event_t *rev);
18 18
19 static ngx_int_t ngx_quic_close_quic(ngx_connection_t *c, ngx_int_t rc); 19 static ngx_int_t ngx_quic_close_quic(ngx_connection_t *c, ngx_int_t rc);
20 static void ngx_quic_close_timer_handler(ngx_event_t *ev); 20 static void ngx_quic_close_timer_handler(ngx_event_t *ev);
21 21
22 static ngx_int_t ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, 22 static ngx_int_t ngx_quic_handle_datagram(ngx_connection_t *c, ngx_buf_t *b,
23 ngx_quic_conf_t *conf); 23 ngx_quic_conf_t *conf);
24 static ngx_int_t ngx_quic_process_packet(ngx_connection_t *c, 24 static ngx_int_t ngx_quic_handle_packet(ngx_connection_t *c,
25 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt); 25 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt);
26 static ngx_int_t ngx_quic_process_payload(ngx_connection_t *c, 26 static ngx_int_t ngx_quic_handle_payload(ngx_connection_t *c,
27 ngx_quic_header_t *pkt); 27 ngx_quic_header_t *pkt);
28 static ngx_int_t ngx_quic_check_csid(ngx_quic_connection_t *qc, 28 static ngx_int_t ngx_quic_check_csid(ngx_quic_connection_t *qc,
29 ngx_quic_header_t *pkt); 29 ngx_quic_header_t *pkt);
30 static ngx_int_t ngx_quic_handle_frames(ngx_connection_t *c, 30 static ngx_int_t ngx_quic_handle_frames(ngx_connection_t *c,
31 ngx_quic_header_t *pkt); 31 ngx_quic_header_t *pkt);
206 ngx_int_t rc; 206 ngx_int_t rc;
207 ngx_quic_connection_t *qc; 207 ngx_quic_connection_t *qc;
208 208
209 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic run"); 209 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic run");
210 210
211 rc = ngx_quic_input(c, c->buffer, conf); 211 rc = ngx_quic_handle_datagram(c, c->buffer, conf);
212 if (rc != NGX_OK) { 212 if (rc != NGX_OK) {
213 ngx_quic_close_connection(c, rc == NGX_DECLINED ? NGX_DONE : NGX_ERROR); 213 ngx_quic_close_connection(c, rc == NGX_DECLINED ? NGX_DONE : NGX_ERROR);
214 return; 214 return;
215 } 215 }
216 216
348 return qc; 348 return qc;
349 } 349 }
350 350
351 351
352 static ngx_int_t 352 static ngx_int_t
353 ngx_quic_process_stateless_reset(ngx_connection_t *c, ngx_quic_header_t *pkt) 353 ngx_quic_handle_stateless_reset(ngx_connection_t *c, ngx_quic_header_t *pkt)
354 { 354 {
355 u_char *tail, ch; 355 u_char *tail, ch;
356 ngx_uint_t i; 356 ngx_uint_t i;
357 ngx_queue_t *q; 357 ngx_queue_t *q;
358 ngx_quic_client_id_t *cid; 358 ngx_quic_client_id_t *cid;
435 return; 435 return;
436 } 436 }
437 437
438 b = c->udp->dgram->buffer; 438 b = c->udp->dgram->buffer;
439 439
440 rc = ngx_quic_input(c, b, NULL); 440 rc = ngx_quic_handle_datagram(c, b, NULL);
441 441
442 if (rc == NGX_ERROR) { 442 if (rc == NGX_ERROR) {
443 ngx_quic_close_connection(c, NGX_ERROR); 443 ngx_quic_close_connection(c, NGX_ERROR);
444 return; 444 return;
445 } 445 }
664 ngx_quic_close_connection(c, NGX_DONE); 664 ngx_quic_close_connection(c, NGX_DONE);
665 } 665 }
666 666
667 667
668 static ngx_int_t 668 static ngx_int_t
669 ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf) 669 ngx_quic_handle_datagram(ngx_connection_t *c, ngx_buf_t *b,
670 ngx_quic_conf_t *conf)
670 { 671 {
671 size_t size; 672 size_t size;
672 u_char *p, *start; 673 u_char *p, *start;
673 ngx_int_t rc; 674 ngx_int_t rc;
674 ngx_uint_t good; 675 ngx_uint_t good;
690 pkt.log = c->log; 691 pkt.log = c->log;
691 pkt.first = (p == start) ? 1 : 0; 692 pkt.first = (p == start) ? 1 : 0;
692 pkt.flags = p[0]; 693 pkt.flags = p[0];
693 pkt.raw->pos++; 694 pkt.raw->pos++;
694 695
695 rc = ngx_quic_process_packet(c, conf, &pkt); 696 rc = ngx_quic_handle_packet(c, conf, &pkt);
696 697
697 #if (NGX_DEBUG) 698 #if (NGX_DEBUG)
698 if (pkt.parsed) { 699 if (pkt.parsed) {
699 ngx_log_debug5(NGX_LOG_DEBUG_EVENT, c->log, 0, 700 ngx_log_debug5(NGX_LOG_DEBUG_EVENT, c->log, 0,
700 "quic packet %s done decr:%d pn:%L perr:%ui rc:%i", 701 "quic packet %s done decr:%d pn:%L perr:%ui rc:%i",
767 return NGX_OK; 768 return NGX_OK;
768 } 769 }
769 770
770 771
771 static ngx_int_t 772 static ngx_int_t
772 ngx_quic_process_packet(ngx_connection_t *c, ngx_quic_conf_t *conf, 773 ngx_quic_handle_packet(ngx_connection_t *c, ngx_quic_conf_t *conf,
773 ngx_quic_header_t *pkt) 774 ngx_quic_header_t *pkt)
774 { 775 {
775 ngx_int_t rc; 776 ngx_int_t rc;
776 ngx_quic_connection_t *qc; 777 ngx_quic_connection_t *qc;
777 778
839 return NGX_DECLINED; 840 return NGX_DECLINED;
840 } 841 }
841 842
842 } 843 }
843 844
844 rc = ngx_quic_process_payload(c, pkt); 845 rc = ngx_quic_handle_payload(c, pkt);
845 846
846 if (rc == NGX_DECLINED && pkt->level == ssl_encryption_application) { 847 if (rc == NGX_DECLINED && pkt->level == ssl_encryption_application) {
847 if (ngx_quic_process_stateless_reset(c, pkt) == NGX_OK) { 848 if (ngx_quic_handle_stateless_reset(c, pkt) == NGX_OK) {
848 ngx_log_error(NGX_LOG_INFO, c->log, 0, 849 ngx_log_error(NGX_LOG_INFO, c->log, 0,
849 "quic stateless reset packet detected"); 850 "quic stateless reset packet detected");
850 851
851 qc->draining = 1; 852 qc->draining = 1;
852 ngx_quic_close_connection(c, NGX_OK); 853 ngx_quic_close_connection(c, NGX_OK);
933 qc = ngx_quic_new_connection(c, conf, pkt); 934 qc = ngx_quic_new_connection(c, conf, pkt);
934 if (qc == NULL) { 935 if (qc == NULL) {
935 return NGX_ERROR; 936 return NGX_ERROR;
936 } 937 }
937 938
938 return ngx_quic_process_payload(c, pkt); 939 return ngx_quic_handle_payload(c, pkt);
939 } 940 }
940 941
941 942
942 static ngx_int_t 943 static ngx_int_t
943 ngx_quic_process_payload(ngx_connection_t *c, ngx_quic_header_t *pkt) 944 ngx_quic_handle_payload(ngx_connection_t *c, ngx_quic_header_t *pkt)
944 { 945 {
945 ngx_int_t rc; 946 ngx_int_t rc;
946 ngx_quic_send_ctx_t *ctx; 947 ngx_quic_send_ctx_t *ctx;
947 ngx_quic_connection_t *qc; 948 ngx_quic_connection_t *qc;
948 static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; 949 static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE];