proxygen
fizz::client::detail Namespace Reference

Functions

template<typename... Args>
Actions actions (Args &&...act)
 
Actions processEvent (const State &state, Param param)
 
Actions handleError (const State &state, ReportError error, Optional< AlertDescription > alertDesc)
 
Actions handleAppClose (const State &state)
 
Actions handleInvalidEvent (const State &state, Event event, Param param)
 

Function Documentation

template<typename... Args>
Actions fizz::client::detail::actions ( Args &&...  act)

Definition at line 86 of file Actions.h.

References fizz::detail::addAction().

Referenced by fizz::client::test::AsyncFizzClientTest::completeEarlyHandshake(), fizz::client::test::ClientProtocolTest::doFinishedFlow(), fizz::client::test::AsyncFizzClientTest::expectAppClose(), fizz::test::ProtocolTest< ClientTypes, Actions >::expectError(), fizz::test::ProtocolTest< ClientTypes, Actions >::expectExceptionType(), fizz::test::ProtocolTest< ClientTypes, Actions >::expectSingleAction(), fizz::FizzBase< FizzServer< ActionMoveVisitor, SM >, ActionMoveVisitor, SM >::FizzBase(), fizz::client::test::AsyncFizzClientTest::fullHandshakeSuccess(), fizz::sm::getClientCert(), fizz::sm::getEarlyDataParams(), fizz::sm::getHrrKeyExchangers(), fizz::sm::getMaxEarlyDataSize(), fizz::test::ProtocolTest< ClientTypes, Actions >::getNumActions(), handleAppClose(), fizz::sm::handleCertMsg(), fizz::sm::handleEarlyAppWrite(), handleError(), fizz::sm::ignoreEarlyAppWrite(), fizz::sm::negotiatePsk(), fizz::FizzBase< Derived, ActionMoveVisitor, StateMachine >::processPendingEvents(), fizz::client::ClientStateMachine::processSocketData(), fizz::client::test::TEST_F(), fizz::server::test::TEST_F(), and fizz::sm::validateAcceptedEarly().

86  {
87  Actions acts;
88  fizz::detail::addAction(acts, std::forward<Args>(act)...);
89  return acts;
90 }
void addAction(ActionsType &)
Definition: Actions.h:67
folly::small_vector< Action, 4 > Actions
Definition: Actions.h:51
Actions fizz::client::detail::handleAppClose ( const State state)

Definition at line 248 of file ClientProtocol.cpp.

References actions(), fizz::alert, fizz::close_notify, fizz::WriteToSocket::contents, fizz::client::Error, folly::gen::move, fizz::detail::write(), fizz::WriteRecordLayer::writeAlert(), and fizz::client::State::writeRecordLayer().

Referenced by fizz::client::ClientStateMachine::processAppClose().

