summaryrefslogtreecommitdiff
path: root/netspeed/src/backend.h
blob: b0e79704ab5259f81b837ed573f1a67ff8e7ba33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*  backend.h
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *  Netspeed Applet was writen by Jörgen Scheibengruber <mfcn@gmx.de>
 */

#ifndef _BACKEND_H
#define _BACKEND_H

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <glib.h>
#include <glibtop/netload.h>

/* copied from <linux/wireless.h> */
#define SIOCGIWNAME     0x8B01          /* get name == wireless protocol */
#define SIOCGIWENCODE	0x8B2B		    /* get encoding token & mode */

#define ETH_ALEN        6
#define ETH_LEN         20
#define MAX_FORMAT_SIZE 15

/* Different types of interfaces */
typedef enum {
    DEV_LO,
    DEV_ETHERNET,
    DEV_WIRELESS,
    DEV_PPP,
    DEV_PLIP,
    DEV_SLIP,
    DEV_UNKNOWN	// this has to be the last one
} DevType;

/* Some information about the selected network device
 */
typedef struct {
    DevType        type;
    char          *name;
    guint32        ip;
    guint32        netmask;
    guint32        ptpip;
    guint8         hwaddr [8]; /* EUI-48 or EUI-64 */
    guint8         ipv6 [16];
    char          *essid;
    gboolean       up;
    gboolean       running;
    guint64        tx;
    guint64        rx;
    int            qual;
    char           rx_rate [MAX_FORMAT_SIZE];
    char           tx_rate [MAX_FORMAT_SIZE];
    char           sum_rate [MAX_FORMAT_SIZE];
#ifdef HAVE_NL
    int            rssi;
    char          *tx_bitrate;
    char          *rx_bitrate;
    char          *channel;
    guint32        connected_time;
    unsigned char  station_mac_addr [ETH_ALEN];
#endif /* HAVE_NL */
} DevInfo;

GList*
get_available_devices(void);

const gchar*
get_default_route(void);

gboolean
is_dummy_device(const char* device);

void
free_devices_list(GList *list);

void
free_device_info(DevInfo *devinfo);

void
get_device_info(const char *device, DevInfo **info);

gboolean
compare_device_info(const DevInfo *a, const DevInfo *b);

void
get_wireless_info (DevInfo *devinfo);
#endif /* _BACKEND_H */