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

core/nodes.h File Reference

#include "common.h"
#include "mq.h"
#include "sq.h"
#include "rx.h"
#include "qrp.h"
#include "hsep.h"
#include "gnutella.h"
#include "extensions.h"
#include "if/core/wrap.h"
#include "if/core/hsep.h"
#include "if/core/guid.h"
#include "if/core/hcache.h"
#include "if/core/nodes.h"
#include "lib/header.h"

Go to the source code of this file.

Data Structures

struct  node_rxfc_mon
 This structure keeps tracks of remote flow-control indications and measures the time spent in flow-control over a period of time. More...
struct  gnutella_node

Defines

#define NODE_RX_FC_HALF_PERIOD   300
 5 minutes
#define MAX_CACHE_HOPS   6
 defines the maximum hop count we handle for the ping/pong caching scheme.
#define CACHE_HOP_IDX(h)   (((h) > MAX_CACHE_HOPS) ? MAX_CACHE_HOPS : (h))
 The macro returning the array index in the (0 ..
#define NODE_LEAF_MIN_FLOW   3
 The value of the hops-flow under which the leaf is not fully searcheable, and which will NOT have its QRP included in the inter-UP QRP table.
#define PING_REG_THROTTLE   3
 seconds, regular peer
#define PING_LEAF_THROTTLE   60
 seconds, peer is leaf node
#define NODE_ID_SELF   (node_id_get_self())
#define NODE_CR_CONNECTION   0x01
 Include connection times.
#define NODE_CR_LOCALE   0x02
 Include locale information.
#define NODE_CR_CRAWLABLE   0x04
 Include crawlable peers only.
#define NODE_CR_USER_AGENT   0x08
 Include user-agent strings.
#define NODE_CR_MASK   0x0f
 Mask for supported features.
#define NODE_CR_SEPARATOR   ';'
#define NODE_CR_ESCAPE_CHAR   '\\'
#define NODE_IS_CONNECTING(n)
#define NODE_IS_CONNECTED(n)
#define NODE_IS_INCOMING(n)   ((n)->flags & NODE_F_INCOMING)
#define NODE_IS_REMOVING(n)   ((n)->status == GTA_NODE_REMOVING)
#define NODE_IN_TX_FLOW_CONTROL(n)   ((n)->outq && mq_is_flow_controlled((n)->outq))
#define NODE_IN_TX_SWIFT_CONTROL(n)   ((n)->outq && mq_is_swift_controlled((n)->outq))
#define NODE_IS_WRITABLE(n)   ((n)->flags & NODE_F_WRITABLE)
#define NODE_IS_READABLE(n)   (((n)->flags & (NODE_F_READABLE|NODE_F_NOREAD)) == NODE_F_READABLE)
#define NODE_IS_ESTABLISHED(n)
#define NODE_MQUEUE_PERCENT_USED(n)   ((n)->outq ? mq_size((n)->outq) * 100 / mq_maxsize((n)->outq) : 0)
#define NODE_SQUEUE(n)   ((n)->searchq)
#define NODE_MQUEUE_COUNT(n)   ((n)->outq ? mq_count((n)->outq) : 0)
#define NODE_MQUEUE_PENDING(n)   ((n)->outq ? mq_pending((n)->outq) : 0)
#define NODE_MQUEUE_ABOVE_LOWAT(n)   ((n)->outq ? mq_size((n)->outq) > mq_lowat((n)->outq) : FALSE)
#define NODE_SQUEUE_COUNT(n)   ((n)->searchq ? sq_count((n)->searchq) : 0)
#define NODE_SQUEUE_SENT(n)   ((n)->searchq ? sq_sent((n)->searchq) : 0)
#define NODE_RX_COMPRESSED(n)   ((n)->attrs & NODE_A_RX_INFLATE)
#define NODE_TX_COMPRESSED(n)   ((n)->attrs & NODE_A_TX_DEFLATE)
#define NODE_TX_COMPRESSION_RATIO(n)
#define NODE_RX_COMPRESSION_RATIO(n)
#define NODE_ID(n)   ((n)->id)
#define NODE_CAN_SFLAG(n)   ((n)->attrs & NODE_A_CAN_SFLAG)
#define NODE_UP_QRP(n)   ((n)->attrs & NODE_A_UP_QRP)
#define NODE_LEAF_GUIDE(n)   ((n)->attrs & NODE_A_GUIDANCE)
#define NODE_CAN_INFLATE(n)   ((n)->attrs & NODE_A_CAN_INFLATE)
#define NODE_IS_LEAF(n)   ((n)->peermode == NODE_P_LEAF)
#define NODE_IS_NORMAL(n)   ((n)->peermode == NODE_P_NORMAL)
#define NODE_IS_ULTRA(n)   ((n)->peermode == NODE_P_ULTRA)
#define NODE_IS_UDP(n)   ((n)->peermode == NODE_P_UDP)
#define node_vendor(n)   ((n)->vendor != NULL ? (n)->vendor : "????")
#define node_type(n)   (NODE_IS_LEAF(n) ? "leaf" : NODE_IS_ULTRA(n) ? "ultra" : "legacy")
#define node_inc_sent(n)   node_add_sent(n, 1)
#define node_inc_txdrop(n)   node_add_txdrop(n, 1)
#define node_inc_rxdrop(n)   node_add_rxdrop(n, 1)
#define node_add_tx_given(n, x)   do { (n)->tx_given += (x); } while (0)
#define node_add_rx_read(n, x)   do { (n)->rx_read += (x); } while (0)
#define node_inc_tx_query(n)   do { (n)->tx_queries++; } while (0)
#define node_inc_rx_query(n)   do { (n)->rx_queries++; } while (0)
#define node_inc_tx_qhit(n)   do { (n)->tx_qhits++; } while (0)
#define node_inc_rx_qhit(n)   do { (n)->rx_qhits++; } while (0)
#define node_inc_qrp_query(n)   do { (n)->qrp_queries++; } while (0)
#define node_inc_qrp_match(n)   do { (n)->qrp_matches++; } while (0)
#define node_ultra_received_qrp(n)
#define node_leaf_sent_qrp(n)
#define node_query_hops_ok(n, h)   ((h) < (n)->hops_flow)
 Can we send query with hop count `h' according to node's hops-flow value?
#define node_flowc_swift_grace(n)   (NODE_IS_LEAF(n) ? 210 : 30)
 The grace period between the time the node enters flow-control and the time we want to speed up things and drop traffic, entering "swift" mode.
#define node_flowc_swift_period(n)   (NODE_IS_LEAF(n) ? 140 : 20)
 In "swift" mode, a callback is periodically invoked to drop more traffic if we don't see much progress in the queue backlog.
#define GNUTELLA_HELLO   "GNUTELLA CONNECT/"
#define GNUTELLA_HELLO_LENGTH   (sizeof(GNUTELLA_HELLO) - 1)

Typedefs

typedef gnutella_node gnutella_node_t

Enumerations

enum  node_magic_t { NODE_MAGIC = 0x67f8e02f }
enum  {
  NODE_F_HDSK_PING = 1 << 0, NODE_F_STALE_QRP = 1 << 1, NODE_F_INCOMING = 1 << 2, NODE_F_ESTABLISHED = 1 << 3,
  NODE_F_VALID = 1 << 4, NODE_F_ALIEN_IP = 1 << 5, NODE_F_WRITABLE = 1 << 6, NODE_F_READABLE = 1 << 7,
  NODE_F_BYE_SENT = 1 << 8, NODE_F_NODELAY = 1 << 9, NODE_F_NOREAD = 1 << 10, NODE_F_EOF_WAIT = 1 << 11,
  NODE_F_CLOSING = 1 << 12, NODE_F_ULTRA = 1 << 13, NODE_F_LEAF = 1 << 14, NODE_F_CRAWLER = 1 << 15,
  NODE_F_FAKE_NAME = 1 << 16, NODE_F_PROXY = 1 << 17, NODE_F_PROXIED = 1 << 18, NODE_F_QRP_SENT = 1 << 19,
  NODE_F_TSYNC_WAIT = 1 << 20, NODE_F_TSYNC_TCP = 1 << 21, NODE_F_GTKG = 1 << 22, NODE_F_FORCE = 1 << 23,
  NODE_F_NO_OOB_PROXY = 1 << 24, NODE_F_TLS = 1 << 25, NODE_F_CAN_TLS = 1 << 26
}
enum  {
  NODE_A_BYE_PACKET = 1 << 0, NODE_A_PONG_CACHING = 1 << 1, NODE_A_PONG_ALIEN = 1 << 2, NODE_A_QHD_NO_VTAG = 1 << 3,
  NODE_A_RX_INFLATE = 1 << 4, NODE_A_TX_DEFLATE = 1 << 5, NODE_A_ULTRA = 1 << 6, NODE_A_NO_ULTRA = 1 << 7,
  NODE_A_UP_QRP = 1 << 8, NODE_A_GUIDANCE = 1 << 9, NODE_A_TIME_SYNC = 1 << 10, NODE_A_CRAWLABLE = 1 << 11,
  NODE_A_DYN_QUERY = 1 << 12, NODE_A_CAN_SFLAG = 1 << 13, NODE_A_NO_KEPT_ZERO = 1 << 14, NODE_A_NO_DUPS = 1 << 15,
  NODE_A_CAN_HSEP = 1 << 16, NODE_A_CAN_QRP = 1 << 17, NODE_A_CAN_VENDOR = 1 << 18, NODE_A_CAN_ULTRA = 1 << 19,
  NODE_A_CAN_INFLATE = 1 << 20, NODE_A_CAN_HEAD = 1 << 21
}

Functions

void node_init (void)
 Network init.
void node_post_init (void)
 Post GUI initialization.
void node_slow_timer (time_t now)
 Low frequency node timer.
void node_timer (time_t now)
 Periodic node heartbeat timer.
guint connected_nodes (void)
guint node_count (void)
guint node_keep_missing (void)
 Amount of node connections we would like to keep.
guint node_missing (void)
 Amount of node connections we would like to have.
guint node_leaves_missing (void)
 Amount of leaves we're missing (0 if not in ultra mode).
guint node_outdegree (void)
gboolean node_is_connected (const host_addr_t addr, guint16 port, gboolean incoming)
 Is there a node connected with this IP/port?
gboolean node_host_is_connected (const host_addr_t addr, guint16 port)
 Are we directly connected to that host?
void node_add_socket (struct gnutella_socket *s, const host_addr_t addr, guint16 port, guint32 flags)
 Add new node, to which we possibly have an existing connection if the socket is not NULL (incoming connection).
void node_remove (struct gnutella_node *, const gchar *reason,...) G_GNUC_PRINTF(2
guint node_remove_by_addr (const host_addr_t addr, guint16 port)
 Determine if the node with specified IP and port is connected.
void node_bye (gnutella_node_t *, gint code, const gchar *reason,...) G_GNUC_PRINTF(3
void node_real_remove (gnutella_node_t *)
 Physically dispose of node.
void node_eof (struct gnutella_node *n, const gchar *reason,...) G_GNUC_PRINTF(2
void node_shutdown (struct gnutella_node *n, const gchar *reason,...) G_GNUC_PRINTF(2
void node_bye_if_writable (struct gnutella_node *n, gint code, const gchar *reason,...) G_GNUC_PRINTF(3
void node_init_outgoing (struct gnutella_node *)
 Called when asynchronous connection to an outgoing node is established.
void node_sent_ttl0 (struct gnutella_node *n)
 Called when a node sends a message with TTL=0.
void node_disableq (struct gnutella_node *n)
void node_enableq (struct gnutella_node *n)
void node_flushq (struct gnutella_node *n)
 Called by queue when it's not empty and it went through the service routine and yet has more data enqueued.
void node_unflushq (struct gnutella_node *n)
 Called by queue to disable the flush mode.
void node_tx_service (struct gnutella_node *n, gboolean on)
 Called when the queue service routine is switched ON/OFF.
void node_tx_enter_flowc (struct gnutella_node *n)
 Called by message queue when the node enters TX flow control.
void node_tx_leave_flowc (struct gnutella_node *n)
 Called by message queue when the node leaves TX flow control.
void node_tx_enter_warnzone (struct gnutella_node *n)
 Called by message queue when the node enters the warn zone.
void node_tx_leave_warnzone (struct gnutella_node *n)
 Called by message queue when the node leaves the warn zone.
void node_tx_swift_changed (struct gnutella_node *n)
 Called by message queue when swift mode changes.
void node_bye_all (void)
 Send a BYE message to all the nodes.
gboolean node_bye_pending (void)
void node_close (void)
 Final cleanup when application terminates.
gboolean node_remove_worst (gboolean non_local)
 Removes the node with the worst stats, considering the number of weird, bad and duplicate packets.
void node_qrt_changed (struct routing_table *query_table)
 Invoked for nodes when our Query Routing Table changed.
void node_qrt_discard (struct gnutella_node *n)
 Invoked when remote sends us a RESET message, making the existing routing table obsolete.
void node_qrt_install (struct gnutella_node *n, struct routing_table *)
 Invoked for ultra nodes to install new Query Routing Table.
void node_qrt_patched (struct gnutella_node *n, struct routing_table *)
 Invoked for ultra nodes when the Query Routing Table of remote node was fully patched (i.e.
void send_node_error (struct gnutella_socket *s, int code, const gchar *msg,...) G_GNUC_PRINTF(3
void node_add_sent (gnutella_node_t *n, gint x)
void node_add_txdrop (gnutella_node_t *n, gint x)
void node_add_rxdrop (gnutella_node_t *n, gint x)
void node_set_vendor (gnutella_node_t *n, const gchar *vendor)
 Record vendor name (user-agent string).
void node_set_hops_flow (gnutella_node_t *n, guint8 hops)
 Called when a vendor-specific "hops-flow" message was received to tell us to update the hops-flow counter for the connection: no query whose hop count is greater or equal to the specified `hops' should be sent to that node.
void node_set_online_mode (gboolean on)
 Whether they want to be "online" within Gnutella or not.
void node_current_peermode_changed (node_peer_t mode)
 Called from the property system when current peermode is changed.
const gchar * node_addr (const gnutella_node_t *n)
const gchar * node_addr2 (const gnutella_node_t *n)
const gchar * node_gnet_addr (const gnutella_node_t *n)
void node_connect_back (const gnutella_node_t *n, guint16 port)
 Connect back to node on specified port and emit a "\n\n" sequence.
void node_connected_back (struct gnutella_socket *s)
 Callback invoked from the socket layer when we are finally connected.
void node_mark_bad_vendor (struct gnutella_node *n)
 Gives a specific vendor a bad mark.
void node_proxying_remove (gnutella_node_t *n)
 Remove push proxy indication for the node, i.e.
gboolean node_proxying_add (gnutella_node_t *n, const gchar *guid)
 Record that node wants us to be his push proxy.
void node_proxy_add (gnutella_node_t *n, const host_addr_t addr, guint16 port)
 Add node to our list of push-proxies.
void node_proxy_cancel_all (void)
 Cancel all our known push-proxies.
size_t node_http_proxies_add (gchar *buf, size_t size, gpointer arg, guint32 flags)
 HTTP status callback.
const GSList * node_push_proxies (void)
const GSList * node_all_nodes (void)
const GSList * node_all_but_broken_gtkg (void)
gnutella_node_tnode_by_id (const node_id_t node_id)
gnutella_node_tnode_active_by_id (const node_id_t node_id)
void node_set_leaf_guidance (const node_id_t node_id, gboolean supported)
 Set leaf-guidance support indication from give node ID.
void node_became_firewalled (void)
 Called when we were not firewalled and suddenly become firewalled.
void node_became_udp_firewalled (void)
 Called when we were not firewalled and suddenly become UDP firewalled.
void node_set_socket_rx_size (gint rx_size)
 Change the socket RX buffer size for all the currently connected nodes.
mqueue_tnode_udp_get_outq (enum net_type net)
 Get the message queue attached to the UDP node.
void node_udp_disable (void)
void node_udp_process (struct gnutella_socket *s)
 Process incoming Gnutella datagram.
gnutella_node_tnode_udp_get_addr_port (const host_addr_t addr, guint16 port)
 Get "fake" node for UDP transmission.
void node_can_tsync (gnutella_node_t *n)
 Invoked when we determined that the node supports Time Sync.
void node_crawl (gnutella_node_t *n, gint ucnt, gint lcnt, guint8 features)
 Received an UDP crawler ping, requesting information about `ucnt' ultra nodes and `lcnt' leaves.
void node_update_udp_socket (void)
 This has to be called once the UDP socket (e.g., due to a changed port number) was changed because some internal references have to be updated.
void node_check_remote_ip_header (const host_addr_t peer, header_t *head)
 Checks for a Remote-IP or X-Remote-IP header and updates our IP address if the current IP address is not enforced.
guint feed_host_cache_from_headers (header_t *headers, host_type_t sender, gboolean gnet, const host_addr_t peer)
 Extract host:port information out of a header field and add those to our pong cache.
gnutella_node_tnode_browse_prepare (gnet_host_t *host, const gchar *vendor, gnutella_header_t *header, gchar *data, guint32 size)
 Let the "browse host" node hold the supplied Gnutella message as if coming from the host and from a servent with the supplied vendor string.
void node_browse_cleanup (gnutella_node_t *n)
 Cleanup the "browse host" node.
void node_kill_hostiles (void)
 Disconnects all connected nodes which are considered hostile.
node_id_t node_id_get_self (void)
gboolean node_id_self (const node_id_t node_id)
void node_check (const struct gnutella_node *const n)
const gchar * node_guid (const struct gnutella_node *const n)
gboolean node_set_guid (struct gnutella_node *n, const gchar *guid)
 Set the GUID of a connected node.
gnutella_nodenode_by_guid (const gchar *guid)

Variables

const gchar * start_rfc822_date
 RFC822 format of start_time.
GHookList node_added_hook_list
gnutella_nodenode_added
 For use by node_added_hook_list hooks, since we can't add a parameter at list invoke time.


Define Documentation

#define CACHE_HOP_IDX  )     (((h) > MAX_CACHE_HOPS) ? MAX_CACHE_HOPS : (h))
 

The macro returning the array index in the (0 ..

MAX_CACHE_HOPS) range, based on the hop count.

#define GNUTELLA_HELLO   "GNUTELLA CONNECT/"
 

#define GNUTELLA_HELLO_LENGTH   (sizeof(GNUTELLA_HELLO) - 1)
 

#define MAX_CACHE_HOPS   6
 

defines the maximum hop count we handle for the ping/pong caching scheme.

Any hop count greater than that is thresholded to that value.

#define node_add_rx_read n,
 )     do { (n)->rx_read += (x); } while (0)
 

