Mercurial > hg > nginx
comparison src/event/ngx_event_quic.c @ 8207:cc8d211cb45c quic
Initial parsing of STREAM frames.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 11 Mar 2020 15:41:35 +0300 |
parents | 8d6ac639feac |
children | 4ae9ac69ab93 |
comparison
equal
deleted
inserted
replaced
8206:8d6ac639feac | 8207:cc8d211cb45c |
---|---|
102 #define NGX_QUIC_FT_ACK_ECN 0x03 | 102 #define NGX_QUIC_FT_ACK_ECN 0x03 |
103 #define NGX_QUIC_FT_RESET_STREAM 0x04 | 103 #define NGX_QUIC_FT_RESET_STREAM 0x04 |
104 #define NGX_QUIC_FT_STOP_SENDING 0x05 | 104 #define NGX_QUIC_FT_STOP_SENDING 0x05 |
105 #define NGX_QUIC_FT_CRYPTO 0x06 | 105 #define NGX_QUIC_FT_CRYPTO 0x06 |
106 #define NGX_QUIC_FT_NEW_TOKEN 0x07 | 106 #define NGX_QUIC_FT_NEW_TOKEN 0x07 |
107 #define NGX_QUIC_FT_STREAM 0x08 // - 0x0f | 107 #define NGX_QUIC_FT_STREAM 0x08 |
108 #define NGX_QUIC_FT_STREAM1 0x09 | |
109 #define NGX_QUIC_FT_STREAM2 0x0A | |
110 #define NGX_QUIC_FT_STREAM3 0x0B | |
111 #define NGX_QUIC_FT_STREAM4 0x0C | |
112 #define NGX_QUIC_FT_STREAM5 0x0D | |
113 #define NGX_QUIC_FT_STREAM6 0x0E | |
114 #define NGX_QUIC_FT_STREAM7 0x0F | |
108 #define NGX_QUIC_FT_MAX_DATA 0x10 | 115 #define NGX_QUIC_FT_MAX_DATA 0x10 |
109 #define NGX_QUIC_FT_MAX_STREAM_DATA 0x11 | 116 #define NGX_QUIC_FT_MAX_STREAM_DATA 0x11 |
110 #define NGX_QUIC_FT_MAX_STREAMS 0x12 | 117 #define NGX_QUIC_FT_MAX_STREAMS 0x12 |
111 #define NGX_QUIC_FT_MAX_STREAMS2 0x13 // XXX | 118 #define NGX_QUIC_FT_MAX_STREAMS2 0x13 // XXX |
112 #define NGX_QUIC_FT_DATA_BLOCKED 0x14 | 119 #define NGX_QUIC_FT_DATA_BLOCKED 0x14 |
173 u_char cid[20]; | 180 u_char cid[20]; |
174 u_char srt[16]; | 181 u_char srt[16]; |
175 } ngx_quic_ncid_t; | 182 } ngx_quic_ncid_t; |
176 | 183 |
177 | 184 |
185 typedef struct { | |
186 uint64_t stream_id; | |
187 uint64_t offset; | |
188 uint64_t length; | |
189 u_char *data; | |
190 } ngx_quic_stream_frame_t; | |
191 | |
192 | |
178 struct ngx_quic_frame_s { | 193 struct ngx_quic_frame_s { |
179 ngx_uint_t type; | 194 ngx_uint_t type; |
180 ngx_quic_level_t level; | 195 ngx_quic_level_t level; |
181 ngx_quic_frame_t *next; | 196 ngx_quic_frame_t *next; |
182 union { | 197 union { |
183 ngx_quic_crypto_frame_t crypto; | 198 ngx_quic_crypto_frame_t crypto; |
184 ngx_quic_ack_frame_t ack; | 199 ngx_quic_ack_frame_t ack; |
185 ngx_quic_ncid_t ncid; | 200 ngx_quic_ncid_t ncid; |
201 ngx_quic_stream_frame_t stream; | |
186 // more frames | 202 // more frames |
187 } u; | 203 } u; |
188 | 204 |
189 u_char info[128]; // for debug purposes | 205 u_char info[128]; // for debug purposes |
190 }; | 206 }; |
1483 | 1499 |
1484 // TODO: parse connection close here | 1500 // TODO: parse connection close here |
1485 return NGX_ERROR; | 1501 return NGX_ERROR; |
1486 break; | 1502 break; |
1487 | 1503 |
1504 case NGX_QUIC_FT_STREAM: | |
1505 case NGX_QUIC_FT_STREAM1: | |
1506 case NGX_QUIC_FT_STREAM2: | |
1507 case NGX_QUIC_FT_STREAM3: | |
1508 case NGX_QUIC_FT_STREAM4: | |
1509 case NGX_QUIC_FT_STREAM5: | |
1510 case NGX_QUIC_FT_STREAM6: | |
1511 case NGX_QUIC_FT_STREAM7: | |
1512 | |
1513 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
1514 "STREAM frame, type: 0x%xi", frame->type); | |
1515 | |
1516 frame->u.stream.stream_id = ngx_quic_parse_int(&p); | |
1517 if (frame->type & 0x04) { | |
1518 frame->u.stream.offset = ngx_quic_parse_int(&p); | |
1519 } else { | |
1520 frame->u.stream.offset = 0; | |
1521 } | |
1522 | |
1523 if (frame->type & 0x02) { | |
1524 frame->u.stream.length = ngx_quic_parse_int(&p); | |
1525 } else { | |
1526 frame->u.stream.length = end - p; /* up to packet end */ | |
1527 } | |
1528 | |
1529 frame->u.stream.data = p; | |
1530 | |
1531 p += frame->u.stream.length; | |
1532 | |
1533 break; | |
1534 | |
1488 default: | 1535 default: |
1489 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, | 1536 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
1490 "unknown frame type %xi", frame->type); | 1537 "unknown frame type %xi", frame->type); |
1491 return NGX_ERROR; | 1538 return NGX_ERROR; |
1492 } | 1539 } |
1669 "NCID: { seq=%ui retire=%ui len=%ui}", | 1716 "NCID: { seq=%ui retire=%ui len=%ui}", |
1670 frame.u.ncid.seqnum, | 1717 frame.u.ncid.seqnum, |
1671 frame.u.ncid.retire, | 1718 frame.u.ncid.retire, |
1672 frame.u.ncid.len); | 1719 frame.u.ncid.len); |
1673 continue; | 1720 continue; |
1721 | |
1722 case NGX_QUIC_FT_STREAM: | |
1723 case NGX_QUIC_FT_STREAM1: | |
1724 case NGX_QUIC_FT_STREAM2: | |
1725 case NGX_QUIC_FT_STREAM3: | |
1726 case NGX_QUIC_FT_STREAM4: | |
1727 case NGX_QUIC_FT_STREAM5: | |
1728 case NGX_QUIC_FT_STREAM6: | |
1729 case NGX_QUIC_FT_STREAM7: | |
1730 | |
1731 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
1732 "STREAM frame 0x%xi id 0x%xi off 0x%xi len 0x%xi", | |
1733 frame.type, | |
1734 frame.u.stream.stream_id, | |
1735 frame.u.stream.offset, | |
1736 frame.u.stream.length); | |
1737 | |
1738 ngx_quic_hexdump0(c->log, "STREAM.data", | |
1739 frame.u.stream.data, frame.u.stream.length); | |
1740 break; | |
1674 | 1741 |
1675 default: | 1742 default: |
1676 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 1743 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
1677 "unexpected frame type 0x%xd in packet", frame.type); | 1744 "unexpected frame type 0x%xd in packet", frame.type); |
1678 return NGX_ERROR; | 1745 return NGX_ERROR; |