(r *countingByteReader, l uint64, streamID quic.StreamID, qlogger qlogwriter.Recorder)
| 179 | } |
| 180 | |
| 181 | func parseSettingsFrame(r *countingByteReader, l uint64, streamID quic.StreamID, qlogger qlogwriter.Recorder) (*settingsFrame, error) { |
| 182 | if l > 8*(1<<10) { |
| 183 | return nil, fmt.Errorf("unexpected size for SETTINGS frame: %d", l) |
| 184 | } |
| 185 | buf := make([]byte, l) |
| 186 | if _, err := io.ReadFull(r, buf); err != nil { |
| 187 | if err == io.ErrUnexpectedEOF { |
| 188 | return nil, io.EOF |
| 189 | } |
| 190 | return nil, err |
| 191 | } |
| 192 | frame := &settingsFrame{MaxFieldSectionSize: -1} |
| 193 | b := bytes.NewReader(buf) |
| 194 | settingsFrame := qlog.SettingsFrame{MaxFieldSectionSize: -1} |
| 195 | var readMaxFieldSectionSize, readDatagram, readExtendedConnect bool |
| 196 | for b.Len() > 0 { |
| 197 | id, err := quicvarint.Read(b) |
| 198 | if err != nil { // should not happen. We allocated the whole frame already. |
| 199 | return nil, err |
| 200 | } |
| 201 | val, err := quicvarint.Read(b) |
| 202 | if err != nil { // should not happen. We allocated the whole frame already. |
| 203 | return nil, err |
| 204 | } |
| 205 | |
| 206 | switch id { |
| 207 | case settingMaxFieldSectionSize: |
| 208 | if readMaxFieldSectionSize { |
| 209 | return nil, fmt.Errorf("duplicate setting: %d", id) |
| 210 | } |
| 211 | readMaxFieldSectionSize = true |
| 212 | frame.MaxFieldSectionSize = int64(val) |
| 213 | settingsFrame.MaxFieldSectionSize = int64(val) |
| 214 | case settingExtendedConnect: |
| 215 | if readExtendedConnect { |
| 216 | return nil, fmt.Errorf("duplicate setting: %d", id) |
| 217 | } |
| 218 | readExtendedConnect = true |
| 219 | if val != 0 && val != 1 { |
| 220 | return nil, fmt.Errorf("invalid value for SETTINGS_ENABLE_CONNECT_PROTOCOL: %d", val) |
| 221 | } |
| 222 | frame.ExtendedConnect = val == 1 |
| 223 | if qlogger != nil { |
| 224 | settingsFrame.ExtendedConnect = pointer(frame.ExtendedConnect) |
| 225 | } |
| 226 | case settingDatagram: |
| 227 | if readDatagram { |
| 228 | return nil, fmt.Errorf("duplicate setting: %d", id) |
| 229 | } |
| 230 | readDatagram = true |
| 231 | if val != 0 && val != 1 { |
| 232 | return nil, fmt.Errorf("invalid value for SETTINGS_H3_DATAGRAM: %d", val) |
| 233 | } |
| 234 | frame.Datagram = val == 1 |
| 235 | if qlogger != nil { |
| 236 | settingsFrame.Datagram = pointer(frame.Datagram) |
| 237 | } |
| 238 | default: |
searching dependent graphs…