4 #define DEVNULL "/dev/null"
6 // workaround for bug in glibc on RedHat 5.0 and Debian 2.1
7 #if defined(__GLIBC__) && (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0 && defined(__linux__))
8 # define MY_SCM_RIGHTS 1
10 # define MY_SCM_RIGHTS SCM_RIGHTS
13 // ### add by bhughes - FreeBSD defines 'BSD' in sys/param.h
14 #include <sys/param.h>
16 #if defined(BSD) || defined(__svr4__)
17 # define IOV_BASE_CAST (char *)
19 # define IOV_BASE_CAST (void *)
22 const char *pppdPath();
30 enum { OpenDevice
= 1,
34 SetSecret
, RemoveSecret
,
36 ExecPPPDaemon
, KillPPPDaemon
,
39 enum Auth
{ PAP
= 1, CHAP
};
40 enum { MaxPathLen
= 30, MaxStrLen
= 40, MaxArgs
= 100 };
43 enum { Original
=0x100, New
=0x200, Old
=0x400 } Version
;
45 int sendFD(int ttyfd
, struct ResponseHeader
*response
);
46 int sendResponse(struct ResponseHeader
*response
);
47 const char *deviceByIndex(int idx
);
48 bool createAuthFile(Auth method
, char *username
, char *password
);
49 bool removeAuthFile(Auth method
);
50 const char* authFile(Auth method
, int version
= Original
);
51 bool execpppd(const char *arguments
);
53 void parseargs(char* buf
, char** args
);
57 char lockfile
[MaxPathLen
+1];
61 struct RequestHeader
{
64 // int id; // TODO: Use a transmission id and check whether
65 // response matches request
68 struct ResponseHeader
{
69 int status
; /* 0 or errno */
73 struct OpenModemRequest
{
74 struct RequestHeader header
;
78 struct RemoveLockRequest
{
79 struct RequestHeader header
;
82 struct OpenLockRequest
{
83 struct RequestHeader header
;
88 struct OpenResolvRequest
{
89 struct RequestHeader header
;
93 struct OpenLogRequest
{
94 struct RequestHeader header
;
97 struct SetSecretRequest
{
98 struct RequestHeader header
;
99 Opener::Auth method
; // PAP or CHAP
100 char username
[Opener::MaxStrLen
+1];
101 char password
[Opener::MaxStrLen
+1];
104 struct RemoveSecretRequest
{
105 struct RequestHeader header
;
106 Opener::Auth method
; // PAP or CHAP
109 struct SetHostnameRequest
{
110 struct RequestHeader header
;
111 char name
[Opener::MaxStrLen
+1];
114 struct ExecDaemonRequest
{
115 struct RequestHeader header
;
116 char arguments
[MAX_CMDLEN
+1];
119 struct KillDaemonRequest
{
120 struct RequestHeader header
;
123 struct PPPDExitStatusRequest
{
124 struct RequestHeader header
;
128 struct RequestHeader header
;
132 struct RequestHeader header
;
133 struct OpenModemRequest modem
;
134 struct OpenLockRequest lock
;
135 struct RemoveLockRequest unlock
;
136 struct OpenResolvRequest resolv
;
137 struct SetSecretRequest secret
;
138 struct RemoveSecretRequest remove
;
139 struct SetHostnameRequest host
;
140 struct OpenLogRequest log
;
141 struct ExecDaemonRequest daemon
;
142 struct ExecDaemonRequest kill
;
143 struct PPPDExitStatusRequest status
;
144 struct StopRequest stop
;