#define node_add_tx_given n,
 )     do { (n)->tx_given += (x); } while (0)
 

#define NODE_CAN_INFLATE  )     ((n)->attrs & NODE_A_CAN_INFLATE)
 

#define NODE_CAN_SFLAG  )     ((n)->attrs & NODE_A_CAN_SFLAG)
 

#define NODE_CR_CONNECTION   0x01
 

Include connection times.

#define NODE_CR_CRAWLABLE   0x04
 

Include crawlable peers only.

#define NODE_CR_ESCAPE_CHAR   '\\'
 

#define NODE_CR_LOCALE   0x02
 

Include locale information.

#define NODE_CR_MASK   0x0f
 

Mask for supported features.

#define NODE_CR_SEPARATOR   ';'
 

#define NODE_CR_USER_AGENT   0x08
 

Include user-agent strings.

#define node_flowc_swift_grace  )     (NODE_IS_LEAF(n) ? 210 : 30)
 

The grace period between the time the node enters flow-control and the time we want to speed up things and drop traffic, entering "swift" mode.

For a leaf node, we allow more time before we start to aggressively drop traffic, but for a peer, we need to respond quickly, to avoid long clogging.

#define node_flowc_swift_period  )     (NODE_IS_LEAF(n) ? 140 : 20)
 

