resend.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 REQUEST_TIMEOUT 65000
  20. #define RESEND_MAX 3
  21. #define RESEND_REQUEST 1
  22. #define RESEND_UPDATE 2
  23. struct resend {
  24. unsigned char kind;
  25. unsigned char max;
  26. unsigned short delay;
  27. struct timeval time;
  28. unsigned char prefix[16];
  29. unsigned char plen;
  30. unsigned char src_prefix[16];
  31. unsigned char src_plen;
  32. unsigned short seqno;
  33. unsigned char id[8];
  34. // -- lorauth --
  35. unsigned short clen;
  36. unsigned char cipher[514];
  37. // ----
  38. struct interface *ifp;
  39. struct resend *next;
  40. };
  41. extern struct timeval resend_time;
  42. struct resend *find_request(const unsigned char *prefix, unsigned char plen,
  43. const unsigned char *src_prefix, unsigned char src_plen,
  44. struct resend **previous_return);
  45. void flush_resends(struct neighbour *neigh);
  46. int record_resend(int kind, const unsigned char *prefix, unsigned char plen,
  47. const unsigned char *src_prefix, unsigned char src_plen,
  48. // -- lorauth --
  49. const unsigned char *cipher, unsigned short clen,
  50. // ----
  51. unsigned short seqno, const unsigned char *id,
  52. struct interface *ifp, int delay);
  53. int unsatisfied_request(const unsigned char *prefix, unsigned char plen,
  54. const unsigned char *src_prefix, unsigned char src_plen,
  55. unsigned short seqno, const unsigned char *id);
  56. int request_redundant(struct interface *ifp,
  57. const unsigned char *prefix, unsigned char plen,
  58. const unsigned char *src_prefix, unsigned char src_plen,
  59. unsigned short seqno, const unsigned char *id);
  60. int satisfy_request(const unsigned char *prefix, unsigned char plen,
  61. const unsigned char *src_prefix, unsigned char src_plen,
  62. unsigned short seqno, const unsigned char *id,
  63. struct interface *ifp);
  64. void expire_resend(void);
  65. void recompute_resend_time(void);
  66. void do_resend(void);