Index: net/spdy/spdy_protocol.cc |
diff --git a/net/spdy/spdy_protocol.cc b/net/spdy/spdy_protocol.cc |
index cec9ba29dc06da07abf0e0ab09fe3bcfcdef83b6..02c74ef3bd178f5d287bc525966c6e071b8a4974 100644 |
--- a/net/spdy/spdy_protocol.cc |
+++ b/net/spdy/spdy_protocol.cc |
@@ -61,6 +61,9 @@ bool SpdyConstants::IsValidFrameType(SpdyMajorVersion version, |
return true; |
} |
+ |
+ LOG(DFATAL) << "Unhandled SPDY version " << version; |
+ return false; |
} |
SpdyFrameType SpdyConstants::ParseFrameType(SpdyMajorVersion version, |
@@ -172,6 +175,130 @@ int SpdyConstants::SerializeFrameType(SpdyMajorVersion version, |
return -1; |
} |
} |
+ |
+ LOG(DFATAL) << "Unhandled SPDY version " << version; |
+ return -1; |
+} |
+ |
+bool SpdyConstants::IsValidSettingId(SpdyMajorVersion version, |
+ int setting_id_field) { |
+ switch (version) { |
+ case SPDY2: |
+ case SPDY3: |
+ // UPLOAD_BANDWIDTH is the first valid setting id. |
+ if (setting_id_field < |
+ SerializeSettingId(version, SETTINGS_UPLOAD_BANDWIDTH)) { |
+ return false; |
+ } |
+ |
+ // INITIAL_WINDOW_SIZE is the last valid setting id. |
+ if (setting_id_field > |
+ SerializeSettingId(version, SETTINGS_INITIAL_WINDOW_SIZE)) { |
+ return false; |
+ } |
+ |
+ return true; |
+ case SPDY4: |
+ // HEADER_TABLE_SIZE is the first valid setting id. |
+ if (setting_id_field < |
+ SerializeSettingId(version, SETTINGS_HEADER_TABLE_SIZE)) { |
+ return false; |
+ } |
+ |
+ // INITIAL_WINDOW_SIZE is the last valid setting id. |
+ if (setting_id_field > |
+ SerializeSettingId(version, SETTINGS_INITIAL_WINDOW_SIZE)) { |
+ return false; |
+ } |
+ |
+ return true; |
+ } |
+ |
+ LOG(DFATAL) << "Unhandled SPDY version " << version; |
+ return false; |
+} |
+ |
+SpdySettingsIds SpdyConstants::ParseSettingId(SpdyMajorVersion version, |
+ int setting_id_field) { |
+ switch (version) { |
+ case SPDY2: |
+ case SPDY3: |
+ switch (setting_id_field) { |
+ case 1: |
+ return SETTINGS_UPLOAD_BANDWIDTH; |
+ case 2: |
+ return SETTINGS_DOWNLOAD_BANDWIDTH; |
+ case 3: |
+ return SETTINGS_ROUND_TRIP_TIME; |
+ case 4: |
+ return SETTINGS_MAX_CONCURRENT_STREAMS; |
+ case 5: |
+ return SETTINGS_CURRENT_CWND; |
+ case 6: |
+ return SETTINGS_DOWNLOAD_RETRANS_RATE; |
+ case 7: |
+ return SETTINGS_INITIAL_WINDOW_SIZE; |
+ } |
+ break; |
+ case SPDY4: |
+ switch (setting_id_field) { |
+ case 1: |
+ return SETTINGS_HEADER_TABLE_SIZE; |
+ case 2: |
+ return SETTINGS_ENABLE_PUSH; |
+ case 3: |
+ return SETTINGS_MAX_CONCURRENT_STREAMS; |
+ case 4: |
+ return SETTINGS_INITIAL_WINDOW_SIZE; |
+ } |
+ break; |
+ } |
+ |
+ LOG(DFATAL) << "Unhandled setting ID " << setting_id_field; |
+ return SETTINGS_UPLOAD_BANDWIDTH; |
+} |
+ |
+int SpdyConstants::SerializeSettingId(SpdyMajorVersion version, |
+ SpdySettingsIds id) { |
+ switch (version) { |
+ case SPDY2: |
+ case SPDY3: |
+ switch (id) { |
+ case SETTINGS_UPLOAD_BANDWIDTH: |
+ return 1; |
+ case SETTINGS_DOWNLOAD_BANDWIDTH: |
+ return 2; |
+ case SETTINGS_ROUND_TRIP_TIME: |
+ return 3; |
+ case SETTINGS_MAX_CONCURRENT_STREAMS: |
+ return 4; |
+ case SETTINGS_CURRENT_CWND: |
+ return 5; |
+ case SETTINGS_DOWNLOAD_RETRANS_RATE: |
+ return 6; |
+ case SETTINGS_INITIAL_WINDOW_SIZE: |
+ return 7; |
+ default: |
+ LOG(DFATAL) << "Serializing unhandled setting id " << id; |
+ return -1; |
+ } |
+ case SPDY4: |
+ switch (id) { |
+ case SETTINGS_HEADER_TABLE_SIZE: |
+ return 1; |
+ case SETTINGS_ENABLE_PUSH: |
+ return 2; |
+ case SETTINGS_MAX_CONCURRENT_STREAMS: |
+ return 3; |
+ case SETTINGS_INITIAL_WINDOW_SIZE: |
+ return 4; |
+ default: |
+ LOG(DFATAL) << "Serializing unhandled setting id " << id; |
+ return -1; |
+ } |
+ } |
+ LOG(DFATAL) << "Unhandled SPDY version " << version; |
+ return -1; |
} |
void SpdyDataIR::Visit(SpdyFrameVisitor* visitor) const { |