In "swift" mode, a callback is periodically invoked to drop more traffic if we don't see much progress in the queue backlog.

For a leaf node, it is invoked less often than for a peer.

#define NODE_ID  )     ((n)->id)
 

#define NODE_ID_SELF   (node_id_get_self())
 

#define NODE_IN_TX_FLOW_CONTROL  )     ((n)->outq && mq_is_flow_controlled((n)->outq))
 

#define NODE_IN_TX_SWIFT_CONTROL  )     ((n)->outq && mq_is_swift_controlled((n)->outq))
 

#define node_inc_qrp_match  )     do { (n)->qrp_matches++; } while (0)
 

#define node_inc_qrp_query  )     do { (n)->qrp_queries++; } while (0)
 

#define node_inc_rx_qhit  )     do { (n)->rx_qhits++; } while (0)
 

#define node_inc_rx_query  )     do { (n)->rx_queries++; } while (0)
 

#define node_inc_rxdrop  )     node_add_rxdrop(n, 1)
 

#define node_inc_sent  )     node_add_sent(n, 1)
 

#define node_inc_tx_qhit  )     do { (n)->tx_qhits++; } while (0)
 

#define node_inc_tx_query  )     do { (n)->tx_queries++; } while (0)
 

#define node_inc_txdrop  )     node_add_txdrop(n, 1)
 

