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

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 */
 5 minutes

#define MAX_CACHE_HOPS   6 /* We won't handle anything larger */
 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 PING_REG_THROTTLE   3 /**< seconds, regular peer */
 seconds, regular peer

#define PING_LEAF_THROTTLE   60 /**< seconds, peer is leaf node */
 seconds, peer is leaf node

#define NODE_F_HDSK_PING   0x00000001 /**< Expecting handshake ping */
 Expecting handshake ping.

#define NODE_F_STALE_QRP   0x00000002 /**< Is sending a stale QRP patch */
 Is sending a stale QRP patch.

#define NODE_F_INCOMING   0x00000004 /**< Incoming (permanent) connection */
 Incoming (permanent) connection.

#define NODE_F_ESTABLISHED   0x00000008 /**< Gnutella connection established */
 Gnutella connection established.

#define NODE_F_VALID   0x00000010 /**< Handshaked with a Gnutella node */
 Handshaked with a Gnutella node.

#define NODE_F_ALIEN_IP   0x00000020 /**< Pong-IP did not match TCP/IP addr */
 Pong-IP did not match TCP/IP addr.

#define NODE_F_WRITABLE   0x00000040 /**< Node is writable */
 Node is writable.

#define NODE_F_READABLE   0x00000080 /**< Node is readable, process queries */
 Node is readable, process queries.

#define NODE_F_BYE_SENT   0x00000100 /**< Bye message was queued */
 Bye message was queued.

#define NODE_F_NODELAY   0x00000200 /**< TCP_NODELAY was activated */
 TCP_NODELAY was activated.

#define NODE_F_NOREAD   0x00000400 /**< Prevent further reading from node */
 Prevent further reading from node.

#define NODE_F_EOF_WAIT   0x00000800 /**< At final shutdown, waiting EOF */
 At final shutdown, waiting EOF.

#define NODE_F_CLOSING   0x00001000 /**< Initiated bye or shutdown */
 Initiated bye or shutdown.

#define NODE_F_ULTRA   0x00002000 /**< Is one of our ultra nodes */
 Is one of our ultra nodes.

#define NODE_F_LEAF   0x00004000 /**< Is one of our leaves */
 Is one of our leaves.

#define NODE_F_CRAWLER   0x00008000 /**< Is a Gnutella Crawler */
 Is a Gnutella Crawler.

#define NODE_F_FAKE_NAME   0x00010000 /**< Was unable to validate GTKG name */
 Was unable to validate GTKG name.

#define NODE_F_PROXY   0x00020000 /**< Sent a push-proxy request to it */
 Sent a push-proxy request to it.

#define NODE_F_PROXIED   0x00040000 /**< We are push-proxy for that node */
 We are push-proxy for that node.

#define NODE_F_QRP_SENT   0x00080000 /**< Undergone 1 complete QRP sending */
 Undergone 1 complete QRP sending.

#define NODE_F_TLS   0x00100000 /**< TLS-tunneled */
 TLS-tunneled.

#define NODE_F_TSYNC_WAIT   0x00200000 /**< Time sync pending via TCP */
 Time sync pending via TCP.

#define NODE_F_TSYNC_TCP   0x00400000 /**< No replies via UDP, use TCP */
 No replies via UDP, use TCP.

#define NODE_F_GTKG   0x00800000 /**< Node is another gtk-gnutella */
 Node is another gtk-gnutella.

#define NODE_F_FORCE   0x01000000 /**< Connection is forced */
 Connection is forced.

#define NODE_A_BYE_PACKET   0x00000001 /**< Supports Bye-Packet */
 Supports Bye-Packet.

#define NODE_A_PONG_CACHING   0x00000002 /**< Supports Pong-Caching */
 Supports Pong-Caching.

#define NODE_A_PONG_ALIEN   0x00000004 /**< Alien Pong-Caching scheme */
 Alien Pong-Caching scheme.

#define NODE_A_QHD_NO_VTAG   0x00000008 /**< Servent has no vendor tag in QHD */
 Servent has no vendor tag in QHD.

#define NODE_A_RX_INFLATE   0x00000010 /**< Reading compressed data */
 Reading compressed data.

#define NODE_A_TX_DEFLATE   0x00000020 /**< Sending compressed data */
 Sending compressed data.

