| 190 | } |
| 191 | |
| 192 | int |
| 193 | Http2CommonSession::state_read_connection_preface(int event, void *edata) |
| 194 | { |
| 195 | VIO *vio = static_cast<VIO *>(edata); |
| 196 | |
| 197 | STATE_ENTER(&Http2CommonSession::state_read_connection_preface, event); |
| 198 | ink_assert(event == VC_EVENT_READ_COMPLETE || event == VC_EVENT_READ_READY); |
| 199 | |
| 200 | if (this->_read_buffer_reader->read_avail() >= static_cast<int64_t>(HTTP2_CONNECTION_PREFACE_LEN)) { |
| 201 | char buf[HTTP2_CONNECTION_PREFACE_LEN]; |
| 202 | unsigned nbytes; |
| 203 | |
| 204 | nbytes = copy_from_buffer_reader(buf, this->_read_buffer_reader, sizeof(buf)); |
| 205 | ink_release_assert(nbytes == HTTP2_CONNECTION_PREFACE_LEN); |
| 206 | |
| 207 | if (memcmp(HTTP2_CONNECTION_PREFACE, buf, nbytes) != 0) { |
| 208 | Http2SsnDebug("invalid connection preface"); |
| 209 | this->get_proxy_session()->do_io_close(); |
| 210 | return 0; |
| 211 | } |
| 212 | |
| 213 | // Check whether data is read from early data |
| 214 | if (this->read_from_early_data > 0) { |
| 215 | this->read_from_early_data -= this->read_from_early_data > nbytes ? nbytes : this->read_from_early_data; |
| 216 | } |
| 217 | |
| 218 | Http2SsnDebug("received connection preface"); |
| 219 | this->_read_buffer_reader->consume(nbytes); |
| 220 | HTTP2_SET_SESSION_HANDLER(&Http2CommonSession::state_start_frame_read); |
| 221 | |
| 222 | this->get_netvc()->set_inactivity_timeout(HRTIME_SECONDS(Http2::no_activity_timeout_in)); |
| 223 | this->get_netvc()->set_active_timeout(HRTIME_SECONDS(Http2::active_timeout_in)); |
| 224 | |
| 225 | // XXX start the write VIO ... |
| 226 | |
| 227 | // If we have unconsumed data, start tranferring frames now. |
| 228 | if (this->_read_buffer_reader->is_read_avail_more_than(0)) { |
| 229 | return this->get_proxy_session()->handleEvent(VC_EVENT_READ_READY, vio); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | // XXX We don't have enough data to check the connection preface. We should |
| 234 | // reset the accept inactivity |
| 235 | // timeout. We should have a maximum timeout to get the session started |
| 236 | // though. |
| 237 | |
| 238 | vio->reenable(); |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | int |
| 243 | Http2CommonSession::state_start_frame_read(int event, void *edata) |
nothing calls this directly
no test coverage detected