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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. {
  35. u_char flags;
  36. u_short hops;
  37. u_short first_qspn_open_chunk;
  38. }_PACKED_ tracer_hdr;
  39. INT_INFO tracer_hdr_iinfo = { 2,
  40. { INT_TYPE_16BIT, INT_TYPE_16BIT },
  41. { sizeof(u_char), sizeof(u_char)+sizeof(u_short) },
  42. { 1, 1 }
  43. };
  44. typedef struct
  45. {
  46. u_char node;
  47. u_int rtt; /* The rtt to reach the `node' of the previous
  48. chunk from the node of the current `one'.
  49. (in milliseconds) */
  50. u_int gcount; /* how many nodes there are in the `node'
  51. gnode */
  52. }_PACKED_ tracer_chunk;
  53. INT_INFO tracer_chunk_iinfo = { 2,
  54. { INT_TYPE_32BIT, INT_TYPE_32BIT },
  55. { sizeof(char), sizeof(char)+sizeof(u_int) },
  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, u_char level);
  67. int tracer_add_rtt(int rpos, tracer_chunk *tracer, u_short hop);
  68. u_short tracer_split_bblock(void *, size_t, bnode_hdr ***, bnode_chunk ****, size_t *);
  69. int tracer_get_trtt(int from_rnode_pos, tracer_hdr *trcr_hdr,
  70. tracer_chunk *tracer, u_int *trtt);
  71. int tracer_store_pkt(inet_prefix, quadro_group *, u_char, tracer_hdr *,
  72. tracer_chunk *, void *, size_t, u_short *, char **, size_t *);
  73. int tracer_unpack_pkt(PACKET, brdcast_hdr **, tracer_hdr **, tracer_chunk **,
  74. bnode_hdr **, size_t *, quadro_group *, int *);
  75. int tracer_pkt_build(u_char, int, int, int, u_char, brdcast_hdr *, tracer_hdr *,
  76. tracer_chunk *, u_short, char *, size_t, PACKET *);
  77. /*
  78. * TRACER_PKT_EXCLUDE_VARS:
  79. * `e_rnode': if the dst is an external rnode, the relative one is passed.
  80. * `node': the destination node/gnode we are sending the pkt to.
  81. * `from_rpos': the position in the root_node's rnodes of the node from
  82. * which the pkt was sent to us.
  83. * `pos' : the position of the `node' in the root_node's rnodes.
  84. * `level': The level where there is the gnode the pkt is restricted to.
  85. * `sub_id': If the pkt is a qspn_open, it is the qspn open sub_id of
  86. * the pkt.
  87. */
  88. #define TRACER_PKT_EXCLUDE_VARS ext_rnode *e_rnode, map_node *node, \
  89. int from_rpos, int pos, \
  90. u_char excl_level, int sub_id
  91. #define TRACER_PKT_EXCLUDE_VARS_NAME e_rnode, node, from_rpos, pos, \
  92. excl_level, sub_id
  93. int flood_pkt_send(int(*is_node_excluded)(TRACER_PKT_EXCLUDE_VARS), u_char level,
  94. int sub_id, int from_rpos, PACKET pkt);
  95. int exclude_from(TRACER_PKT_EXCLUDE_VARS);
  96. int exclude_glevel(TRACER_PKT_EXCLUDE_VARS);
  97. int exclude_all_but_notfrom(TRACER_PKT_EXCLUDE_VARS);
  98. int exclude_from_and_glevel(TRACER_PKT_EXCLUDE_VARS);
  99. int tracer_pkt_recv(PACKET rpkt);
  100. int tracer_pkt_start(u_char level);
  101. #endif /*TRACER_H*/