1/*
2 *
3 * kPPP: A pppd front end for the KDE project
4 *
5 * $Id$
6 *
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>
10 *
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.
15 *
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.
20 *
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.
24 */
25
26#ifndef _PPPSTATS_H_
27#define _PPPSTATS_H_
28
29
30#include "kpppconfig.h"
31#include <qobject.h>
32
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
48
49class QTimer;
50
51class PPPStats : public QObject {
52 Q_OBJECT
53public:
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();
63
64signals:
65 void statsChanged(int);
66
67private slots:
68 void timerClick();
69
70public:
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;
79
80 QString local_ip_address;
81 QString remote_ip_address;
82
83 enum IOStatus { BytesNone = 0, BytesIn, BytesOut, BytesBoth };
84
85private:
86 bool get_ppp_stats(struct ppp_stats *curp);
87 bool strioctl(int fd, int cmd, char* ptr,int ilen, int olen);
88
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;
98};
99
100#endif
101