blob: c0c80a8090a1a9349e2486087f7de8679fd65f6e [file] [log] [blame]
Paul Stewart735eab52013-03-29 09:19:23 -07001// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_SUPPLICANT_EAP_STATE_HANDLER_H_
6#define SHILL_SUPPLICANT_EAP_STATE_HANDLER_H_
7
8#include <string>
9
10#include "shill/service.h"
11
12namespace shill {
13
14// This object tracks the state of wpa_supplicant's EAP association.
15// It parses events from wpa_supplicant and can notify callers when
16// wpa_supplicant succeeds or fails authentication. In the latter
17// case it can explain the failure in detail based on the course of
18// events leading up to it.
19class SupplicantEAPStateHandler {
20 public:
21 SupplicantEAPStateHandler();
22 virtual ~SupplicantEAPStateHandler();
23
24 // Receive the |status| and |parameter| from an EAP event and returns
25 // true if this state transition indicates that the EAP authentication
26 // process has succeeded. If instead the EAP authentication has failed,
27 // |failure| will be set to reflect the type of failure that occurred,
28 // false will be returned. If this EAP event has no direct outcome,
29 // this function returns false without changing |failure|.
30 virtual bool ParseStatus(const std::string &status,
31 const std::string &parameter,
32 Service::ConnectFailure *failure);
33
34 // Resets the internal state of the handler.
35 virtual void Reset();
36
37 virtual bool is_eap_in_progress() { return is_eap_in_progress_; }
38
39 private:
40 friend class SupplicantEAPStateHandlerTest;
41
42 // The stored TLS error type which may lead to an EAP failure.
43 std::string tls_error_;
44
45 // Whether or not an EAP authentication is in progress. Note
46 // specifically that an EAP failure in wpa_supplicant does not
47 // automatically cause the EAP process to stop, while success does.
48 bool is_eap_in_progress_;
49};
50
51} // namespace shill
52
53#endif // SHILL_SUPPLICANT_EAP_STATE_HANDLER_H_