comparison src/event/ngx_event_quic_transport.c @ 7739:cb75f194f1f0 quic

Implemented sending HANDSHAKE_DONE frame after handshake. This makes it possible to switch to draft 27 by default.
author Vladimir Homutov <vl@nginx.com>
date Tue, 24 Mar 2020 11:59:14 +0300
parents c9c3a73df6e8
children 19660929e8ff
comparison
equal deleted inserted replaced
7738:7f0981be07c4 7739:cb75f194f1f0
64 u_char *dst); 64 u_char *dst);
65 65
66 static size_t ngx_quic_create_ack(u_char *p, ngx_quic_ack_frame_t *ack); 66 static size_t ngx_quic_create_ack(u_char *p, ngx_quic_ack_frame_t *ack);
67 static size_t ngx_quic_create_crypto(u_char *p, 67 static size_t ngx_quic_create_crypto(u_char *p,
68 ngx_quic_crypto_frame_t *crypto); 68 ngx_quic_crypto_frame_t *crypto);
69 static size_t ngx_quic_create_hs_done(u_char *p);
69 static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf); 70 static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf);
70 static size_t ngx_quic_create_max_streams(u_char *p, 71 static size_t ngx_quic_create_max_streams(u_char *p,
71 ngx_quic_max_streams_frame_t *ms); 72 ngx_quic_max_streams_frame_t *ms);
72 static size_t ngx_quic_create_max_stream_data(u_char *p, 73 static size_t ngx_quic_create_max_stream_data(u_char *p,
73 ngx_quic_max_stream_data_frame_t *ms); 74 ngx_quic_max_stream_data_frame_t *ms);
880 f->u.streams_blocked.limit, 881 f->u.streams_blocked.limit,
881 f->u.streams_blocked.bidi); 882 f->u.streams_blocked.bidi);
882 883
883 break; 884 break;
884 885
885 /* TODO: implement parsing for all frames below */ 886 case NGX_QUIC_FT_HANDSHAKE_DONE:
887 /* only sent by server, not by client */
888 goto not_allowed;
889
886 case NGX_QUIC_FT_NEW_TOKEN: 890 case NGX_QUIC_FT_NEW_TOKEN:
887 case NGX_QUIC_FT_HANDSHAKE_DONE:
888 891
889 if (!ngx_quic_short_pkt(flags)) { 892 if (!ngx_quic_short_pkt(flags)) {
890 goto not_allowed; 893 goto not_allowed;
891 } 894 }
895
896 /* TODO: implement */
892 897
893 ngx_log_error(NGX_LOG_ERR, pkt->log, 0, 898 ngx_log_error(NGX_LOG_ERR, pkt->log, 0,
894 "unimplemented frame type 0x%xi in packet", f->type); 899 "unimplemented frame type 0x%xi in packet", f->type);
895 900
896 break; 901 break;
1062 case NGX_QUIC_FT_ACK: 1067 case NGX_QUIC_FT_ACK:
1063 return ngx_quic_create_ack(p, &f->u.ack); 1068 return ngx_quic_create_ack(p, &f->u.ack);
1064 1069
1065 case NGX_QUIC_FT_CRYPTO: 1070 case NGX_QUIC_FT_CRYPTO:
1066 return ngx_quic_create_crypto(p, &f->u.crypto); 1071 return ngx_quic_create_crypto(p, &f->u.crypto);
1072
1073 case NGX_QUIC_FT_HANDSHAKE_DONE:
1074 return ngx_quic_create_hs_done(p);
1067 1075
1068 case NGX_QUIC_FT_STREAM0: 1076 case NGX_QUIC_FT_STREAM0:
1069 case NGX_QUIC_FT_STREAM1: 1077 case NGX_QUIC_FT_STREAM1:
1070 case NGX_QUIC_FT_STREAM2: 1078 case NGX_QUIC_FT_STREAM2:
1071 case NGX_QUIC_FT_STREAM3: 1079 case NGX_QUIC_FT_STREAM3:
1140 1148
1141 ngx_quic_build_int(&p, NGX_QUIC_FT_CRYPTO); 1149 ngx_quic_build_int(&p, NGX_QUIC_FT_CRYPTO);
1142 ngx_quic_build_int(&p, crypto->offset); 1150 ngx_quic_build_int(&p, crypto->offset);
1143 ngx_quic_build_int(&p, crypto->len); 1151 ngx_quic_build_int(&p, crypto->len);
1144 p = ngx_cpymem(p, crypto->data, crypto->len); 1152 p = ngx_cpymem(p, crypto->data, crypto->len);
1153
1154 return p - start;
1155 }
1156
1157
1158 static size_t
1159 ngx_quic_create_hs_done(u_char *p)
1160 {
1161 u_char *start;
1162
1163 if (p == NULL) {
1164 return ngx_quic_varint_len(NGX_QUIC_FT_HANDSHAKE_DONE);
1165 }
1166
1167 start = p;
1168
1169 ngx_quic_build_int(&p, NGX_QUIC_FT_HANDSHAKE_DONE);
1145 1170
1146 return p - start; 1171 return p - start;
1147 } 1172 }
1148 1173
1149 1174