#define NODE_IS_CONNECTED  ) 
 

Value:

(   (n)->status == GTA_NODE_CONNECTED           \
    ||  (n)->status == GTA_NODE_SHUTDOWN )

#define NODE_IS_CONNECTING  ) 
 

Value:

(   (n)->status == GTA_NODE_CONNECTING          \
    ||  (n)->status == GTA_NODE_HELLO_SENT          \
    ||  (n)->status == GTA_NODE_WELCOME_SENT        \
    ||  (n)->status == GTA_NODE_RECEIVING_HELLO )

#define NODE_IS_ESTABLISHED  ) 
 

Value:

(((n)->flags & (NODE_F_WRITABLE|NODE_F_ESTABLISHED)) == \
        (NODE_F_WRITABLE|NODE_F_ESTABLISHED))

#define NODE_IS_INCOMING  )     ((n)->flags & NODE_F_INCOMING)
 

#define NODE_IS_LEAF  )     ((n)->peermode == NODE_P_LEAF)
 

#define NODE_IS_NORMAL  )     ((n)->peermode == NODE_P_NORMAL)
 

#define NODE_IS_READABLE  )     (((n)->flags & (NODE_F_READABLE|NODE_F_NOREAD)) == NODE_F_READABLE)
 

#define NODE_IS_REMOVING  )     ((n)->status == GTA_NODE_REMOVING)
 

