message.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. Copyright (c) 2007, 2008 by Juliusz Chroboczek
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #define MAX_BUFFERED_UPDATES 200
  20. #define BUCKET_TOKENS_MAX 4000
  21. #define BUCKET_TOKENS_PER_SEC 1000
  22. #define MESSAGE_PAD1 0
  23. #define MESSAGE_PADN 1
  24. #define MESSAGE_ACK_REQ 2
  25. #define MESSAGE_ACK 3
  26. #define MESSAGE_HELLO 4
  27. #define MESSAGE_IHU 5
  28. #define MESSAGE_ROUTER_ID 6
  29. #define MESSAGE_NH 7
  30. #define MESSAGE_UPDATE 8
  31. #define MESSAGE_REQUEST 9
  32. #define MESSAGE_MH_REQUEST 10
  33. /* 11 and 12 are for authentication */
  34. #define MESSAGE_UPDATE_SRC_SPECIFIC 13
  35. #define MESSAGE_REQUEST_SRC_SPECIFIC 14
  36. #define MESSAGE_MH_REQUEST_SRC_SPECIFIC 15
  37. /* 29 for lorauth */
  38. #define MESSAGE_LORAUTH 29
  39. /* Protocol extension through sub-TLVs. */
  40. #define SUBTLV_PAD1 0
  41. #define SUBTLV_PADN 1
  42. #define SUBTLV_DIVERSITY 2 /* Also known as babelz. */
  43. #define SUBTLV_TIMESTAMP 3 /* Used to compute RTT. */
  44. extern unsigned short myseqno;
  45. extern struct timeval seqno_time;
  46. extern int broadcast_ihu;
  47. extern int split_horizon;
  48. extern unsigned char packet_header[4];
  49. extern struct neighbour *unicast_neighbour;
  50. extern struct timeval unicast_flush_timeout;
  51. void parse_packet(const unsigned char *from, struct interface *ifp,
  52. const unsigned char *packet, int packetlen);
  53. void flushbuf(struct interface *ifp);
  54. void flushupdates(struct interface *ifp);
  55. void send_ack(struct neighbour *neigh, unsigned short nonce,
  56. unsigned short interval);
  57. void send_hello_noupdate(struct interface *ifp, unsigned interval);
  58. void send_hello(struct interface *ifp);
  59. void flush_unicast(int dofree);
  60. void send_update(struct interface *ifp, int urgent,
  61. const unsigned char *prefix, unsigned char plen,
  62. const unsigned char *src_prefix, unsigned char src_plen,
  63. // -- lorauth --
  64. const unsigned char *cipher, unsigned short clen
  65. // ----
  66. );
  67. void send_update_resend(struct interface *ifp,
  68. const unsigned char *prefix, unsigned char plen,
  69. const unsigned char *src_prefix,
  70. unsigned char src_plen,
  71. // -- lorauth --
  72. const unsigned char *cipher, unsigned short clen
  73. // ----
  74. );
  75. void send_wildcard_retraction(struct interface *ifp);
  76. void update_myseqno(void);
  77. void send_self_update(struct interface *ifp);
  78. void send_ihu(struct neighbour *neigh, struct interface *ifp);
  79. void send_marginal_ihu(struct interface *ifp);
  80. void send_request(struct interface *ifp,
  81. const unsigned char *prefix, unsigned char plen,
  82. const unsigned char *src_prefix, unsigned char src_plen);
  83. void send_unicast_request(struct neighbour *neigh,
  84. const unsigned char *prefix, unsigned char plen,
  85. const unsigned char *src_prefix,
  86. unsigned char src_plen);
  87. void send_multihop_request(struct interface *ifp,
  88. const unsigned char *prefix, unsigned char plen,
  89. const unsigned char *src_prefix,
  90. unsigned char src_plen,
  91. unsigned short seqno, const unsigned char *id,
  92. unsigned short hop_count);
  93. void
  94. send_unicast_multihop_request(struct neighbour *neigh,
  95. const unsigned char *prefix, unsigned char plen,
  96. const unsigned char *src_prefix,
  97. unsigned char src_plen,
  98. unsigned short seqno, const unsigned char *id,
  99. unsigned short hop_count);
  100. void send_request_resend(struct neighbour *neigh,
  101. const unsigned char *prefix, unsigned char plen,
  102. const unsigned char *src_prefix,
  103. unsigned char src_plen,
  104. unsigned short seqno, unsigned char *id);
  105. void handle_request(struct neighbour *neigh, const unsigned char *prefix,
  106. unsigned char plen,
  107. const unsigned char *src_prefix, unsigned char src_plen,
  108. unsigned char hop_count,
  109. unsigned short seqno, const unsigned char *id);