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.

rehook.h 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* This file is part of Netsukuku
  2. * (c) Copyright 2005 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 REHOOK_H
  19. #define REHOOK_H
  20. int rehook_mutex; /* The can be only one rehook at the same time */
  21. /*
  22. * REHOOK_PER_INSTANCE the is total number of rehooks allowed in
  23. * REHOOK_INSTANCE_TIME(level) seconds. After REHOOK_INSTANCE_TIME(level)
  24. * seconds have passed since the first rehook, REHOOK_WAIT_TIME(level) seconds
  25. * must be waited before rehooking again.
  26. * `level' is the level where the rehook is taking place.
  27. * REHOOK_WAIT_TIME is calculated in this way:
  28. * ((8<<level) - (1<<level)) * 60
  29. */
  30. #define REHOOK_PER_INSTANCE 8
  31. #define REHOOK_INSTANCE_TIME(level) (REHOOK_PER_INSTANCE*(level)*60)
  32. #define REHOOK_WAIT_TIME(level) (( (8<<(level)) - (1<<(level)) ) * 60)
  33. time_t last_instance_rehook; /* When the first rehook of the latest
  34. instance occurred */
  35. int total_rehooks; /* Number of rehooks made in the current
  36. instance.
  37. It cannot be > REHOOK_PER_INSTANCE */
  38. #define CHALLENGE_THRESHOLD (1<<16) /* When the gnode X, which must
  39. rehook, has a gnode_count >= (1<<16)
  40. it sends a new challenge. */
  41. /* `rk_gnode_ip' is the ip that will be used if we cannot rehook directly to
  42. * any gnode: a new gnode is created with the ip equal to `rk_gnode_ip'. */
  43. inet_prefix rk_gnode_ip;
  44. /* * * Functions declaration * * */
  45. void rehook_init(void);
  46. void new_rehook(map_gnode * gnode, int gid, int level, int gnode_count);
  47. int rehook(map_gnode * hook_gnode, int hook_level);
  48. #endif /*REHOOK_H */