#define NODE_IS_UDP  )     ((n)->peermode == NODE_P_UDP)
 

#define NODE_IS_ULTRA  )     ((n)->peermode == NODE_P_ULTRA)
 

#define NODE_IS_WRITABLE  )     ((n)->flags & NODE_F_WRITABLE)
 

#define NODE_LEAF_GUIDE  )     ((n)->attrs & NODE_A_GUIDANCE)
 

#define NODE_LEAF_MIN_FLOW   3
 

The value of the hops-flow under which the leaf is not fully searcheable, and which will NOT have its QRP included in the inter-UP QRP table.

#define node_leaf_sent_qrp  ) 
 

Value:

(NODE_IS_LEAF(n) && \
    (n)->qrt_receive == NULL && (n)->recv_query_table != NULL)

#define NODE_MQUEUE_ABOVE_LOWAT  )     ((n)->outq ? mq_size((n)->outq) > mq_lowat((n)->outq) : FALSE)
 

#define NODE_MQUEUE_COUNT  )     ((n)->outq ? mq_count((n)->outq) : 0)
 

#define NODE_MQUEUE_PENDING  )     ((n)->outq ? mq_pending((n)->outq) : 0)
 

#define NODE_MQUEUE_PERCENT_USED  )     ((n)->outq ? mq_size((n)->outq) * 100 / mq_maxsize((n)->outq) : 0)
 

#define node_query_hops_ok n,
 )     ((h) < (n)->hops_flow)
 

