1 /* EtherApe
2  * Copyright (C) 2001 Juan Toledo, Riccardo Ghetta
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef ETHERAPE_NODE_ID_H
19 #define ETHERAPE_NODE_ID_H
20 
21 /* a node identification */
22 typedef struct
23 {
24   apemode_t node_type;
25   union __attribute__((packed))
26   {
27     guint8 eth[6];
28     address_t ip;
29     struct __attribute__((packed))
30     {
31       address_t host;
32       guint16 port;
33     } tcp;
34   } addr;
35 } node_id_t;
36 
37 void node_id_clear(node_id_t *a);
38 gint node_id_compare(const node_id_t *a, const node_id_t *b);
39 /* returns a newly allocated string with a human-readable id */
40 gchar *node_id_str(const node_id_t *id);
41 /* returns a newly allocated string with a dump of id */
42 gchar *node_id_dump(const node_id_t *id);
43 /* returns a newly allocated string with an xml dump of id */
44 gchar *node_id_xml(const node_id_t *id);
45 
46 /* a node name */
47 typedef struct
48 {
49   node_id_t node_id;
50   GString *numeric_name; /* readable version of node_id */
51   GString *res_name; /* resolved name - NULL if not resolved */
52   gdouble accumulated; /* total accumulated traffic */
53 } name_t;
54 
55 name_t *node_name_create(const node_id_t *node_id);
56 void node_name_delete(name_t *name);
57 void node_name_assign(name_t *name, const gchar *nm, const gchar *num_nm,
58                       gdouble sz);
59 gint node_name_id_compare(const name_t *a, const name_t *b);
60 gint node_name_freq_compare(gconstpointer a, gconstpointer b);
61 gchar *node_name_dump(const name_t *name);
62 gchar *node_name_xml(const name_t *name);
63 long active_names(void);
64 
65 #endif
66