00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _if_core_nodes_h_
00027 #define _if_core_nodes_h_
00028
00029 #include "common.h"
00030
00031 #include "if/core/hosts.h"
00032 #include "lib/vendors.h"
00033
00037 typedef guint32 gnet_node_t;
00038
00039
00040
00041
00042
00043
00044 typedef struct gnet_node_status {
00045 guchar status;
00047
00048
00049
00050 time_t connect_date;
00051 time_t up_date;
00052 guint32 gnet_files_count;
00053 guint32 gnet_kbytes_count;
00054 gboolean gnet_info_known;
00056 guint32 sent;
00057 guint32 received;
00058 guint32 tx_dropped;
00059 guint32 rx_dropped;
00060 guint32 n_bad;
00061 guint16 n_dups;
00062 guint16 n_hard_ttl;
00063 guint32 n_weird;
00064 guint32 n_hostile;
00066 gint squeue_sent;
00067 gint squeue_count;
00068 gint mqueue_count;
00069 gint mqueue_percent_used;
00070 gboolean in_tx_flow_control;
00071 gboolean in_tx_swift_control;
00072
00073
00074
00075
00076
00077 gint32 tx_given;
00078 gint32 tx_deflated;
00079 gint32 tx_written;
00080 gboolean tx_compressed;
00081 gfloat tx_compression_ratio;
00082 guint32 tx_bps;
00084 gint32 rx_given;
00085 gint32 rx_inflated;
00086 gint32 rx_read;
00087 gboolean rx_compressed;
00088 gfloat rx_compression_ratio;
00089 gfloat rx_bps;
00091
00092
00093
00094
00095 gboolean has_qrp;
00096 gfloat qrp_efficiency;
00097 guint32 rx_queries;
00098 guint32 tx_queries;
00099 guint32 rx_qhits;
00100 guint32 tx_qhits;
00102 gint qrt_slots;
00103 gint qrt_generation;
00104 gint qrt_fill_ratio;
00105 gint qrt_pass_throw;
00107 guint32 rt_avg;
00108 guint32 rt_last;
00110 guint32 tcp_rtt;
00111 guint32 udp_rtt;
00113 gint shutdown_remain;
00114 gchar message[128];
00115 } gnet_node_status_t;
00116
00117 typedef struct gnet_node_info {
00118 gnet_node_t node_handle;
00120 gchar *error_str;
00121 gint proto_major;
00122 gint proto_minor;
00123 gchar *vendor;
00124 gint country;
00125 union vendor_code vcode;
00127 host_addr_t addr;
00128 guint16 port;
00130 gboolean is_pseudo;
00132 host_addr_t gnet_addr;
00133 guint16 gnet_port;
00134 gchar gnet_guid[GUID_RAW_SIZE];
00135 } gnet_node_info_t;
00136
00137
00138
00139
00140
00141 typedef enum {
00142 NODE_P_LEAF = 0,
00143 NODE_P_AUTO,
00144 NODE_P_ULTRA,
00145 NODE_P_NORMAL,
00146 NODE_P_CRAWLER,
00147 NODE_P_UDP,
00148 NODE_P_UNKNOWN
00149 } node_peer_t;
00150
00151
00152
00153
00154
00155 typedef enum {
00156 QRT_S_NONE = 0,
00157 QRT_S_SENDING,
00158 QRT_S_SENT,
00159 QRT_S_RECEIVING,
00160 QRT_S_PATCHING,
00161 QRT_S_RECEIVED
00162 } qrt_state_t;
00163
00164 typedef struct gnet_node_flags {
00165 node_peer_t peermode;
00166 qrt_state_t qrt_state;
00167 qrt_state_t uqrt_state;
00168 guint8 hops_flow;
00169 gboolean incoming;
00170 gboolean writable;
00171 gboolean readable;
00172 gboolean tx_compressed;
00173 gboolean rx_compressed;
00174 gboolean mqueue_empty;
00175 gboolean mqueue_above_lowat;
00176 gboolean in_tx_flow_control;
00177 gboolean in_tx_swift_control;
00178 gboolean is_push_proxied;
00179 gboolean is_proxying;
00180 gboolean tls;
00181 } gnet_node_flags_t;
00182
00183
00184
00185
00186 typedef enum {
00187 GTA_NODE_CONNECTING = 1,
00188 GTA_NODE_HELLO_SENT = 2,
00189 GTA_NODE_WELCOME_SENT = 3,
00190 GTA_NODE_CONNECTED = 4,
00191 GTA_NODE_REMOVING = 5,
00192 GTA_NODE_RECEIVING_HELLO = 6,
00193 GTA_NODE_SHUTDOWN = 7
00195 } gnet_node_state_t;
00196
00197 #define GTA_NORMAL_TTL 4
00199
00200
00201
00202 typedef void (*node_added_listener_t) (gnet_node_t);
00203 typedef void (*node_removed_listener_t) (gnet_node_t);
00204 typedef void (*node_info_changed_listener_t) (gnet_node_t);
00205 typedef void (*node_flags_changed_listener_t) (gnet_node_t);
00206
00207 #define node_add_listener(signal, callback) \
00208 CAT3(node_add_,signal,_listener)(callback);
00209
00210 #define node_remove_listener(signal, callback) \
00211 CAT3(node_remove_,signal,_listener)(callback);
00212
00213 #ifdef CORE_SOURCES
00214
00215
00216
00217
00218
00219 void node_add_node_added_listener(node_added_listener_t);
00220 void node_remove_node_added_listener(node_added_listener_t);
00221 void node_add_node_removed_listener(node_removed_listener_t);
00222 void node_remove_node_removed_listener(node_removed_listener_t);
00223 void node_add_node_info_changed_listener(node_info_changed_listener_t);
00224 void node_remove_node_info_changed_listener(node_info_changed_listener_t);
00225 void node_add_node_flags_changed_listener(node_flags_changed_listener_t);
00226 void node_remove_node_flags_changed_listener(node_flags_changed_listener_t);
00227
00228
00229
00230
00231 void node_add(const host_addr_t addr, guint16, guint32 flags);
00232 void node_remove_by_handle(gnet_node_t n);
00233 void node_remove_nodes_by_handle(GSList *node_list);
00234 void node_get_status(const gnet_node_t n, gnet_node_status_t *s);
00235 gnet_node_info_t *node_get_info(const gnet_node_t n);
00236 void node_clear_info(gnet_node_info_t *info);
00237 void node_free_info(gnet_node_info_t *info);
00238 void node_fill_flags(gnet_node_t n, gnet_node_flags_t *flags);
00239 void node_fill_info(const gnet_node_t n, gnet_node_info_t *info);
00240
00241 void node_udp_gui_show(void);
00242 void node_udp_gui_remove(void);
00243
00244 #endif
00245
00246 #endif
00247