Can we send query with hop count `h' according to node's hops-flow value?

#define NODE_RX_COMPRESSED  )     ((n)->attrs & NODE_A_RX_INFLATE)
 

#define NODE_RX_COMPRESSION_RATIO  ) 
 

Value:

((n)->rx_inflated ?                 \
        (double) ((n)->rx_inflated - (n)->rx_given) / (n)->rx_inflated : 0.0)

#define NODE_RX_FC_HALF_PERIOD   300
 

5 minutes

#define NODE_SQUEUE  )     ((n)->searchq)
 

#define NODE_SQUEUE_COUNT  )     ((n)->searchq ? sq_count((n)->searchq) : 0)
 

#define NODE_SQUEUE_SENT  )     ((n)->searchq ? sq_sent((n)->searchq) : 0)
 

#define NODE_TX_COMPRESSED  )     ((n)->attrs & NODE_A_TX_DEFLATE)
 

#define NODE_TX_COMPRESSION_RATIO  ) 
 

Value:

((n)->tx_given ?                    \
        (double) ((n)->tx_given - (n)->tx_deflated) / (n)->tx_given : 0.0)

#define node_type  )     (NODE_IS_LEAF(n) ? "leaf" : NODE_IS_ULTRA(n) ? "ultra" : "legacy")
 

#define node_ultra_received_qrp  ) 
 

Value:

(NODE_IS_ULTRA(n) && \
    (n)->qrt_update == NULL && (n)->sent_query_table != NULL)

#define NODE_UP_QRP  )     ((n)->attrs & NODE_A_UP_QRP)
 

#define node_vendor  )     ((n)->vendor != NULL ? (n)->vendor : "????")
 

#define PING_LEAF_THROTTLE   60
 

seconds, peer is leaf node

#define PING_REG_THROTTLE   3
 

seconds, regular peer


Typedef Documentation

typedef struct gnutella_node gnutella_node_t
 


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
NODE_F_HDSK_PING  Expecting handshake ping.
NODE_F_STALE_QRP  Is sending a stale QRP patch.
NODE_F_INCOMING  Incoming (permanent) connection.
NODE_F_ESTABLISHED  Gnutella connection established.
NODE_F_VALID  Handshaked with a Gnutella node.
NODE_F_ALIEN_IP  Pong-IP did not match TCP/IP addr.
NODE_F_WRITABLE  Node is writable.
NODE_F_READABLE  Node is readable, process queries.
NODE_F_BYE_SENT  Bye message was queued.
NODE_F_NODELAY  TCP_NODELAY was activated.
NODE_F_NOREAD  Prevent further reading from node.
NODE_F_EOF_WAIT  At final shutdown, waiting EOF.
NODE_F_CLOSING  Initiated bye or shutdown.
NODE_F_ULTRA  Is one of our ultra nodes.
NODE_F_LEAF  Is one of our leaves.
NODE_F_CRAWLER  Is a Gnutella Crawler.
NODE_F_FAKE_NAME  Was unable to validate GTKG name.
NODE_F_PROXY  Sent a push-proxy request to it.
NODE_F_PROXIED  We are push-proxy for that node.
NODE_F_QRP_SENT  Undergone 1 complete QRP sending.
NODE_F_TSYNC_WAIT  Time sync pending via TCP.
NODE_F_TSYNC_TCP  No replies via UDP, use TCP.
NODE_F_GTKG  Node is another gtk-gnutella.
NODE_F_FORCE  Connection is forced.
NODE_F_NO_OOB_PROXY  Do not OOB proxy the leaf.
NODE_F_TLS  TLS-tunneled.
NODE_F_CAN_TLS  Indicated support for TLS.

anonymous enum
 

Enumeration values:
NODE_A_BYE_PACKET  Supports Bye-Packet.
NODE_A_PONG_CACHING  Supports Pong-Caching.
NODE_A_PONG_ALIEN  Alien Pong-Caching scheme.
NODE_A_QHD_NO_VTAG  Servent has no vendor tag in QHD.
NODE_A_RX_INFLATE  Reading compressed data.
NODE_A_TX_DEFLATE  Sending compressed data.
NODE_A_ULTRA  Node wants to be an Ultrapeer.
NODE_A_NO_ULTRA  Node is NOT ultra capable.
NODE_A_UP_QRP  Supports intra-UP QRP.
NODE_A_GUIDANCE  Can leaf-guide dyn queries.
NODE_A_TIME_SYNC  Supports time sync.
NODE_A_CRAWLABLE  Node can be UDP-crawled.
NODE_A_DYN_QUERY  Node can perform dynamic queries.
NODE_A_CAN_SFLAG  Node supports flags in headers.
NODE_A_NO_KEPT_ZERO  For GTKG < 2006-08-15: no kept=0!
NODE_A_NO_DUPS  For broken old GTKG: no dups!
NODE_A_CAN_HSEP  Node supports HSEP.
NODE_A_CAN_QRP  Node supports query routing.
NODE_A_CAN_VENDOR  Node supports vendor messages.
NODE_A_CAN_ULTRA  Node is ultra capable.
NODE_A_CAN_INFLATE  Node capable of inflating.
NODE_A_CAN_HEAD  Supports HEAD ping (vendor message).

enum node_magic_t
 

Enumeration values:
NODE_MAGIC 


Function Documentation

guint connected_nodes void   ) 
 

guint feed_host_cache_from_headers header_t header,
host_type_t  sender,
gboolean  gnet,
const host_addr_t  peer
 

Extract host:port information out of a header field and add those to our pong cache.

If ``gnet'' is TRUE, the header names without a leading "X-" are checked as variants as well.

Parameters:
header a valid header_t.
sender the host_type_t of the sender, if unknown use HOST_ANY.
gnet should be set to TRUE if the headers come from a Gnutella handshake.
peer the peer address who sent the headers.
Returns:
the amount of valid peer addresses we parsed.
The syntax we expect is:

<header>: <peer> ("," <peer>)*

peer = <host> [":" <port>] [any except ","]* header = "Alt" | Listen-Ip" | "Listen-Ip" | "My-Address" | "Node" | "Try" | "Try-Ultrapeers"

gnutella_node_t* node_active_by_id const node_id_t  node_id  ) 
 

Returns:
writable node given its ID, or NULL if we can't reach that node.

void node_add_rxdrop gnutella_node_t n,
gint  x
 

void node_add_sent gnutella_node_t n,
gint  x
 

void node_add_socket struct gnutella_socket s,
const host_addr_t  addr,
guint16  port,
guint32  flags
 

Add new node, to which we possibly have an existing connection if the socket is not NULL (incoming connection).

void node_add_txdrop gnutella_node_t n,
gint  x
 

const gchar* node_addr const gnutella_node_t n  ) 
 

Returns:
the address:port of a node

const gchar* node_addr2 const gnutella_node_t n  ) 
 

Returns:
the address:port of a node

const GSList* node_all_but_broken_gtkg void   ) 
 

Returns:
list of all nodes without any broken GTKG (those nodes that must not be forwarded any duplicate message, even with a higher TTL than previously sent).

const GSList* node_all_nodes void   ) 
 

Returns:
list of all nodes.

void node_became_firewalled void   ) 
 

Called when we were not firewalled and suddenly become firewalled.

Send proxy requests to our current connections.

void node_became_udp_firewalled void   ) 
 

Called when we were not firewalled and suddenly become UDP firewalled.

Send UDP connect back requests to our current connections.

void node_browse_cleanup gnutella_node_t n  ) 
 

Cleanup the "browse host" node.

gnutella_node_t* node_browse_prepare gnet_host_t host,
const gchar *  vendor,
gnutella_header_t header,
gchar *  data,
guint32  size
 

Let the "browse host" node hold the supplied Gnutella message as if coming from the host and from a servent with the supplied vendor string.

Returns:
the shared instance, suitable for parsing the received message.

struct gnutella_node* node_by_guid const gchar *  guid  ) 
 

gnutella_node_t* node_by_id const node_id_t  node_id  ) 
 

Returns:
writable node given its ID, or NULL if we can't reach that node.

void node_bye gnutella_node_t ,
gint  code,
const gchar *  reason,
  ...
 

void node_bye_all void   ) 
 

Send a BYE message to all the nodes.

void node_bye_if_writable struct gnutella_node n,
gint  code,
const gchar *  reason,
  ...
 

gboolean node_bye_pending void   ) 
 

Returns:
true whilst there are some connections with a pending BYE.

void node_can_tsync gnutella_node_t n  ) 
 

Invoked when we determined that the node supports Time Sync.

void node_check const struct gnutella_node *const   n  )  [inline, static]
 

void node_check_remote_ip_header const host_addr_t  peer,
header_t head
 

Checks for a Remote-IP or X-Remote-IP header and updates our IP address if the current IP address is not enforced.

Note that settings_addr_changed() doesn't trust a single source.

Parameters:
peer the IPv4 address of the peer who sent the header
head a header_t holding headers sent by the peer

void node_close void   ) 
 

Final cleanup when application terminates.

void node_connect_back const gnutella_node_t n,
guint16  port
 

Connect back to node on specified port and emit a "\n\n" sequence.

This is called when a "Connect Back" vendor-specific message (BEAR/7v1) is received. This scheme is used by servents to detect whether they are firewalled.

void node_connected_back struct gnutella_socket s  ) 
 

Callback invoked from the socket layer when we are finally connected.

guint node_count void   ) 
 

void node_crawl gnutella_node_t n,
gint  ucnt,
gint  lcnt,
guint8  features
 

Received an UDP crawler ping, requesting information about `ucnt' ultra nodes and `lcnt' leaves.

