Darin Petkov | e6ca320 | 2012-10-19 14:49:56 +0200 | [diff] [blame] | 1 | // Copyright (c) 2012 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 | // pppd.h declares a field member called |class| which forces this file to be C. |
| 6 | #include <pppd/pppd.h> |
| 7 | |
| 8 | #include "shill/shims/c_ppp.h" |
| 9 | |
| 10 | char pppd_version[] = VERSION; |
| 11 | |
| 12 | static void PPPOnUp(void *data, int arg) { |
| 13 | PPPOnConnect(ifname); |
| 14 | } |
| 15 | |
| 16 | static void PPPOnPhaseChange(void *data, int arg) { |
mukesh agrawal | fc36291 | 2013-08-06 18:10:07 -0700 | [diff] [blame] | 17 | if (arg == PHASE_AUTHENTICATE) { |
| 18 | PPPOnAuthenticateStart(); |
| 19 | } else if (arg == PHASE_NETWORK) { |
| 20 | // Either no authentication was required, or authentication has |
| 21 | // completed. |
mukesh agrawal | ee10f37 | 2013-08-14 14:07:11 -0700 | [diff] [blame] | 22 | // |
| 23 | // TODO(quiche): We can also transition backwards to PHASE_NETWORK, |
| 24 | // when disconnecting. In such cases, the may want to omit this |
| 25 | // (spurious) call. |
mukesh agrawal | fc36291 | 2013-08-06 18:10:07 -0700 | [diff] [blame] | 26 | PPPOnAuthenticateDone(); |
| 27 | } else if (arg == PHASE_DISCONNECT || arg == PHASE_DEAD) { |
Darin Petkov | e6ca320 | 2012-10-19 14:49:56 +0200 | [diff] [blame] | 28 | PPPOnDisconnect(); |
| 29 | } |
| 30 | } |
| 31 | |
Liam McLoughlin | 15fe6e3 | 2013-12-26 16:30:55 +0000 | [diff] [blame] | 32 | __attribute__ ((visibility("default"))) int plugin_init() { |
Darin Petkov | e6ca320 | 2012-10-19 14:49:56 +0200 | [diff] [blame] | 33 | PPPInit(); |
| 34 | |
| 35 | chap_check_hook = PPPHasSecret; |
| 36 | pap_check_hook = PPPHasSecret; |
| 37 | |
| 38 | pap_passwd_hook = PPPGetSecret; |
| 39 | chap_passwd_hook = PPPGetSecret; |
| 40 | |
| 41 | add_notifier(&ip_up_notifier, PPPOnUp, NULL); |
| 42 | add_notifier(&phasechange, PPPOnPhaseChange, NULL); |
| 43 | add_notifier(&exitnotify, PPPOnExit, NULL); |
| 44 | |
| 45 | return 0; |
| 46 | } |