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.

netsukuku.h 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 NETSUKUKU_H
  19. #define NETSUKUKU_H
  20. #include "config.h"
  21. #include "igs.h"
  22. #define VERSION_STR "NetsukukuD "VERSION
  23. #ifdef DEBUG
  24. #undef VERSION_STR
  25. #define VERSION_STR "NetsukukuD "VERSION" (debug)"
  26. #endif
  27. struct {
  28. int netsplit_inet_mode;
  29. int netsplit_ntk_mode;
  30. } netsplit;
  31. /*
  32. * current_globals
  33. *
  34. * Here there are the main globals variables used among the code.
  35. */
  36. struct current_globals {
  37. /*
  38. * Internal map
  39. */
  40. map_node *int_map; /*Internal Map */
  41. /*
  42. * External map
  43. */
  44. map_gnode **ext_map; /*External Map. */
  45. quadro_group cur_quadg;
  46. /*
  47. * Border nodes maps.(bmap.h)
  48. */
  49. map_bnode **bnode_map;
  50. u_int *bmap_nodes; /* bnode counter for each map */
  51. u_int *bmap_nodes_closed; /* number of closed bnodes */
  52. u_int *bmap_nodes_opened; /* " " opened " */
  53. /*
  54. * Myself
  55. */
  56. inet_prefix cur_ip;
  57. map_node *cur_node;
  58. /*
  59. * external rnode cache list. (see gmap.h)
  60. */
  61. ext_rnode_cache *cur_erc;
  62. u_int cur_erc_counter;
  63. /*
  64. * Current Qspn id and qspn time
  65. */
  66. int *cur_qspn_id; /*The current qspn_id we are processing.
  67. It is cur_qspn_id[levels] big */
  68. struct timeval *cur_qspn_time; /*When the last qspn round was received/sent
  69. (gettimeofday format) */
  70. /*
  71. * Internet gateways
  72. */
  73. inet_gw **igws;
  74. int *igws_counter;
  75. inet_gw **my_igws; /* my_igws[level] points to our inet gateway
  76. present at igws[level]. It's the same of using
  77. igw_find_node(igws, me.cur_quadg.gnode[_EL(level)]); */
  78. u_char my_bandwidth; /* The bandwidth of the Internet connection
  79. we are sharing */
  80. u_char inet_connected; /* If it is 1, we are connected to the Internet */
  81. /*
  82. * Network interfaces
  83. */
  84. interface cur_ifs[MAX_INTERFACES];
  85. int cur_ifs_n; /* number of interfaces present
  86. in `cur_ifs' */
  87. time_t uptime; /*The time when we finished the hooking,
  88. to get the the actual uptime just do:
  89. time(0)-me.uptime */
  90. } me;
  91. #define NTK_TCP_PORT 269
  92. #define NTK_UDP_RADAR_PORT 269
  93. #define ANDNA_UDP_PORT 277
  94. #define ANDNA_TCP_PORT 277
  95. const static u_short ntk_udp_radar_port = NTK_UDP_RADAR_PORT,
  96. ntk_tcp_port = NTK_TCP_PORT;
  97. const static u_short andna_udp_port = ANDNA_UDP_PORT,
  98. andna_tcp_port = ANDNA_TCP_PORT;
  99. #define NTK_CONFIG_FILE CONF_DIR "/netsukuku.conf"
  100. #define NTK_PID_FILE PID_DIR "/ntkd.pid"
  101. #define INT_MAP_FILE DATA_DIR "/ntk_internal_map"
  102. #define EXT_MAP_FILE DATA_DIR "/ntk_external_map"
  103. #define BNODE_MAP_FILE DATA_DIR "/ntk_bnode_map"
  104. #define ANDNA_HNAMES_FILE CONF_DIR "/andna_hostnames"
  105. #define SNSD_NODES_FILE CONF_DIR "/snsd_nodes"
  106. #define ANDNA_CACHE_FILE DATA_DIR "/andna_cache"
  107. #define LCLKEY_FILE DATA_DIR "/andna_lcl_keyring"
  108. #define LCL_FILE DATA_DIR "/andna_lcl_cache"
  109. #define RHC_FILE DATA_DIR "/andna_rh_cache"
  110. #define COUNTER_C_FILE DATA_DIR "/andna_counter_cache"
  111. #define IPMASQ_SCRIPT_FILE CONF_DIR "/ip_masquerade.sh"
  112. #define TCSHAPER_SCRIPT_FILE CONF_DIR "/tc_shaper.sh"
  113. /*
  114. * ServOpt
  115. *
  116. * Options
  117. */
  118. typedef struct {
  119. char *config_file;
  120. char *pid_file;
  121. int family;
  122. char *ifs[MAX_INTERFACES];
  123. int ifs_n; /* number of interfaces present in `ifs' */
  124. char *int_map_file;
  125. char *ext_map_file;
  126. char *bnode_map_file;
  127. char *andna_hnames_file;
  128. char *snsd_nodes_file;
  129. char *andna_cache_file;
  130. char *lclkey_file;
  131. char *lcl_file;
  132. char *rhc_file;
  133. char *counter_c_file;
  134. char daemon;
  135. char restricted;
  136. int restricted_class;
  137. char inet_connection; /* If it's 1, we are connected
  138. to the Internet */
  139. char share_internet;
  140. char shape_internet;
  141. char use_shared_inet;
  142. inet_prefix inet_gw;
  143. char *inet_gw_dev;
  144. char **inet_hosts; /* Hosts to be pinged in order to check
  145. if the internet connection is up */
  146. int inet_hosts_counter;
  147. char *ip_masq_script;
  148. char *tc_shaper_script;
  149. /* The bandwidths of the Internet connection we are sharing.
  150. * If we are just leeching they are all 0. */
  151. u_int my_upload_bw;
  152. u_int my_dnload_bw;
  153. char disable_andna;
  154. char disable_resolvconf;
  155. int max_connections;
  156. int max_accepts_per_host;
  157. int max_accepts_per_host_time;
  158. char dbg_lvl;
  159. } ServOpt;
  160. ServOpt server_opt;
  161. time_t sigterm_timestamp, sighup_timestamp, sigalrm_timestamp;
  162. /*
  163. * set_option_literal: set an option from a default value
  164. */
  165. #define set_option_literal(opt, l) \
  166. { \
  167. if(!(*opt = malloc(strlen(l)+1))) \
  168. { \
  169. perror("Unable to allocate memory for option default value");\
  170. exit(-1); \
  171. } \
  172. strcpy(*opt, l); \
  173. }
  174. /*
  175. * set_option_str: set an option from a default value
  176. */
  177. #define set_option_str(opt, str) \
  178. { \
  179. if(!(*opt = realloc(*opt, strlen(str) + 1))) \
  180. { \
  181. perror("Unable to allocate memory for option"); \
  182. exit(-1); \
  183. } \
  184. strcpy(*opt, str); \
  185. }
  186. #endif /*NETSUKUKU_H */