Processing is further customized with some `features', a set of flags.

void node_current_peermode_changed node_peer_t  mode  ) 
 

Called from the property system when current peermode is changed.

void node_disableq struct gnutella_node n  ) 
 

void node_enableq struct gnutella_node n  ) 
 

void node_eof struct gnutella_node n,
const gchar *  reason,
  ...
 

void node_flushq struct gnutella_node n  ) 
 

Called by queue when it's not empty and it went through the service routine and yet has more data enqueued.

const gchar* node_gnet_addr const gnutella_node_t n  ) 
 

Returns:
the advertised Gnutella ip:port of a node if known, otherwise just the IP address..

const gchar* node_guid const struct gnutella_node *const   n  )  [inline, static]
 

gboolean node_host_is_connected const host_addr_t  addr,
guint16  port
 

Are we directly connected to that host?

size_t node_http_proxies_add gchar *  buf,
size_t  size,
gpointer  unused_arg,
guint32  unused_flags
 

HTTP status callback.

If we are still firewalled and have push-proxies, let the downloader know about them via the X-Push-Proxy header.

node_id_t node_id_get_self void   ) 
 

gboolean node_id_self const node_id_t  node_id  ) 
 

void node_init void   ) 
 

Network init.

void node_init_outgoing struct gnutella_node  ) 
 

Called when asynchronous connection to an outgoing node is established.

gboolean node_is_connected const host_addr_t  addr,
guint16  port,
gboolean  incoming
 

Is there a node connected with this IP/port?

The port is tested only when `incoming' is FALSE, i.e. we allow only one incoming connection per IP, even when there are several instances, all on different ports.

guint node_keep_missing void   ) 
 

Amount of node connections we would like to keep.

Returns:
0 if none.

void node_kill_hostiles void   ) 
 

Disconnects all connected nodes which are considered hostile.

This is mainly for disconnecting nodes after hostiles.txt has been reloaded.

guint node_leaves_missing void   ) 
 

Amount of leaves we're missing (0 if not in ultra mode).

void node_mark_bad_vendor struct gnutella_node n  ) 
 

Gives a specific vendor a bad mark.

If a vendor + version gets to many marks, we won't try to connect to it anymore.

guint node_missing void   ) 
 

Amount of node connections we would like to have.

Returns:
0 if none.

guint node_outdegree void   ) 
 

Returns:
this node's outdegree, i.e. the maximum amount of peer connections that we can support.

void node_post_init void   ) 
 

Post GUI initialization.

void node_proxy_add gnutella_node_t n,
const host_addr_t  addr,
guint16  port
 

Add node to our list of push-proxies.

void node_proxy_cancel_all void   ) 
 

Cancel all our known push-proxies.

