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// pppd.h declares a field member called |class| which forces this file to be C.
18#include <pppd/pppd.h>
19
20#include "shill/shims/c_ppp.h"
21
22char pppd_version[] = VERSION;
23
24static void PPPOnUp(void* data, int arg) {
25  PPPOnConnect(ifname);
26}
27
28static void PPPOnPhaseChange(void* data, int arg) {
29  if (arg == PHASE_AUTHENTICATE) {
30    PPPOnAuthenticateStart();
31  } else if (arg == PHASE_NETWORK) {
32    // Either no authentication was required, or authentication has
33    // completed.
34    //
35    // TODO(quiche): We can also transition backwards to PHASE_NETWORK,
36    // when disconnecting. In such cases, the may want to omit this
37    // (spurious) call.
38    PPPOnAuthenticateDone();
39  } else if (arg == PHASE_DISCONNECT || arg == PHASE_DEAD) {
40    PPPOnDisconnect();
41  }
42}
43
44__attribute__ ((visibility("default"))) int plugin_init() {
45  PPPInit();
46
47  chap_check_hook = PPPHasSecret;
48  pap_check_hook = PPPHasSecret;
49
50  pap_passwd_hook = PPPGetSecret;
51  chap_passwd_hook = PPPGetSecret;
52
53  add_notifier(&ip_up_notifier, PPPOnUp, NULL);
54  add_notifier(&phasechange, PPPOnPhaseChange, NULL);
55  add_notifier(&exitnotify, PPPOnExit, NULL);
56
57  return 0;
58}
59