#define NODE_A_ULTRA   0x00000040 /**< Node wants to be an Ultrapeer */
 Node wants to be an Ultrapeer.

#define NODE_A_NO_ULTRA   0x00000080 /**< Node is NOT ultra capable */
 Node is NOT ultra capable.

#define NODE_A_UP_QRP   0x00000100 /**< Supports intra-UP QRP */
 Supports intra-UP QRP.

#define NODE_A_LEAF_GUIDE   0x00000200 /**< Supports leaf-guided dyn queries */
 Supports leaf-guided dyn queries.

#define NODE_A_TIME_SYNC   0x00000400 /**< Supports time sync */
 Supports time sync.

#define NODE_A_CRAWLABLE   0x00000800 /**< Node can be UDP-crawled */
 Node can be UDP-crawled.

#define NODE_A_DYN_QUERY   0x00001000 /**< Node can perform dynamic queries */
 Node can perform dynamic queries.

#define NODE_A_NO_DUPS   0x02000000 /**< For broken old GTKG: no dups! */
 For broken old GTKG: no dups!

#define NODE_A_CAN_HSEP   0x04000000 /**< Node supports HSEP */
 Node supports HSEP.

#define NODE_A_CAN_QRP   0x08000000 /**< Node supports query routing */
 Node supports query routing.

#define NODE_A_CAN_VENDOR   0x10000000 /**< Node supports vendor messages */
 Node supports vendor messages.

#define NODE_A_CAN_GGEP   0x20000000 /**< Node supports big pongs, etc.. */
 Node supports big pongs, etc.

#define NODE_A_CAN_ULTRA   0x40000000 /**< Node is ultra capable */
 Node is ultra capable.

#define NODE_A_CAN_INFLATE   0x80000000 /**< Node capable of inflating */
 Node capable of inflating.

#define NODE_CR_CONNECTION   0x01 /**< Include connection times */
 Include connection times.

#define NODE_CR_LOCALE   0x02 /**< Include locale information */
 Include locale information.

#define NODE_CR_CRAWLABLE   0x04 /**< Include crawlable peers only */
 Include crawlable peers only.

#define NODE_CR_USER_AGENT   0x08 /**< Include user-agent strings */
 Include user-agent strings.

#define NODE_CR_MASK   0x0f /**< Mask for supported features */
 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_GGEP(n)   ((n)->attrs & NODE_A_CAN_GGEP)
#define NODE_UP_QRP(n)   ((n)->attrs & NODE_A_UP_QRP)
#define NODE_GUIDES_QUERY(n)   ((n)->attrs & NODE_A_LEAF_GUIDE)
#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)
#define NODE_ID_LOCAL   0x0U /**< ID for "local node" (ourselves) */
 ID for "local node" (ourselves).


Typedefs

typedef enum node_protocol_types node_protocol_types_t
typedef gnutella_node gnutella_node_t

Enumerations

enum  node_protocol_types { PROTOCOL_TYPE_GNUTELLA = 0, PROTOCOL_TYPE_G2 }
enum  node_magic_t { NODE_MAGIC = 0x67f8e02f }

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
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 (gpointer 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, gpointer query_table)
 Invoked for ultra nodes to install new Query Routing Table.

void node_qrt_patched (struct gnutella_node *n, gpointer query_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_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, gboolean discard)
 Remove push proxy indication for the node, i.e.

