• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2012 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 #include "shill/shims/c_ppp.h"
18 
19 #include <string>
20 
21 #include <base/at_exit.h>
22 
23 #include "shill/shims/ppp.h"
24 
25 using shill::shims::PPP;
26 using std::string;
27 
28 namespace {
29 base::AtExitManager* g_exit_manager = NULL;  // Cleans up LazyInstances.
30 }  // namespace
31 
PPPInit()32 void PPPInit() {
33   g_exit_manager = new base::AtExitManager();
34   PPP::GetInstance()->Init();
35 }
36 
PPPHasSecret()37 int PPPHasSecret() {
38   return 1;
39 }
40 
PPPGetSecret(char * username,char * password)41 int PPPGetSecret(char* username, char* password) {
42   string user, pass;
43   if (!PPP::GetInstance()->GetSecret(&user, &pass)) {
44     return -1;
45   }
46   if (username) {
47     strcpy(username, user.c_str());  // NOLINT(runtime/printf)
48   }
49   if (password) {
50     strcpy(password, pass.c_str());  // NOLINT(runtime/printf)
51   }
52   return 1;
53 }
54 
PPPOnAuthenticateStart()55 void PPPOnAuthenticateStart() {
56   PPP::GetInstance()->OnAuthenticateStart();
57 }
58 
PPPOnAuthenticateDone()59 void PPPOnAuthenticateDone() {
60   PPP::GetInstance()->OnAuthenticateDone();
61 }
62 
PPPOnConnect(const char * ifname)63 void PPPOnConnect(const char* ifname) {
64   PPP::GetInstance()->OnConnect(ifname);
65 }
66 
PPPOnDisconnect()67 void PPPOnDisconnect() {
68   PPP::GetInstance()->OnDisconnect();
69 }
70 
PPPOnExit(void *,int)71 void PPPOnExit(void* /*data*/, int /*arg*/) {
72   LOG(INFO) << __func__;
73   delete g_exit_manager;
74   g_exit_manager = NULL;
75 }
76