You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tracer.h 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #ifndef TRACER_H
  19. #define TRACER_H
  20. #include "pkts.h"
  21. #include "bmap.h"
  22. #define TRACER_RQ_TIMEOUT 16 /* seconds */
  23. /*
  24. * Tracer_hdr flags
  25. */
  26. #define TRCR_BBLOCK 1 /* In this tracer_pkt there are
  27. encapsulated bblocks */
  28. #define TRCR_IGW (1<<1) /* Internet Gateways are encapsulated
  29. in the pkt */
  30. /*
  31. * * Tracer packet. It is encapsulated in a broadcast pkt *
  32. */
  33. typedef struct {
  34. u_char flags;
  35. u_short hops;
  36. u_short first_qspn_open_chunk;
  37. } _PACKED_ tracer_hdr;
  38. INT_INFO tracer_hdr_iinfo = { 2,
  39. {INT_TYPE_16BIT, INT_TYPE_16BIT},
  40. {sizeof(u_char), sizeof(u_char) + sizeof(u_short)}
  41. ,
  42. {1, 1}
  43. };
  44. typedef struct {
  45. u_char node;
  46. u_int rtt; /* The rtt to reach the `node' of the previous
  47. chunk from the node of the current `one'.
  48. (in milliseconds) */
  49. u_int gcount; /* how many nodes there are in the `node'
  50. gnode */
  51. } _PACKED_ tracer_chunk;
  52. INT_INFO tracer_chunk_iinfo = { 2,
  53. {INT_TYPE_32BIT, INT_TYPE_32BIT},
  54. {sizeof(char), sizeof(char) + sizeof(u_int)}
  55. ,
  56. {1, 1}
  57. };
  58. #define TRACERPKT_SZ(hops) (sizeof(tracer_hdr)+(sizeof(tracer_chunk)*(hops)))
  59. #define TRACER_HDR_PTR(msg) ((tracer_hdr *)(((char *)BRDCAST_HDR_PTR((msg)))+sizeof(brdcast_hdr)))
  60. #define TRACER_CHUNK_PTR(msg) ((tracer_chunk *)(((char *)TRACER_HDR_PTR(msg))+sizeof(tracer_hdr)))
  61. int tracer_pkt_start_mutex;
  62. /*Functions definition. Damn I hate to use functions with a lot of args. It isn't elegant*/
  63. int ip_to_rfrom(inet_prefix rip, quadro_group * rip_quadg,
  64. quadro_group * new_quadg, char quadg_flags);
  65. tracer_chunk *tracer_add_entry(void *void_map, void *void_node,
  66. tracer_chunk * tracer, u_int * hops,
  67. u_char level);
  68. int tracer_add_rtt(int rpos, tracer_chunk * tracer, u_short hop);
  69. u_short tracer_split_bblock(void *, size_t, bnode_hdr ***,
  70. bnode_chunk ****, size_t *);
  71. int tracer_get_trtt(int from_rnode_pos, tracer_hdr * trcr_hdr,
  72. tracer_chunk * tracer, u_int * trtt);
  73. int tracer_store_pkt(inet_prefix, quadro_group *, u_char, tracer_hdr *,
  74. tracer_chunk *, void *, size_t, u_short *, char **,
  75. size_t *);
  76. int tracer_unpack_pkt(PACKET, brdcast_hdr **, tracer_hdr **,
  77. tracer_chunk **, bnode_hdr **, size_t *,
  78. quadro_group *, int *);
  79. int tracer_pkt_build(u_char, int, int, int, u_char, brdcast_hdr *,
  80. tracer_hdr *, tracer_chunk *, u_short, char *, size_t,
  81. PACKET *);
  82. /*
  83. * TRACER_PKT_EXCLUDE_VARS:
  84. * `e_rnode': if the dst is an external rnode, the relative one is passed.
  85. * `node': the destination node/gnode we are sending the pkt to.
  86. * `from_rpos': the position in the root_node's rnodes of the node from
  87. * which the pkt was sent to us.
  88. * `pos' : the position of the `node' in the root_node's rnodes.
  89. * `level': The level where there is the gnode the pkt is restricted to.
  90. * `sub_id': If the pkt is a qspn_open, it is the qspn open sub_id of
  91. * the pkt.
  92. */
  93. #define TRACER_PKT_EXCLUDE_VARS ext_rnode *e_rnode, map_node *node, \
  94. int from_rpos, int pos, \
  95. u_char excl_level, int sub_id
  96. #define TRACER_PKT_EXCLUDE_VARS_NAME e_rnode, node, from_rpos, pos, \
  97. excl_level, sub_id
  98. int flood_pkt_send(int (*is_node_excluded) (TRACER_PKT_EXCLUDE_VARS),
  99. u_char level, int sub_id, int from_rpos, PACKET pkt);
  100. int exclude_from(TRACER_PKT_EXCLUDE_VARS);
  101. int exclude_glevel(TRACER_PKT_EXCLUDE_VARS);
  102. int exclude_all_but_notfrom(TRACER_PKT_EXCLUDE_VARS);
  103. int exclude_from_and_glevel(TRACER_PKT_EXCLUDE_VARS);
  104. int tracer_pkt_recv(PACKET rpkt);
  105. int tracer_pkt_start(u_char level);
  106. #endif /*TRACER_H */