Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

nodes.h

Go to the documentation of this file.
00001 /*
00002  * $Id: nodes.h,v 1.20 2005/11/26 22:19:12 cbiere Exp $
00003  *
00004  * Copyright (c) 2001-2003, Raphael Manfredi, Richard Eckart
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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  * XXX this structure should really be inlined in a node,
00041  * XXX to avoid definition duplication --RAM, 2004-08-21
00042  */
00043 
00044 typedef struct gnet_node_status {
00045     guchar status;              
00047     /* FIXME: the variables below should go to gnet_node_info since they
00048      *        only change very seldom
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      * Traffic statistics -- RAM, 13/05/2002.
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      * Gnutella statistics -- RAM, 10/12/2003.
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  * Peer modes.
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  * QRT state.
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  * Node states.
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  * Nodes callback definitions
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  *** Gnet nodes
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  * Nodes public interface
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 /* CORE_SOURCES */
00245 
00246 #endif /* _if_core_nodes_h */
00247 /* vi: set ts=4 sw=4 cindent: */

Generated on Sun Feb 12 10:49:57 2006 for Gtk-Gnutella by doxygen 1.3.6