]> git.ozlabs.org Git - ppp.git/blob - PLUGINS
update version numbers
[ppp.git] / PLUGINS
1 Starting with version 2.3.10, pppd includes support for `plugins' -
2 pieces of code which can be loaded into pppd at runtime and which can
3 affect its behaviour in various ways.  The idea of plugins is to
4 provide a way for people to customize the behaviour of pppd without
5 having to either apply local patches to each version or get their
6 patches accepted into the standard distribution.  My aim is that
7 plugins will be able to be used with successive versions of pppd
8 without needing to recompile the plugins.
9
10 A plugin is a standard shared library object, typically with a name
11 ending in .so.  They are loaded using the standard dlopen() library
12 call, so plugins are only supported on systems which support shared
13 libraries and the dlopen call.  At present pppd is compiled with
14 plugin support only under Linux.
15
16 Plugins are loaded into pppd using the `plugin' option, which takes
17 one argument, the name of a shared object file.  The plugin option is
18 a privileged option.  I suggest that you give the full path name of
19 the shared object file; if you don't, it may be possible for
20 unscrupulous users to substitute another shared object file for the
21 one you mean to load, e.g. by setting the LD_LIBRARY_PATH variable.
22
23 Plugins are usually written in C and compiled and linked to a shared
24 object file in the appropriate manner for your platform.  Using gcc
25 under Linux, a plugin called `xyz' could be compiled and linked with
26 the following commands:
27
28         gcc -c -O xyz.c
29         gcc -shared -o xyz.so xyz.o
30
31 Plugins can access global variables within pppd, so it is useful for
32 them to #include "pppd.h" from the pppd source directory.
33
34 Every plugin must contain a global procedure called `plugin_init'.
35 This procedure will get called (with no arguments) immediately after
36 the plugin is loaded.
37
38 Plugins can affect the behaviour of pppd in at least three ways:
39
40 1. They can add extra options which pppd will then recognize.  This is
41    done by calling the add_options() procedure with a pointer to an
42    array of option_t structures.  The last entry in the array must
43    have its name field set to NULL.
44
45 2. Pppd contains `hook' variables which are procedure pointers.  If a
46    given hook is not NULL, pppd will call the procedure it points to
47    at the appropriate point in its processing.  The plugin can set any
48    of these hooks to point to its own procedures.  See below for a
49    description of the hooks which are currently implemented.
50
51 3. Plugin code can call any global procedures and access any global
52    variables in pppd.
53
54 Here is a list of the currently implemented hooks in pppd.
55
56
57 int (*idle_time_hook)(struct ppp_idle *idlep);
58
59 The idle_time_hook is called when the link first comes up (i.e. when
60 the first network protocol comes up) and at intervals thereafter.  On
61 the first call, the idlep parameter is NULL, and the return value is
62 the number of seconds before pppd should check the link activity, or 0
63 if there is to be no idle timeout.
64
65 On subsequent calls, idlep points to a structure giving the number of
66 seconds since the last packets were sent and received.  If the return
67 value is > 0, pppd will wait that many seconds before checking again.
68 If it is <= 0, that indicates that the link should be terminated due
69 to lack of activity.
70
71
72 int (*holdoff_hook)(void);
73
74 The holdoff_hook is called when an attempt to bring up the link fails,
75 or the link is terminated, and the persist or demand option was used.
76 It returns the number of seconds that pppd should wait before trying
77 to reestablish the link (0 means immediately).
78
79
80 int (*pap_check_hook)(void);
81 int (*pap_passwd_hook)(char *user, char *passwd);
82 int (*pap_auth_hook)(char *user, int userlen,
83                      char *passwd, int passlen,
84                      char **msgp, int *msglenp,
85                      struct wordlist **paddrs,
86                      struct wordlist **popts);
87
88 These hooks are designed to allow a plugin to replace the normal PAP
89 password processing in pppd with something different (e.g. contacting
90 an external server).
91
92 The pap_check_hook is called to check whether there is any possibility
93 that the peer could authenticate itself to us.  If it returns 1, pppd
94 will ask the peer to authenticate itself.  If it returns 0, pppd will
95 not ask the peer to authenticate itself (but if authentication is
96 required, pppd may exit, or terminate the link before network protocol
97 negotiation).  If it returns -1, pppd will look in the pap-secrets
98 file as it would normally.
99
100 The pap_passwd_hook is called to determine what username and password
101 pppd should use in authenticating itself to the peer with PAP.  The
102 user string will already be initialized, by the `user' option, the
103 `name' option, or from the hostname, but can be changed if necessary.
104 MAXNAMELEN bytes of space are available at *user, and MAXSECRETLEN
105 bytes of space at *passwd.  If this hook returns 0, pppd will use the
106 values at *user and *passwd; if it returns -1, pppd will look in the
107 pap-secrets file, or use the value from the +ua or password option, as
108 it would normally.
109
110 The pap_auth_hook is called to determine whether the username and
111 password supplied by the peer are valid.  user and passwd point to
112 null-terminated strings containing the username and password supplied
113 by the peer, with non-printable characters converted to a printable
114 form.  The pap_auth_hook function should set msg to a string to be
115 returned to the peer and return 1 if the username/password was valid
116 and 0 if not.  If the hook returns -1, pppd will look in the
117 pap-secrets file as usual.
118
119 If the username/password was valid, the hook can set *paddrs to point
120 to a wordlist containing the IP address(es) which the peer is
121 permitted to use, formatted as in the pap-secrets file.  It can also
122 set *popts to a wordlist containing any extra options for this user
123 which pppd should apply at this point.
124
125
126 ## $Id: PLUGINS,v 1.1 1999/09/11 12:09:31 paulus Exp $ ##