gboolean node_proxying_add (gnutella_node_t *n, 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.

void node_http_proxies_add (gchar *buf, gint *retval, gpointer arg, guint32 flags)
 HTTP status callback.

GSList * node_push_proxies (void)
const GSList * node_all_nodes (void)
const GSList * node_all_but_broken_gtkg (void)
gnutella_node_tnode_active_by_id (guint32 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 (void)
 Get the message queue attached to the UDP node.

void node_udp_enable (void)
 Enable UDP transmission via pseudo node.

void node_udp_disable (void)
 Disable UDP transmission via pseudo node.

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, struct gnutella_header *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.


Variables

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 /* We won't handle anything larger */
 

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_A_BYE_PACKET   0x00000001 /**< Supports Bye-Packet */
 

Supports Bye-Packet.

#define NODE_A_CAN_GGEP   0x20000000 /**< Node supports big pongs, etc.. */
 

Node supports big pongs, etc.

#define NODE_A_CAN_HSEP   0x04000000 /**< Node supports HSEP */
 

Node supports HSEP.

#define NODE_A_CAN_INFLATE   0x80000000 /**< Node capable of inflating */
 

Node capable of inflating.

#define NODE_A_CAN_QRP   0x08000000 /**< Node supports query routing */
 

Node supports query routing.

#define NODE_A_CAN_ULTRA   0x40000000 /**< Node is ultra capable */
 

Node is ultra capable.

#define NODE_A_CAN_VENDOR   0x10000000 /**< Node supports vendor messages */
 

Node supports vendor messages.

#define NODE_A_CRAWLABLE   0x00000800 /**< Node can be UDP-crawled */
 

Node can be UDP-crawled.

#define NODE_A_DYN_QUERY   0x00001000 /**< Node can perform dynamic queries */
 

Node can perform dynamic queries.

#define NODE_A_LEAF_GUIDE   0x00000200 /**< Supports leaf-guided dyn queries */
 

Supports leaf-guided dyn queries.

#define NODE_A_NO_DUPS   0x02000000 /**< For broken old GTKG: no dups! */
 

For broken old GTKG: no dups!

#define NODE_A_NO_ULTRA   0x00000080 /**< Node is NOT ultra capable */
 

Node is NOT ultra capable.

#define NODE_A_PONG_ALIEN   0x00000004 /**< Alien Pong-Caching scheme */
 

Alien Pong-Caching scheme.

#define NODE_A_PONG_CACHING   0x00000002 /**< Supports Pong-Caching */
 

Supports Pong-Caching.

#define NODE_A_QHD_NO_VTAG   0x00000008 /**< Servent has no vendor tag in QHD */
 

Servent has no vendor tag in QHD.

#define NODE_A_RX_INFLATE   0x00000010 /**< Reading compressed data */
 

Reading compressed data.

#define NODE_A_TIME_SYNC   0x00000400 /**< Supports time sync */
 

Supports time sync.

#define NODE_A_TX_DEFLATE   0x00000020 /**< Sending compressed data */
 

Sending compressed data.

#define NODE_A_ULTRA   0x00000040 /**< Node wants to be an Ultrapeer */
 

Node wants to be an Ultrapeer.

#define NODE_A_UP_QRP   0x00000100 /**< Supports intra-UP QRP */
 

Supports intra-UP QRP.

#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_GGEP  )     ((n)->attrs & NODE_A_CAN_GGEP)
 

#define NODE_CR_CONNECTION   0x01 /**< Include connection times */
 

Include connection times.

#define NODE_CR_CRAWLABLE   0x04 /**< Include crawlable peers only */
 

Include crawlable peers only.

#define NODE_CR_ESCAPE_CHAR   '\\'
 

#define NODE_CR_LOCALE   0x02 /**< Include locale information */
 

Include locale information.

#define NODE_CR_MASK   0x0f /**< Mask for supported features */
 

Mask for supported features.

#define NODE_CR_SEPARATOR   ';'
 

#define NODE_CR_USER_AGENT   0x08 /**< Include user-agent strings */
 

Include user-agent strings.

#define NODE_F_ALIEN_IP   0x00000020 /**< Pong-IP did not match TCP/IP addr */
 

Pong-IP did not match TCP/IP addr.

#define NODE_F_BYE_SENT   0x00000100 /**< Bye message was queued */
 

Bye message was queued.

#define NODE_F_CLOSING   0x00001000 /**< Initiated bye or shutdown */
 

Initiated bye or shutdown.

#define NODE_F_CRAWLER   0x00008000 /**< Is a Gnutella Crawler */
 

Is a Gnutella Crawler.

#define NODE_F_EOF_WAIT   0x00000800 /**< At final shutdown, waiting EOF */
 

At final shutdown, waiting EOF.

#define NODE_F_ESTABLISHED   0x00000008 /**< Gnutella connection established */
 

Gnutella connection established.

#define NODE_F_FAKE_NAME   0x00010000 /**< Was unable to validate GTKG name */
 

Was unable to validate GTKG name.

#define NODE_F_FORCE   0x01000000 /**< Connection is forced */
 

Connection is forced.

#define NODE_F_GTKG   0x00800000 /**< Node is another gtk-gnutella */
 

Node is another gtk-gnutella.

#define NODE_F_HDSK_PING   0x00000001 /**< Expecting handshake ping */
 

Expecting handshake ping.

#define NODE_F_INCOMING   0x00000004 /**< Incoming (permanent) connection */
 

Incoming (permanent) connection.

#define NODE_F_LEAF   0x00004000 /**< Is one of our leaves */
 

Is one of our leaves.

#define NODE_F_NODELAY   0x00000200 /**< TCP_NODELAY was activated */
 

TCP_NODELAY was activated.

#define NODE_F_NOREAD   0x00000400 /**< Prevent further reading from node */
 

Prevent further reading from node.

#define NODE_F_PROXIED   0x00040000 /**< We are push-proxy for that node */
 

We are push-proxy for that node.

#define NODE_F_PROXY   0x00020000 /**< Sent a push-proxy request to it */
 

Sent a push-proxy request to it.

#define NODE_F_QRP_SENT   0x00080000 /**< Undergone 1 complete QRP sending */
 

Undergone 1 complete QRP sending.

#define NODE_F_READABLE   0x00000080 /**< Node is readable, process queries */
 

Node is readable, process queries.

#define NODE_F_STALE_QRP   0x00000002 /**< Is sending a stale QRP patch */
 

Is sending a stale QRP patch.

#define NODE_F_TLS   0x00100000 /**< TLS-tunneled */
 

TLS-tunneled.

#define NODE_F_TSYNC_TCP   0x00400000 /**< No replies via UDP, use TCP */
 

No replies via UDP, use TCP.

#define NODE_F_TSYNC_WAIT   0x00200000 /**< Time sync pending via TCP */
 

Time sync pending via TCP.

#define NODE_F_ULTRA   0x00002000 /**< Is one of our ultra nodes */
 

Is one of our ultra nodes.

#define NODE_F_VALID   0x00000010 /**< Handshaked with a Gnutella node */
 

Handshaked with a Gnutella node.

#define NODE_F_WRITABLE   0x00000040 /**< Node is writable */
 

Node is writable.

#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_GUIDES_QUERY  )     ((n)->attrs & NODE_A_LEAF_GUIDE)
 

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

#define NODE_ID_LOCAL   0x0U /**< ID for "local node" (ourselves) */
 

ID for "local node" (ourselves).

#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:

#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_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 */
 

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 */
 

seconds, peer is leaf node

#define PING_REG_THROTTLE   3 /**< seconds, regular peer */
 

seconds, regular peer


Typedef Documentation

typedef struct gnutella_node gnutella_node_t
 

typedef enum node_protocol_types node_protocol_types_t
 


Enumeration Type Documentation

enum node_magic_t
 

Enumeration values:
NODE_MAGIC 

enum node_protocol_types
 

Enumeration values:
PROTOCOL_TYPE_GNUTELLA 
PROTOCOL_TYPE_G2 


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:

: ("," )*

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

gnutella_node_t* node_active_by_id guint32  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
[inline]
 

void node_add_sent gnutella_node_t n,
gint  x
[inline]
 

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
[inline]
 

const gchar* node_addr 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,
struct gnutella_header 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.

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_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

gboolean node_host_is_connected const host_addr_t  addr,
guint16  port
 

Are we directly connected to that host?

void node_http_proxies_add gchar *  buf,
gint *  retval,
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.

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.

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,
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,
gboolean  discard
 

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.

GSList* node_push_proxies void   ) 
 

Returns:
list of our push-proxies.

void node_qrt_changed gpointer  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,
gpointer  query_table
 

Invoked for ultra nodes to install new Query Routing Table.

void node_qrt_patched struct gnutella_node n,
gpointer  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,
... 
 

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.

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_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.

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   ) 
 

Disable UDP transmission via pseudo node.

void node_udp_enable void   ) 
 

Enable UDP transmission via pseudo node.

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 void   ) 
 

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
 

gchar* start_rfc822_date
 

RFC822 format of start_time.


Generated on Sun Feb 12 10:50:05 2006 for Gtk-Gnutella by doxygen 1.3.6