ping.h 2.9 KB
Newer Older
Rodrigo Moya's avatar
Rodrigo Moya committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/* gnome-netinfo - A GUI Interface for network utilities
 * Copyright (C) 2002, 2003 by German Poo-Caaman~o
 *
 * 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

19
#include <glib.h>
Rodrigo Moya's avatar
Rodrigo Moya committed
20

Rodrigo Moya's avatar
Rodrigo Moya committed
21
#include "nettool.h"
Rodrigo Moya's avatar
Rodrigo Moya committed
22 23

/* The ping usage and output is different between Unix flavours */
Alejandro Andres's avatar
Alejandro Andres committed
24
#if defined(__linux__)
25 26 27
    /*  <path to program> ping -b [-c <count>] -n <host> */
#   define PING_PROGRAM_FORMAT "%s ping -b%s-n %s"
#   define PING_PROGRAM_FORMAT_6 "%s ping6%s-n %s"
28 29
#   define PING_FORMAT "%d bytes from %s icmp_%3c=%d ttl=%d time=%s %s"
#   define PING_PARAMS_7
30
#elif defined(__OSF__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
31 32 33
    /*  <path to program> ping [-c <count>] -n <host> */
#   define PING_PROGRAM_FORMAT "%s ping%s-n %s"
#   define PING_PROGRAM_FORMAT_6 "%s ping6%s-n %s"
34 35
#   define PING_FORMAT "%d bytes from %s icmp_%3c=%d ttl=%d time=%s %s"
#   define PING_PARAMS_7
Rodrigo Moya's avatar
Rodrigo Moya committed
36
#elif defined(__sun__) 
37 38 39
    /*  <path to program> ping -s -n <host> [<count>] */
#   define PING_PROGRAM_FORMAT "%s ping -s -n %s 56%s"
#   define PING_PROGRAM_FORMAT_6 "%s ping -s -A inet6 -a -n %s 56%s"
Rodrigo Moya's avatar
Rodrigo Moya committed
40 41 42
#   define PING_FORMAT "%d bytes from %s icmp_seq=%d. time=%f %s"
#   define PING_PARAMS_5
#elif defined(__hpux__)
43 44
#   define PING_PROGRAM_FORMAT "%s ping %s -n%s"
#   define PING_PROGRAM_FORMAT_6 "%s ping %s -f inet6 -n%s"
Rodrigo Moya's avatar
Rodrigo Moya committed
45 46 47
#   define PING_FORMAT "%d bytes from %s icmp_seq=%d. time=%f %s"
#   define PING_PARAMS_5
#else
48 49
#   define PING_PROGRAM_FORMAT "%s ping %s -n %s"
#   define PING_PROGRAM_FORMAT_6 "%s ping6 %s -n %s"
Rodrigo Moya's avatar
Rodrigo Moya committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#   define PING_FORMAT "%d bytes from %s icmp_seq=%d. time=%f %s"
#   define PING_PARAMS_5
#endif

#define PING_TOTAL "%d packets transmitted, %d %s"

typedef struct _ping_data ping_data;
	
struct _ping_data {
	gint bytes;
	gint icmp_seq;
	gint ttl;
	gfloat rtt;
	gchar srtt[128];
	gchar ip[128];
	gchar unit[128];
};

/* Ping funtions */
void ping_do (Netinfo * netinfo);
void ping_stop (Netinfo * netinfo);
71
void ping_foreach (Netinfo * netinfo, gchar * line, gssize len, gpointer user_data);
Rodrigo Moya's avatar
Rodrigo Moya committed
72 73
void ping_foreach_with_tree (Netinfo * netinfo, gchar * line, gint len, gpointer user_data);
void ping_copy_to_clipboard (Netinfo * netinfo, gpointer user_data);
74
gint on_ping_graph_draw (GtkWidget *widget, cairo_t *cr, Netinfo *info);