#include "common.h"
#include "gmsg.h"
#include "pmsg.h"
#include "nodes.h"
#include "sq.h"
#include "mq.h"
#include "routing.h"
#include "vmsg.h"
#include "search.h"
#include "if/gnet_property_priv.h"
#include "lib/endian.h"
#include "lib/glib-missing.h"
#include "lib/override.h"
Functions | |
RCSID ("$Id:gmsg.c, v 1.22 2005/12/17 09:25:44 daichik Exp $") | |
void | gmsg_header_check (const struct gnutella_header *h, guint32 size) |
Ensure that the gnutella message header has the correct size, a TTL greater than zero and that size is at least 23 (GTA_HEADER_SIZE). | |
void | gmsg_dump (FILE *out, gconstpointer data, guint32 size) |
Log an hexadecimal dump of the message `data'. | |
void | gmsg_split_dump (FILE *out, gconstpointer head, gconstpointer data, guint32 size) |
Same as gmsg_dump(), but the header and the PDU data are separated. | |
void | gmsg_init (void) |
Initialization of the Gnutella message structures. | |
const gchar * | gmsg_name (guint function) |
Convert message function number into name. | |
pmsg_t * | gmsg_to_pmsg (gconstpointer msg, guint32 size) |
Construct regular PDU descriptor from message. | |
pmsg_t * | gmsg_to_ctrl_pmsg (gconstpointer msg, guint32 size) |
Construct control PDU descriptor from message. | |
pmsg_t * | gmsg_to_ctrl_pmsg_extend (gconstpointer msg, guint32 size, pmsg_free_t free_cb, gpointer arg) |
Construct extended control PDU (with free routine) from message. | |
void | write_message (pmsg_t *mb, gconstpointer head, gconstpointer data, guint32 size) |
Write message data into new empty message buffer. | |
pmsg_t * | gmsg_split_to_pmsg (gconstpointer head, gconstpointer data, guint32 size) |
Construct PDU from header and data. | |
pmsg_t * | gmsg_split_to_pmsg_extend (gconstpointer head, gconstpointer data, guint32 size, pmsg_free_t free_cb, gpointer arg) |
Construct extended PDU (with free routine) from header and data. | |
void | gmsg_mb_sendto_all (const GSList *sl, pmsg_t *mb) |
Broadcast message to all nodes in the list. | |
void | gmsg_mb_sendto_one (struct gnutella_node *n, pmsg_t *mb) |
Send message to one node. | |
void | gmsg_sendto_one (struct gnutella_node *n, gconstpointer msg, guint32 size) |
Send message to one node. | |
void | gmsg_sendto_one_ggep (struct gnutella_node *n, gconstpointer msg, guint32 size, guint32 regular_size) |
Send message to one node, stripping the GGEP part if the node cannot grok GGEP extensions. | |
void | gmsg_ctrl_sendto_one (struct gnutella_node *n, gconstpointer msg, guint32 size) |
Send control message to one node. | |
void | gmsg_ctrl_sendto_one_ggep (struct gnutella_node *n, gconstpointer msg, guint32 size, guint32 regular_size) |
Send control message to one node. | |
void | gmsg_search_sendto_one (struct gnutella_node *n, gnet_search_t sh, gconstpointer msg, guint32 size) |
Send our search message to one node. | |
void | gmsg_split_sendto_one (struct gnutella_node *n, gconstpointer head, gconstpointer data, guint32 size) |
Send message consisting of header and data to one node. | |
void | gmsg_sendto_all (const GSList *sl, gconstpointer msg, guint32 size) |
Broadcast message to all nodes in the list. | |
void | gmsg_sendto_all_ggep (const GSList *sl, gconstpointer msg, guint32 size, guint32 regular_size) |
Broadcast message to all nodes in the list, sending only a stripped down version without the trailing GGEP extension to nodes not advertising GGEP support. | |
void | gmsg_search_sendto_all (const GSList *sl, gnet_search_t sh, gconstpointer msg, guint32 size) |
Broadcast our search message to all nodes in the list. | |
void | gmsg_split_sendto_all_but_one (const GSList *sl, const struct gnutella_node *n, gconstpointer head, gconstpointer data, guint32 size) |
Send message consisting of header and data to all nodes in the list but one node. | |
void | gmsg_split_sendto_all (const GSList *sl, gconstpointer head, gconstpointer data, guint32 size) |
Send message consisting of header and data to all the nodes in the list. | |
void | gmsg_split_sendto_all_but_one_ggep (const GSList *sl, const struct gnutella_node *n, gconstpointer head, gconstpointer data, guint32 size, guint32 regular_size) |
Same as gmsg_split_sendto_all_but_one(), but the message must not be forwarded as-is to nodes not supporting GGEP: it must be truncated to its `regular_size' size first. | |
void | gmsg_sendto_route (struct gnutella_node *n, struct route_dest *rt) |
Send message held in current node according to route specification. | |
void | sendto_ggep (struct gnutella_node *n, struct gnutella_node *dn, guint32 regular_size) |
Send message from `n' to destination node `dn'. | |
void | gmsg_sendto_route_ggep (struct gnutella_node *n, struct route_dest *rt, guint32 regular_size) |
Same as gmsg_sendto_route() but if the node did not claim support of GGEP extensions in pings, pongs and pushes, strip the GGEP payload before forwarding the message. | |
gboolean | gmsg_query_can_send (pmsg_t *mb, const mqueue_t *q) |
Test whether a query can be sent. | |
void | gmsg_install_presend (pmsg_t *mb) |
Install "pre-send" callback for certain types of messages. | |
gboolean | gmsg_can_drop (gconstpointer pdu, gint size) |
Test whether the Gnutella message can be safely dropped on the connection. | |
gint | gmsg_cmp (gconstpointer pdu1, gconstpointer pdu2) |
Perform a priority comparison between two messages, given as the whole PDU. | |
gchar * | gmsg_infostr_full (gconstpointer message) |
gchar * | gmsg_infostr_full_split (gconstpointer head, gconstpointer data) |
gchar * | gmsg_infostr (gconstpointer head) |
gchar * | gmsg_infostr2 (gconstpointer head) |
Same as gmsg_infostr(), but different static buffer. | |
void | gmsg_log_dropped (gconstpointer head, const gchar *reason,...) |
Log dropped message, and reason. | |
void | gmsg_log_bad (const struct gnutella_node *n, const gchar *reason,...) |
Log bad message, the node's vendor, and reason. | |
gboolean | gmsg_is_oob_query (gconstpointer msg) |
Check whether query message starting at `msg' is flagged for OOB hit delivery. | |
gboolean | gmsg_split_is_oob_query (gconstpointer head, gconstpointer data) |
Check whether query message split between header and data is flagged for OOB hit delivery. | |
Variables | |
const gchar * | msg_name [256] |
guint8 | msg_weight [256] |
For gmsg_cmp(). |
|
Test whether the Gnutella message can be safely dropped on the connection. We're given the whole PDU, not just the payload. Dropping of messages only happens when the connection is flow-controlled, and there's not enough room in the queue. |
|
Perform a priority comparison between two messages, given as the whole PDU.
|
|
Send control message to one node. A control message is inserted ahead any other queued regular data. |
|
Send control message to one node. A control message is inserted ahead any other queued regular data. |
|
Log an hexadecimal dump of the message `data'. Tagged with: msg_type (payload length) [hops=x, TTL=x] to the specified file descriptor. |
|
Ensure that the gnutella message header has the correct size, a TTL greater than zero and that size is at least 23 (GTA_HEADER_SIZE).
|
|
|
|
Same as gmsg_infostr(), but different static buffer.
|
|
that can also decompile vendor messages given a pointer on the whole message that contains the leading header immediately followed by the payload of that message. |
|
that can also decompile vendor messages given a pointer on the header and on the data of the message (which may not be consecutive in memory). |
|
Initialization of the Gnutella message structures.
|
|
Install "pre-send" callback for certain types of messages.
|
|
Check whether query message starting at `msg' is flagged for OOB hit delivery.
|
|
Log bad message, the node's vendor, and reason.
|
|
Log dropped message, and reason.
|
|
Broadcast message to all nodes in the list. The supplied mb is cloned for each node to which it is sent. It is up to the caller to free that mb, if needed, upon return. |
|
Send message to one node. The supplied mb is NOT cloned, it is up to the caller to ensure that a private instance is supplied. |
|
Convert message function number into name.
|
|
Test whether a query can be sent. We look at the hops-flow, and whether there is a route for the query hits if it is a non-OOB query: no need to forward the request if the reply will be dropped.
|
|
Broadcast our search message to all nodes in the list.
|
|
Send our search message to one node.
|
|
Broadcast message to all nodes in the list.
|
|
Broadcast message to all nodes in the list, sending only a stripped down version without the trailing GGEP extension to nodes not advertising GGEP support.
|
|
Send message to one node.
|
|
Send message to one node, stripping the GGEP part if the node cannot grok GGEP extensions.
|
|
Send message held in current node according to route specification.
|
|
Same as gmsg_sendto_route() but if the node did not claim support of GGEP extensions in pings, pongs and pushes, strip the GGEP payload before forwarding the message.
|
|
Same as gmsg_dump(), but the header and the PDU data are separated.
|
|
Check whether query message split between header and data is flagged for OOB hit delivery.
|
|
Send message consisting of header and data to all the nodes in the list.
|
|
Send message consisting of header and data to all nodes in the list but one node. We never broadcast anything to a leaf node. Those are handled specially. |
|
Same as gmsg_split_sendto_all_but_one(), but the message must not be forwarded as-is to nodes not supporting GGEP: it must be truncated to its `regular_size' size first. We never broadcast anything to a leaf node. Those are handled specially. In UP mode, we never broadcast queries with TTL=1 to ultra nodes that support the last-hop QRP.
|
|
Send message consisting of header and data to one node.
|
|
Construct PDU from header and data.
|
|
Construct extended PDU (with free routine) from header and data.
|
|
Construct control PDU descriptor from message.
|
|
Construct extended control PDU (with free routine) from message.
|
|
Construct regular PDU descriptor from message. Message data is copied into the new data buffer, so caller may release its memory. |
|
|
|
Send message from `n' to destination node `dn'. If target node cannot understand extra GGEP payloads, trim message before sending.
|
|
Write message data into new empty message buffer.
|
|
|
|
For gmsg_cmp().
|