Delete the QTimer before assigning null.
[kdenetwork.git] / kppp / opener.h
blob812ec9bad5b25d3c045a763753f65d1ce84c45fa
1 #ifndef _FILEOPENER_H_
2 #define _FILEOPENER_H_
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
9 #else
10 # define MY_SCM_RIGHTS SCM_RIGHTS
11 #endif
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 *)
18 #else
19 # define IOV_BASE_CAST (void *)
20 #endif
22 const char *pppdPath();
24 class Opener {
26 public:
27 Opener(int);
28 ~Opener();
30 enum { OpenDevice = 1,
31 OpenLock, RemoveLock,
32 OpenResolv,
33 OpenSysLog,
34 SetSecret, RemoveSecret,
35 SetHostname,
36 ExecPPPDaemon, KillPPPDaemon,
37 PPPDExitStatus,
38 Stop };
39 enum Auth { PAP = 1, CHAP };
40 enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 };
42 private:
43 enum { Original=0x100, New=0x200, Old=0x400 } Version;
44 void mainLoop();
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);
52 bool killpppd()const;
53 void parseargs(char* buf, char** args);
55 int socket;
56 int ttyfd;
57 char lockfile[MaxPathLen+1];
61 struct RequestHeader {
62 int type;
63 int len;
64 // int id; // TODO: Use a transmission id and check whether
65 // response matches request
68 struct ResponseHeader {
69 int status; /* 0 or errno */
70 // int id;
73 struct OpenModemRequest {
74 struct RequestHeader header;
75 int deviceNum;
78 struct RemoveLockRequest {
79 struct RequestHeader header;
82 struct OpenLockRequest {
83 struct RequestHeader header;
84 int deviceNum;
85 int flags;
88 struct OpenResolvRequest {
89 struct RequestHeader header;
90 int flags;
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;
127 struct StopRequest {
128 struct RequestHeader header;
131 union AllRequests {
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;
147 #endif