gboolean node_proxying_add gnutella_node_t n,
const gchar *  guid
 

Record that node wants us to be his push proxy.

Returns:
TRUE if we can act as this node's proxy.

void node_proxying_remove gnutella_node_t n  ) 
 

Remove push proxy indication for the node, i.e.

we're no longer acting as its push-proxy from now on. If `discard' is true, get rid of the GUID and route information.

const GSList* node_push_proxies void   ) 
 

Returns:
list of our push-proxies.

void node_qrt_changed struct routing_table query_table  ) 
 

Invoked for nodes when our Query Routing Table changed.

void node_qrt_discard struct gnutella_node n  ) 
 

Invoked when remote sends us a RESET message, making the existing routing table obsolete.

void node_qrt_install struct gnutella_node n,
struct routing_table
 

Invoked for ultra nodes to install new Query Routing Table.

void node_qrt_patched struct gnutella_node n,
struct routing_table query_table
 

Invoked for ultra nodes when the Query Routing Table of remote node was fully patched (i.e.

we got a new generation).

void node_real_remove gnutella_node_t  ) 
 

Physically dispose of node.

void node_remove struct gnutella_node ,
const gchar *  reason,
  ...
 

guint node_remove_by_addr const host_addr_t  addr,
guint16  port
 

Determine if the node with specified IP and port is connected.

If so, schedule it to be removed.

Parameters:
addr The address of the node.
port A port number of zero means to match all connections to the host. Often the port is redundant [from a user perspective] as it is not often that two nodes will be at the same IP and connected to us.
Returns:
The number of nodes that have been removed.

gboolean node_remove_worst gboolean  non_local  ) 
 

Removes the node with the worst stats, considering the number of weird, bad and duplicate packets.

If `non_local' is TRUE, we're removing this node because it is not a local node, and we're having a connection from the local LAN. Otherwise, we're just removing a bad node (the BYE code is different).

void node_sent_ttl0 struct gnutella_node n  ) 
 

Called when a node sends a message with TTL=0.

Returns:
TRUE if node was removed (due to a duplicate bye, probably), FALSE otherwise.

gboolean node_set_guid struct gnutella_node n,
const gchar *  guid
 

Set the GUID of a connected node.

Returns:
TRUE if any error occured and the GUID was not set.

void node_set_hops_flow gnutella_node_t n,
guint8  hops
 

Called when a vendor-specific "hops-flow" message was received to tell us to update the hops-flow counter for the connection: no query whose hop count is greater or equal to the specified `hops' should be sent to that node.

void node_set_leaf_guidance const node_id_t  node_id,
gboolean  supported
 

Set leaf-guidance support indication from give node ID.

void node_set_online_mode gboolean  on  ) 
 

Whether they want to be "online" within Gnutella or not.

void node_set_socket_rx_size gint  rx_size  ) 
 

Change the socket RX buffer size for all the currently connected nodes.

void node_set_vendor gnutella_node_t n,
const gchar *  vendor
 

Record vendor name (user-agent string).

Parameters:
n The gnutella node.
vendor The payload of the User-Agent header; the assumed character encoding is ISO-8859-1.

void node_shutdown struct gnutella_node n,
const gchar *  reason,
  ...
 

void node_slow_timer time_t  now  ) 
 

Low frequency node timer.

Periodically emit an UHC ping to a random node to keep the cache fresh and diverse.

void node_timer time_t  now  ) 
 

Periodic node heartbeat timer.

void node_tx_enter_flowc struct gnutella_node n  ) 
 

Called by message queue when the node enters TX flow control.

void node_tx_enter_warnzone struct gnutella_node n  ) 
 

Called by message queue when the node enters the warn zone.

void node_tx_leave_flowc struct gnutella_node n  ) 
 

Called by message queue when the node leaves TX flow control.

void node_tx_leave_warnzone struct gnutella_node n  ) 
 

Called by message queue when the node leaves the warn zone.

void node_tx_service struct gnutella_node n,
gboolean  on
 

Called when the queue service routine is switched ON/OFF.

void node_tx_swift_changed struct gnutella_node n  ) 
 

Called by message queue when swift mode changes.

void node_udp_disable void   ) 
 

gnutella_node_t* node_udp_get_addr_port const host_addr_t  addr,
guint16  port
 

Get "fake" node for UDP transmission.

mqueue_t* node_udp_get_outq enum net_type  net  ) 
 

Get the message queue attached to the UDP node.

Returns:
the UDP message queue, or NULL if UDP has been disabled.

void node_udp_process struct gnutella_socket s  ) 
 

Process incoming Gnutella datagram.

void node_unflushq struct gnutella_node n  ) 
 

Called by queue to disable the flush mode.

void node_update_udp_socket void   ) 
 

This has to be called once the UDP socket (e.g., due to a changed port number) was changed because some internal references have to be updated.

void send_node_error struct gnutella_socket s,
int  code,
const gchar *  msg,
  ...
 


Variable Documentation

struct gnutella_node* node_added
 

For use by node_added_hook_list hooks, since we can't add a parameter at list invoke time.

GHookList node_added_hook_list
 

const gchar* start_rfc822_date
 

RFC822 format of start_time.


Generated on Sat Jun 30 17:53:29 2007 for gtk-gnutella by  doxygen 1.3.9.1