The Netsukuku Project  0.0.9
An Alternative routing method
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
tracer.h
Go to the documentation of this file.
1 /* This file is part of Netsukuku
2  * (c) Copyright 2004 Andrea Lo Pumo aka AlpT <alpt@freaknet.org>
3  *
4  * This source code is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as published
6  * by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  *
9  * This source code 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.
12  * Please refer to the GNU Public License for more details.
13  *
14  * You should have received a copy of the GNU Public License along with
15  * this source code; if not, write to:
16  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 
19 #ifndef TRACER_H
20 #define TRACER_H
21 
22 #include "pkts.h"
23 #include "bmap.h"
24 
25 
26 #define TRACER_RQ_TIMEOUT 16 /* seconds */
27 
28 /*
29  * Tracer_hdr flags
30  */
31 
32 #define TRCR_BBLOCK 1 /* In this tracer_pkt there are
33  encapsulated bblocks */
34 #define TRCR_IGW (1<<1) /* Internet Gateways are encapsulated
35  in the pkt */
36 
37 /*
38  * * Tracer packet. It is encapsulated in a broadcast pkt *
39  */
40 typedef struct
41 {
42  u_char flags;
43  u_short hops;
45 }_PACKED_ tracer_hdr;
48  { sizeof(u_char), sizeof(u_char)+sizeof(u_short) },
49  { 1, 1 }
50  };
51 typedef struct
52 {
53  u_char node;
54  u_int rtt; /* The rtt to reach the `node' of the previous
55  chunk from the node of the current `one'.
56  (in milliseconds) */
57  u_int gcount; /* how many nodes there are in the `node'
58  gnode */
59 }_PACKED_ tracer_chunk;
62  { sizeof(char), sizeof(char)+sizeof(u_int) },
63  { 1, 1 }
64  };
65 #define TRACERPKT_SZ(hops) (sizeof(tracer_hdr)+(sizeof(tracer_chunk)*(hops)))
66 #define TRACER_HDR_PTR(msg) ((tracer_hdr *)(((char *)BRDCAST_HDR_PTR((msg)))+sizeof(brdcast_hdr)))
67 #define TRACER_CHUNK_PTR(msg) ((tracer_chunk *)(((char *)TRACER_HDR_PTR(msg))+sizeof(tracer_hdr)))
68 
70 
71 /*Functions definition. Damn I hate to use functions with a lot of args. It isn't elegant*/
72 int ip_to_rfrom(inet_prefix rip, quadro_group *rip_quadg,
73  quadro_group *new_quadg, char quadg_flags);
74 tracer_chunk *tracer_add_entry(void *void_map, void *void_node,
75  tracer_chunk *tracer, u_int *hops, u_char level);
76 int tracer_add_rtt(int rpos, tracer_chunk *tracer, u_short hop);
77 u_short tracer_split_bblock(void *, size_t, bnode_hdr ***, bnode_chunk ****, size_t *);
78 int tracer_get_trtt(int from_rnode_pos, tracer_hdr *trcr_hdr,
79  tracer_chunk *tracer, u_int *trtt);
80 int tracer_store_pkt(inet_prefix, quadro_group *, u_char, tracer_hdr *,
81  tracer_chunk *, void *, size_t, u_short *, char **, size_t *);
82 int tracer_unpack_pkt(PACKET, brdcast_hdr **, tracer_hdr **, tracer_chunk **,
83  bnode_hdr **, size_t *, quadro_group *, int *);
84 int tracer_pkt_build(u_char, int, int, int, u_char, brdcast_hdr *, tracer_hdr *,
85  tracer_chunk *, u_short, char *, size_t, PACKET *);
86 
87 /*
88  * TRACER_PKT_EXCLUDE_VARS:
89  * `e_rnode': if the dst is an external rnode, the relative one is passed.
90  * `node': the destination node/gnode we are sending the pkt to.
91  * `from_rpos': the position in the root_node's rnodes of the node from
92  * which the pkt was sent to us.
93  * `pos' : the position of the `node' in the root_node's rnodes.
94  * `level': The level where there is the gnode the pkt is restricted to.
95  * `sub_id': If the pkt is a qspn_open, it is the qspn open sub_id of
96  * the pkt.
97  */
98 #define TRACER_PKT_EXCLUDE_VARS ext_rnode *e_rnode, map_node *node, \
99  int from_rpos, int pos, \
100  u_char excl_level, int sub_id
101 #define TRACER_PKT_EXCLUDE_VARS_NAME e_rnode, node, from_rpos, pos, \
102  excl_level, sub_id
103 int flood_pkt_send(int(*is_node_excluded)(TRACER_PKT_EXCLUDE_VARS), u_char level,
104  int sub_id, int from_rpos, PACKET pkt);
109 
110 int tracer_pkt_recv(PACKET rpkt);
111 int tracer_pkt_start(u_char level);
112 
113 #endif /*TRACER_H*/
int tracer_unpack_pkt(PACKET, brdcast_hdr **, tracer_hdr **, tracer_chunk **, bnode_hdr **, size_t *, quadro_group *, int *)
Definition: tracer.c:645
int tracer_add_rtt(int rpos, tracer_chunk *tracer, u_short hop)
Definition: tracer.c:242
static const int_info tracer_chunk_iinfo
Definition: tracer.h:60
tracer_chunk * tracer_add_entry(void *void_map, void *void_node, tracer_chunk *tracer, u_int *hops, u_char level)
Definition: tracer.c:163
#define INT_TYPE_16BIT
Definition: endianness.h:36
int tracer_get_trtt(int from_rnode_pos, tracer_hdr *trcr_hdr, tracer_chunk *tracer, u_int *trtt)
Definition: tracer.c:254
Definition: inet.h:73
Definition: gmap.h:127
u_short hops
Definition: tracer.h:43
int exclude_from(ext_rnode *e_rnode, map_node *node, int from_rpos, int pos, u_char excl_level, int sub_id)
Definition: tracer.c:1359
u_int gcount
Definition: tracer.h:57
int ip_to_rfrom(inet_prefix rip, quadro_group *rip_quadg, quadro_group *new_quadg, char quadg_flags)
Definition: tracer.c:45
#define TRACER_PKT_EXCLUDE_VARS
Definition: tracer.h:98
int exclude_all_but_notfrom(ext_rnode *e_rnode, map_node *node, int from_rpos, int pos, u_char excl_level, int sub_id)
Definition: tracer.c:1367
int exclude_glevel(ext_rnode *e_rnode, map_node *node, int from_rpos, int pos, u_char excl_level, int sub_id)
Definition: tracer.c:1340
int tracer_pkt_start_mutex
Definition: tracer.h:69
int tracer_store_pkt(inet_prefix, quadro_group *, u_char, tracer_hdr *, tracer_chunk *, void *, size_t, u_short *, char **, size_t *)
Definition: tracer.c:1069
#define INT_INFO
Definition: endianness.h:90
int tracer_pkt_start(u_char level)
Definition: tracer.c:1516
u_short tracer_split_bblock(void *, size_t, bnode_hdr ***, bnode_chunk ****, size_t *)
Definition: tracer.c:747
static const int_info tracer_hdr_iinfo
Definition: tracer.h:46
int flood_pkt_send(int(*is_node_excluded)(ext_rnode *e_rnode, map_node *node, int from_rpos, int pos, u_char excl_level, int sub_id), u_char level, int sub_id, int from_rpos, PACKET pkt)
Definition: tracer.c:1277
int exclude_from_and_glevel(ext_rnode *e_rnode, map_node *node, int from_rpos, int pos, u_char excl_level, int sub_id)
Definition: tracer.c:1374
Definition: pkts.h:118
int flags
Definition: if.c:39
#define INT_TYPE_32BIT
Definition: endianness.h:35
int tracer_pkt_build(u_char, int, int, int, u_char, brdcast_hdr *, tracer_hdr *, tracer_chunk *, u_short, char *, size_t, PACKET *)
Definition: tracer.c:429
u_char node
Definition: tracer.h:53
Definition: bmap.h:89
u_short first_qspn_open_chunk
Definition: tracer.h:44
int tracer_pkt_recv(PACKET rpkt)
Definition: tracer.c:1388