#include "common.h"
#include "vmsg.h"
#include "nodes.h"
#include "search.h"
#include "gmsg.h"
#include "routing.h"
#include "gnet_stats.h"
#include "dq.h"
#include "udp.h"
#include "settings.h"
#include "guid.h"
#include "inet.h"
#include "oob.h"
#include "mq.h"
#include "mq_udp.h"
#include "clock.h"
#include "tsync.h"
#include "hosts.h"
#include "pmsg.h"
#include "if/gnet_property_priv.h"
#include "lib/endian.h"
#include "lib/glib-missing.h"
#include "lib/tm.h"
#include "lib/vendors.h"
#include "lib/override.h"
Data Structures | |
struct | vmsg |
Definition of vendor messages. More... | |
struct | vms_item |
Items in the "Messages Supported" vector. More... | |
struct | vms_feature |
Items in the "Features Supported" vector. More... | |
Defines | |
#define | VMS_ITEM_SIZE 8 /**< Each entry is 8 bytes (4+2+2) */ |
Each entry is 8 bytes (4+2+2). | |
#define | VMS_FEATURE_SIZE 6 /**< Each entry is 6 bytes (4+2) */ |
Each entry is 6 bytes (4+2). | |
#define | PAIR_CMP(x, y, a0, a1, b0, b1) |
#define | GET_KEY(i) (&vmsg_map[(i)]) |
#define | FOUND(i) |
#define | COMPARE(item, key) |
#define | COMPARE(it, o) |
Typedefs | |
typedef void(* | vmsg_handler_t )(struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Functions | |
RCSID ("$Id:vmsg.c, v 1.52 2005/11/12 12:04:34 cbiere Exp $") | |
void | handle_messages_supported (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle the "Messages Supported" message. | |
void | handle_features_supported (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle the "Features Supported" message. | |
void | handle_hops_flow (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle the "Hops Flow" message. | |
void | handle_tcp_connect_back (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle the "TCP Connect Back" message. | |
void | handle_udp_connect_back (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle the \"UDP Connect Back" message. | |
void | handle_proxy_req (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle reception of the "Push Proxy Request" message. | |
void | handle_proxy_ack (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle reception of the "Push Proxy Acknowledgment" message. | |
void | handle_qstat_req (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle reception of "Query Status Request", where the UP requests how many results the search filters of the leave (ourselves) let pass through. | |
void | handle_qstat_answer (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle "Query Status Response" where the leave notifies us about the amount of results its search filters let pass through for the specified query. | |
void | handle_proxy_cancel (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle reception of "Push Proxy Cancel" request, when remote node no longer wishes to have us as a push-proxy. | |
void | handle_oob_reply_ind (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle reception of an "OOB Reply Indication" message, whereby the remote host informs us about the amount of query hits it has for us for a given query. | |
void | handle_oob_reply_ack (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle reception of an "OOB Reply Ack" message, whereby the remote host informs us about the amount of query hits it wants delivered for the query identified by the MUID of the message. | |
void | handle_time_sync_req (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle reception of a "Time Sync Request" message, indicating a request from another host about time synchronization. | |
void | handle_time_sync_reply (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle reception of a "Time Sync Reply" message, holding the reply from a previous time synchronization request. | |
void | handle_udp_crawler_ping (struct gnutella_node *n, const struct vmsg *vmsg, gchar *payload, gint size) |
Handle reception of an UDP crawler ping. | |
const struct vmsg * | find_message (union vendor_code vc, guint16 id, guint16 version) |
Find message, given vendor code, and id, version. | |
const gchar * | vmsg_infostr (gconstpointer data, gint size) |
Decompiles vendor-message name given the data payload of the Gnutella message and its size. | |
void | vmsg_handle (struct gnutella_node *n) |
Main entry point to handle reception of vendor-specific message. | |
guint32 | vmsg_fill_header (struct gnutella_header *header, guint32 size, guint32 maxsize) |
Fill common message header part for all vendor-specific messages. | |
gchar * | vmsg_fill_type (struct gnutella_vendor *base, guint32 vendor, guint16 id, guint16 version) |
Fill leading part of the payload data, containing the common part for all vendor-specific messages. | |
void | vmsg_bad_payload (struct gnutella_node *n, const struct vmsg *vmsg, gint size, gint expected) |
Report a vendor-message with bad payload to the stats. | |
void | vmsg_send_messages_supported (struct gnutella_node *n) |
Send a "Messages Supported" message to specified node, telling it which subset of the vendor messages we can understand. | |
void | vmsg_send_hops_flow (struct gnutella_node *n, guint8 hops) |
Send an "Hops Flow" message to specified node. | |
void | vmsg_send_tcp_connect_back (struct gnutella_node *n, guint16 port) |
Send a "TCP Connect Back" message to specified node, telling it to connect back to us on the specified port. | |
void | vmsg_send_udp_connect_back (struct gnutella_node *n, guint16 port) |
Send a "UDP Connect Back" message to specified node, telling it to ping us back via UDP on the specified port. | |
void | vmsg_send_proxy_ack (struct gnutella_node *n, gchar *muid, gint version) |
Send a "Push Proxy Acknowledgment" message to specified node, using supplied `muid' as the message ID (which is the target node's GUID). | |
void | vmsg_send_proxy_req (struct gnutella_node *n, const gchar *muid) |
Send a "Push Proxy Request" message to specified node, using supplied `muid' as the message ID (which is our GUID). | |
void | vmsg_send_qstat_req (struct gnutella_node *n, gchar *muid) |
Send a "Query Status Request" message to specified node, using supplied `muid' as the message ID (which is the query ID). | |
void | vmsg_send_qstat_answer (struct gnutella_node *n, gchar *muid, guint16 hits) |
Send a "Query Status Response" message to specified node. | |
void | vmsg_send_proxy_cancel (struct gnutella_node *n) |
Send a "Push Proxy Cancel" message to specified node. | |
pmsg_t * | vmsg_build_oob_reply_ind (gchar *muid, guint8 hits) |
Build an "OOB Reply Indication" message. | |
void | vmsg_send_oob_reply_ack (struct gnutella_node *n, gchar *muid, guint8 want) |
Send an "OOB Reply Ack" message to specified node, informing it that we want the specified amount of hits delivered for the query identified by the MUID of the message we got (the "OOB Reply Indication"). | |
gboolean | vmsg_time_sync_req_stamp (pmsg_t *mb, const struct mqueue *unused_q) |
Callback invoked when "Time Sync Request" is about to be sent. | |
void | vmsg_send_time_sync_req (struct gnutella_node *n, gboolean ntp, tm_t *sent) |
Send a "Time Sync Request" message, asking them to echo back their own time so that we can compute our clock differences and measure round trip times. | |
gboolean | vmsg_time_sync_reply_stamp (pmsg_t *mb, const struct mqueue *unused_q) |
Callback invoked when "Time Sync Reply" is about to be sent. | |
void | vmsg_send_time_sync_reply (struct gnutella_node *n, gboolean ntp, tm_t *got) |
Send a "Time Sync Reply" message to the node, including the time at which we send back the message in the second half of the MUID. | |
void | vmsg_send_udp_crawler_pong (struct gnutella_node *n, pmsg_t *mb) |
Send UDP crawler pong, in reply to their ping. | |
void | vmsg_map_is_sorted (void) |
Assert that the vmsg_map[] array is sorted. | |
void | vmsg_init (void) |
Initialize vendor messages. | |
Variables | |
gchar | v_tmp [4128] |
Large enough for a payload of 4K. | |
const struct vmsg | vmsg_map [] |
Known vendor-specific messages. |
|
Value: (0 != (c_vendor = VENDOR_CODE_CMP((it)->vendor, (o)->vendor)) \ ? c_vendor \ : PAIR_CMP(c_id, c_version, \ (it)->id, (o)->id, (it)->version, (o)->version)) |
|
Value: 0 != (c_vendor = VENDOR_CODE_CMP((item)->key, key)) \ ? c_vendor \ : PAIR_CMP(c_id, c_version, (item)->id, id, (item)->version, version) |
|
Value: G_STMT_START { \ return &vmsg_map[(i)]; \ /* NOTREACHED */ \ } G_STMT_END |
|
|
|
Value: |
|
Each entry is 6 bytes (4+2).
|
|
Each entry is 8 bytes (4+2+2).
|
|
|
|
Find message, given vendor code, and id, version.
|
|
Handle the "Features Supported" message.
|
|
Handle the "Hops Flow" message.
|
|
Handle the "Messages Supported" message.
|
|
Handle reception of an "OOB Reply Ack" message, whereby the remote host informs us about the amount of query hits it wants delivered for the query identified by the MUID of the message.
|
|
Handle reception of an "OOB Reply Indication" message, whereby the remote host informs us about the amount of query hits it has for us for a given query. The message bears the MUID of the query we sent out. |
|
Handle reception of the "Push Proxy Acknowledgment" message. Version 1 only bears the port. The IP address must be gathered from n->addr. Version 2 holds both the IP and port of our push-proxy. |
|
Handle reception of "Push Proxy Cancel" request, when remote node no longer wishes to have us as a push-proxy. This is an indication that the host determined it was not TCP-firewalled. |
|
Handle reception of the "Push Proxy Request" message.
|
|
Handle "Query Status Response" where the leave notifies us about the amount of results its search filters let pass through for the specified query.
|
|
Handle reception of "Query Status Request", where the UP requests how many results the search filters of the leave (ourselves) let pass through.
|
|
Handle the "TCP Connect Back" message.
|
|
Handle reception of a "Time Sync Reply" message, holding the reply from a previous time synchronization request.
|
|
Handle reception of a "Time Sync Request" message, indicating a request from another host about time synchronization.
|
|
Handle the \"UDP Connect Back" message.
|
|
Handle reception of an UDP crawler ping.
|
|
|
|
Report a vendor-message with bad payload to the stats.
|
|
Build an "OOB Reply Indication" message.
|
|
Fill common message header part for all vendor-specific messages. The GUID is blanked (all zero bytes), TTL is set to 1 and hops to 0. Those common values can be superseded by the caller if needed. `size' is only the size of the payload we filled so far. `maxsize' is the size of the already allocated vendor messsage.
|
|
Fill leading part of the payload data, containing the common part for all vendor-specific messages.
|
|
Main entry point to handle reception of vendor-specific message.
|
|
Decompiles vendor-message name given the data payload of the Gnutella message and its size. The leading bytes give us the identification unless it's too short.
|
|
Initialize vendor messages.
|
|
Assert that the vmsg_map[] array is sorted.
|
|
Send an "Hops Flow" message to specified node.
|
|
Send a "Messages Supported" message to specified node, telling it which subset of the vendor messages we can understand. We don't send information about the "Messages Supported" message itself, since this one is guaranteed to be always understood |
|
Send an "OOB Reply Ack" message to specified node, informing it that we want the specified amount of hits delivered for the query identified by the MUID of the message we got (the "OOB Reply Indication").
|
|
Send a "Push Proxy Acknowledgment" message to specified node, using supplied `muid' as the message ID (which is the target node's GUID). The version 1 of this message did not have the listening IP, only the port: the recipient was supposed to gather the IP address from the connected socket. The version 2 includes both our IP and port. |
|
Send a "Push Proxy Cancel" message to specified node.
|
|
Send a "Push Proxy Request" message to specified node, using supplied `muid' as the message ID (which is our GUID).
|
|
Send a "Query Status Response" message to specified node.
|
|
Send a "Query Status Request" message to specified node, using supplied `muid' as the message ID (which is the query ID).
|
|
Send a "TCP Connect Back" message to specified node, telling it to connect back to us on the specified port.
|
|
Send a "Time Sync Reply" message to the node, including the time at which we send back the message in the second half of the MUID. The time in `got' is the time at which we received their request. |
|
Send a "Time Sync Request" message, asking them to echo back their own time so that we can compute our clock differences and measure round trip times. The time at which we send the message is included in the first half of the MUID. If the node is an UDP node, its IP and port indicate to whom we shall send the message. The `sent' parameter holds the initial "T1" timestamp markup. |
|
Send a "UDP Connect Back" message to specified node, telling it to ping us back via UDP on the specified port. XXX for now, we only send GTKG/7v1, although GTKG/7v2 is more compact. |
|
Send UDP crawler pong, in reply to their ping. The supplied message block contains the payload to send back. |
|
Callback invoked when "Time Sync Reply" is about to be sent. Writes current time in the second half of the MUID. |
|
Callback invoked when "Time Sync Request" is about to be sent. Writes current time in the first half of the MUID. |
|
Large enough for a payload of 4K.
|
|
Initial value: { { T_0000, 0x0000, 0x0000, handle_messages_supported, "Messages Supported" }, { T_0000, 0x000a, 0x0000, handle_features_supported, "Features Supported" }, { T_BEAR, 0x0004, 0x0001, handle_hops_flow, "Hops Flow" }, { T_BEAR, 0x0007, 0x0001, handle_tcp_connect_back, "TCP Connect Back" }, { T_BEAR, 0x000b, 0x0001, handle_qstat_req, "Query Status Request" }, { T_BEAR, 0x000c, 0x0001, handle_qstat_answer, "Query Status Response" }, { T_GTKG, 0x0007, 0x0001, handle_udp_connect_back, "UDP Connect Back" }, { T_GTKG, 0x0007, 0x0002, handle_udp_connect_back, "UDP Connect Back" }, { T_GTKG, 0x0009, 0x0001, handle_time_sync_req, "Time Sync Request" }, { T_GTKG, 0x000a, 0x0001, handle_time_sync_reply, "Time Sync Reply" }, { T_GTKG, 0x0015, 0x0001, handle_proxy_cancel, "Push-Proxy Cancel" }, { T_LIME, 0x0005, 0x0001, handle_udp_crawler_ping, "UDP Crawler Ping" }, { T_LIME, 0x000b, 0x0002, handle_oob_reply_ack, "OOB Reply Ack" }, { T_LIME, 0x000c, 0x0001, handle_oob_reply_ind, "OOB Reply Indication" }, { T_LIME, 0x000c, 0x0002, handle_oob_reply_ind, "OOB Reply Indication" }, { T_LIME, 0x0015, 0x0001, handle_proxy_req, "Push-Proxy Request" }, { T_LIME, 0x0015, 0x0002, handle_proxy_req, "Push-Proxy Request" }, { T_LIME, 0x0016, 0x0001, handle_proxy_ack, "Push-Proxy Acknowledgment" }, { T_LIME, 0x0016, 0x0002, handle_proxy_ack, "Push-Proxy Acknowledgment" }, }
|