Home | History | Annotate | Download | only in dbus
      1 //
      2 // Copyright (C) 2015 The Android Open Source Project
      3 //
      4 // Licensed under the Apache License, Version 2.0 (the "License");
      5 // you may not use this file except in compliance with the License.
      6 // You may obtain a copy of the License at
      7 //
      8 //      http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unless required by applicable law or agreed to in writing, software
     11 // distributed under the License is distributed on an "AS IS" BASIS,
     12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 // See the License for the specific language governing permissions and
     14 // limitations under the License.
     15 //
     16 
     17 #ifndef SHILL_DBUS_CHROMEOS_THIRD_PARTY_VPN_DBUS_ADAPTOR_H_
     18 #define SHILL_DBUS_CHROMEOS_THIRD_PARTY_VPN_DBUS_ADAPTOR_H_
     19 
     20 #include <map>
     21 #include <string>
     22 #include <vector>
     23 
     24 #include <base/callback.h>
     25 #include <base/memory/scoped_ptr.h>
     26 
     27 #include "dbus_bindings/org.chromium.flimflam.ThirdPartyVpn.h"
     28 #include "shill/adaptor_interfaces.h"
     29 #include "shill/dbus/chromeos_dbus_adaptor.h"
     30 
     31 namespace shill {
     32 
     33 class ThirdPartyVpnDriver;
     34 
     35 class ChromeosThirdPartyVpnDBusAdaptor
     36     : public org::chromium::flimflam::ThirdPartyVpnAdaptor,
     37       public org::chromium::flimflam::ThirdPartyVpnInterface,
     38       public ChromeosDBusAdaptor,
     39       public ThirdPartyVpnAdaptorInterface {
     40  public:
     41   enum ExternalConnectState {
     42     kStateConnected = 1,
     43     kStateFailure,
     44   };
     45 
     46   ChromeosThirdPartyVpnDBusAdaptor(const scoped_refptr<dbus::Bus>& bus,
     47                                    ThirdPartyVpnDriver* client);
     48   ~ChromeosThirdPartyVpnDBusAdaptor() override;
     49 
     50   // Implementation of ThirdPartyVpnAdaptorInterface
     51   void EmitPacketReceived(const std::vector<uint8_t>& packet) override;
     52   void EmitPlatformMessage(uint32_t message) override;
     53 
     54   // Implementation of org::chromium::flimflam::ThirdPartyVpnAdaptor
     55   bool SetParameters(
     56       brillo::ErrorPtr* error,
     57       const std::map<std::string, std::string>& parameters,
     58       std::string* warning_message) override;
     59   bool UpdateConnectionState(brillo::ErrorPtr* error,
     60                              uint32_t connection_state) override;
     61   bool SendPacket(brillo::ErrorPtr* error,
     62                   const std::vector<uint8_t>& ip_packet) override;
     63 
     64  private:
     65   ThirdPartyVpnDriver* client_;
     66 
     67   DISALLOW_COPY_AND_ASSIGN(ChromeosThirdPartyVpnDBusAdaptor);
     68 };
     69 
     70 }  // namespace shill
     71 
     72 #endif  // SHILL_DBUS_CHROMEOS_THIRD_PARTY_VPN_DBUS_ADAPTOR_H_
     73