Contact cannot be a null ptr, and it is accessed before anyway. Disscussed with kedge.
[kdenetwork.git] / kppp / pppstats.h
blob7b12cac00a66c63b9346190e963f70b554097c19
1 /*
3 * kPPP: A pppd front end for the KDE project
5 * $Id$
7 * (c) 1997-1998 Bernd Johannes Wuebben <wuebben@kde.org>
8 * (c) 1997-1999 Mario Weilguni <mweilguni@kde.org>
9 * (c) 1998-1999 Harri Porten <porten@kde.org>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public
22 * License along with this program; if not, write to the Free
23 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #ifndef _PPPSTATS_H_
27 #define _PPPSTATS_H_
30 #include "kpppconfig.h"
31 #include <qobject.h>
33 #ifdef Q_OS_BSD4
34 #include <sys/types.h>
35 #include <sys/socket.h>
36 #ifdef __DragonFly__
37 #include <net/ppp_layer/ppp_defs.h>
38 #else
39 #include <net/ppp_defs.h>
40 #endif
41 #include <net/if.h>
42 #ifdef __DragonFly__
43 #include <net/ppp/if_ppp.h>
44 #else
45 #include <net/if_ppp.h>
46 #endif
47 #endif
49 class QTimer;
51 class PPPStats : public QObject {
52 Q_OBJECT
53 public:
54 PPPStats();
55 ~PPPStats();
56 void clear();
57 bool initStats();
58 bool doStats();
59 bool ifIsUp();
60 void setUnit(int u);
61 void start();
62 void stop();
64 signals:
65 void statsChanged(int);
67 private slots:
68 void timerClick();
70 public:
71 int ibytes, obytes;
72 int totalbytes;
73 int ipackets, opackets;
74 int compressedin;
75 int uncompressedin;
76 int compressed;
77 int errorin;
78 int packetsunc, packetsoutunc;
80 QString local_ip_address;
81 QString remote_ip_address;
83 enum IOStatus { BytesNone = 0, BytesIn, BytesOut, BytesBoth };
85 private:
86 bool get_ppp_stats(struct ppp_stats *curp);
87 bool strioctl(int fd, int cmd, char* ptr,int ilen, int olen);
89 int ibytes_last, obytes_last;
90 int s; // socket file descriptor
91 #ifdef STREAMS
92 int t;
93 #endif
94 int unit;
95 char unitName[5];
96 enum IOStatus ioStatus;
97 QTimer *timer;
100 #endif