248  {
249  auto transition = [](State& newState) {
250  newState.state() = StateEnum::Error;
251  newState.writeRecordLayer() = nullptr;
252  newState.readRecordLayer() = nullptr;
253  };
254  if (state.writeRecordLayer()) {
255  Alert alert(AlertDescription::close_notify);
256  WriteToSocket write;
257  write.contents.emplace_back(
258  state.writeRecordLayer()->writeAlert(std::move(alert)));
259  return actions(std::move(transition), std::move(write));
260  } else {
261  return actions(std::move(transition));
262  }
263 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
TLSContent writeAlert(Alert &&alert) const
Definition: RecordLayer.h:65
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
const WriteRecordLayer * writeRecordLayer() const
Definition: State.h:245
error_stage Error
Actions actions(Args &&...act)
Definition: Actions.h:86
Actions fizz::client::detail::handleError ( const State state,
ReportError  error,
Optional< AlertDescription alertDesc 
)

Definition at line 225 of file ClientProtocol.cpp.

References actions(), fizz::alert, fizz::WriteToSocket::contents, fizz::client::Error, folly::gen::move, fizz::client::State::state(), fizz::detail::write(), fizz::WriteRecordLayer::writeAlert(), and fizz::client::State::writeRecordLayer().

Referenced by processEvent(), and fizz::client::ClientStateMachine::processSocketData().

228  {
229  if (state.state() == StateEnum::Error) {
230  return actions(std::move(error));
231  }
232  auto transition = [](State& newState) {
233  newState.state() = StateEnum::Error;
234  newState.writeRecordLayer() = nullptr;
235  newState.readRecordLayer() = nullptr;
236  };
237  if (alertDesc && state.writeRecordLayer()) {
238  Alert alert(*alertDesc);
239  WriteToSocket write;
240  write.contents.emplace_back(
241  state.writeRecordLayer()->writeAlert(std::move(alert)));
242  return actions(std::move(transition), std::move(write), std::move(error));
243  } else {
244  return actions(std::move(transition), std::move(error));
245  }
246 }
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
TLSContent writeAlert(Alert &&alert) const
Definition: RecordLayer.h:65
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StateEnum state() const
Definition: State.h:63
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
const WriteRecordLayer * writeRecordLayer() const
Definition: State.h:245
error_stage Error
Actions actions(Args &&...act)
Definition: Actions.h:86
Actions fizz::client::detail::handleInvalidEvent ( const State state,
Event  event,
Param  param 
)

Definition at line 265 of file ClientProtocol.cpp.

References fizz::Alert, fizz::alert, folly::none, fizz::client::State::state(), fizz::toString(), and fizz::unexpected_message.

265  {
266  if (event == Event::Alert) {
267  auto& alert = boost::get<Alert>(param);
268  throw FizzException(
269  folly::to<std::string>(
270  "received alert: ",
271  toString(alert.description),
272  ", in state ",
273  toString(state.state())),
274  folly::none);
275  } else {
276  throw FizzException(
277  folly::to<std::string>(
278  "invalid event: ",
279  toString(event),
280  ", in state ",
281  toString(state.state())),
282  AlertDescription::unexpected_message);
283  }
284 }
folly::StringPiece toString(StateEnum state)
Definition: State.cpp:16
StateEnum state() const
Definition: State.h:63
constexpr None none
Definition: Optional.h:87
Actions fizz::client::detail::processEvent ( const State state,
Param  param 
)

Definition at line 207 of file ClientProtocol.cpp.

References folly::apply_visitor(), fizz::FizzException::getAlert(), fizz::sm::StateMachine< SM >::getHandler(), handleError(), folly::gen::move, fizz::client::State::state(), and fizz::unexpected_message.

Referenced by fizz::client::test::ClientProtocolTest::doFinishedFlow(), fizz::client::ClientStateMachine::processAppWrite(), fizz::client::ClientStateMachine::processConnect(), fizz::client::ClientStateMachine::processEarlyAppWrite(), fizz::client::ClientStateMachine::processSocketData(), fizz::client::ClientStateMachine::processWriteNewSessionTicket(), fizz::client::test::TEST_F(), and fizz::server::test::TEST_F().

207  {
208  auto event = boost::apply_visitor(EventVisitor(), param);
209  try {
210  return sm::StateMachine<ClientTypes>::getHandler(state.state(), event)(
211  state, std::move(param));
212  } catch (const FizzException& e) {
213  return detail::handleError(
214  state,
215  ReportError(folly::exception_wrapper(std::current_exception(), e)),
216  e.getAlert());
217  } catch (const std::exception& e) {
218  return detail::handleError(
219  state,
220  ReportError(folly::exception_wrapper(std::current_exception(), e)),
221  AlertDescription::unexpected_message);
222  }
223 }
Actions handleError(const State &state, ReportError error, Optional< AlertDescription > alertDesc)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
StateEnum state() const
Definition: State.h:63
decltype(auto) apply_visitor(Visitor &&visitor, const DiscriminatedPtr< Args... > &variant)