2018-05-12 16:03:00 +00:00
|
|
|
/*
|
2009-10-17 14:43:12 +00:00
|
|
|
*
|
|
|
|
* Conky, a system monitor, based on torsmo
|
|
|
|
*
|
|
|
|
* Any original torsmo code is licensed under the BSD license
|
|
|
|
*
|
|
|
|
* All code written since the fork of torsmo is licensed under the GPL
|
|
|
|
*
|
|
|
|
* Please see COPYING for details
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
2019-01-05 15:52:43 +00:00
|
|
|
* Copyright (c) 2005-2019 Brenden Matthews, Philip Kovacs, et. al.
|
2009-10-17 14:43:12 +00:00
|
|
|
* (see AUTHORS)
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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 3 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 General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NET_STAT_H
|
|
|
|
#define _NET_STAT_H
|
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
#include <netinet/in.h> /* struct in6_addr */
|
2018-12-22 18:16:38 +00:00
|
|
|
#include <sys/socket.h> /* struct sockaddr */
|
|
|
|
#include "config.h"
|
2009-10-17 14:43:12 +00:00
|
|
|
|
2011-02-09 17:49:52 +00:00
|
|
|
#ifdef BUILD_IPV6
|
|
|
|
struct v6addr {
|
2018-05-12 16:03:00 +00:00
|
|
|
struct in6_addr addr;
|
|
|
|
unsigned int netmask;
|
|
|
|
char scope;
|
|
|
|
struct v6addr *next;
|
2011-02-09 17:49:52 +00:00
|
|
|
};
|
|
|
|
#endif /* BUILD_IPV6 */
|
|
|
|
|
2009-10-17 14:43:12 +00:00
|
|
|
struct net_stat {
|
2018-05-12 16:03:00 +00:00
|
|
|
/* interface name, e.g. wlan0, eth0, ... */
|
|
|
|
char *dev;
|
|
|
|
/* set to 1, if interface is up */
|
|
|
|
int up;
|
|
|
|
/* network traffic read on last call in order to calculate how much
|
|
|
|
* was received or transmitted since the last call. contains -1 if
|
|
|
|
* it was never read before. in bytes */
|
|
|
|
long long last_read_recv, last_read_trans;
|
|
|
|
/* total received and transmitted data statistics in bytes */
|
|
|
|
long long recv, trans;
|
|
|
|
/* averaged network speed in bytes / second */
|
|
|
|
double recv_speed, trans_speed;
|
|
|
|
/* struct with at least the member sa_data which is a const * containing
|
|
|
|
* the socket address.
|
|
|
|
* @see http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html */
|
|
|
|
struct sockaddr addr;
|
2011-02-09 17:49:52 +00:00
|
|
|
#ifdef BUILD_IPV6
|
2018-05-12 16:03:00 +00:00
|
|
|
struct v6addr *v6addrs;
|
|
|
|
bool v6show_nm;
|
|
|
|
bool v6show_sc;
|
2011-02-09 17:49:52 +00:00
|
|
|
#endif /* BUILD_IPV6 */
|
2009-10-17 14:43:12 +00:00
|
|
|
#if defined(__linux__)
|
2018-05-12 16:03:00 +00:00
|
|
|
char addrs[17 * MAX_NET_INTERFACES + 1];
|
2009-10-17 14:43:12 +00:00
|
|
|
#endif /* __linux__ */
|
2018-05-12 16:03:00 +00:00
|
|
|
/* network speeds between two conky calls in bytes per second.
|
|
|
|
* An average over these samples is calculated in recv_speed and
|
|
|
|
* trans_speed */
|
|
|
|
double net_rec[15], net_trans[15];
|
|
|
|
// wireless extensions
|
2018-12-22 18:16:38 +00:00
|
|
|
char essid[35];
|
2018-05-12 16:03:00 +00:00
|
|
|
int channel;
|
|
|
|
char freq[16];
|
|
|
|
char bitrate[16];
|
|
|
|
char mode[16];
|
|
|
|
int link_qual;
|
|
|
|
int link_qual_max;
|
|
|
|
char ap[18];
|
2009-10-17 14:43:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct net_stat netstats[];
|
|
|
|
|
|
|
|
struct net_stat *get_net_stat(const char *, void *, void *);
|
|
|
|
|
|
|
|
void parse_net_stat_arg(struct text_object *, const char *, void *);
|
|
|
|
void parse_net_stat_bar_arg(struct text_object *, const char *, void *);
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_downspeed(struct text_object *, char *, unsigned int);
|
|
|
|
void print_downspeedf(struct text_object *, char *, unsigned int);
|
|
|
|
void print_upspeed(struct text_object *, char *, unsigned int);
|
|
|
|
void print_upspeedf(struct text_object *, char *, unsigned int);
|
|
|
|
void print_totaldown(struct text_object *, char *, unsigned int);
|
|
|
|
void print_totalup(struct text_object *, char *, unsigned int);
|
|
|
|
void print_addr(struct text_object *, char *, unsigned int);
|
2009-10-17 14:43:12 +00:00
|
|
|
#ifdef __linux__
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_addrs(struct text_object *, char *, unsigned int);
|
2011-02-09 17:49:52 +00:00
|
|
|
#ifdef BUILD_IPV6
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_v6addrs(struct text_object *, char *, unsigned int);
|
2011-02-09 17:49:52 +00:00
|
|
|
#endif /* BUILD_IPV6 */
|
2009-10-17 14:43:12 +00:00
|
|
|
#endif /* __linux__ */
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2009-10-17 14:43:12 +00:00
|
|
|
void parse_net_stat_graph_arg(struct text_object *, const char *, void *);
|
2009-12-04 00:53:53 +00:00
|
|
|
double downspeedgraphval(struct text_object *);
|
|
|
|
double upspeedgraphval(struct text_object *);
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2010-01-11 00:13:42 +00:00
|
|
|
#ifdef BUILD_WLAN
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_wireless_essid(struct text_object *, char *, unsigned int);
|
|
|
|
void print_wireless_channel(struct text_object *, char *, unsigned int);
|
|
|
|
void print_wireless_frequency(struct text_object *, char *, unsigned int);
|
|
|
|
void print_wireless_mode(struct text_object *, char *, unsigned int);
|
|
|
|
void print_wireless_bitrate(struct text_object *, char *, unsigned int);
|
|
|
|
void print_wireless_ap(struct text_object *, char *, unsigned int);
|
|
|
|
void print_wireless_link_qual(struct text_object *, char *, unsigned int);
|
|
|
|
void print_wireless_link_qual_max(struct text_object *, char *, unsigned int);
|
|
|
|
void print_wireless_link_qual_perc(struct text_object *, char *, unsigned int);
|
2009-12-04 00:13:36 +00:00
|
|
|
double wireless_link_barval(struct text_object *);
|
2010-01-11 00:13:42 +00:00
|
|
|
#endif /* BUILD_WLAN */
|
2009-10-17 14:43:12 +00:00
|
|
|
|
|
|
|
void clear_net_stats(void);
|
2018-05-12 16:03:00 +00:00
|
|
|
void clear_net_stats(net_stat *);
|
2009-10-09 02:30:02 +00:00
|
|
|
|
|
|
|
void parse_if_up_arg(struct text_object *, const char *);
|
|
|
|
int interface_up(struct text_object *);
|
|
|
|
void free_if_up(struct text_object *);
|
2009-10-17 14:43:12 +00:00
|
|
|
|
2009-11-29 19:55:42 +00:00
|
|
|
void free_dns_data(struct text_object *);
|
2010-05-05 16:46:04 +00:00
|
|
|
int update_dns_data(void);
|
2009-10-17 14:43:12 +00:00
|
|
|
void parse_nameserver_arg(struct text_object *, const char *);
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_nameserver(struct text_object *, char *, unsigned int);
|
2009-10-17 14:43:12 +00:00
|
|
|
|
|
|
|
#endif /* _NET_STAT_H */
|