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

gmsg.h File Reference


Detailed Description

Gnutella Messages.

Author:
Raphael Manfredi
Date:
2002-2003

#include "common.h"
#include "gnutella.h"
#include "pmsg.h"
#include "if/core/search.h"
#include "lib/endian.h"

Go to the source code of this file.

Enumerations

enum  gmsg_valid_t { GMSG_VALID = 0, GMSG_VALID_MARKED, GMSG_INVALID, GMSG_VALID_NO_PROCESS }

Functions

guint8 gmsg_function (gconstpointer data)
guint8 gmsg_hops (gconstpointer data)
guint16 gmsg_size (gconstpointer msg)
 Returns the size (16-bit quantity) of a gnutella message.
guint16 gmsg_flags (gconstpointer msg)
 Returns the flags (16-bit quantity) of a gnutella message.
void gmsg_init (void)
 Initialization of the Gnutella message structures.
const gchar * gmsg_name (guint function)
 Convert message function number into name.
gmsg_valid_t gmsg_size_valid (gconstpointer msg, guint16 *size)
 Returns whether the size field is properly architected as flags and size.
pmsg_tgmsg_to_pmsg (gconstpointer msg, guint32 size)
 Construct regular PDU descriptor from message.
pmsg_tgmsg_to_deflated_pmsg (gconstpointer msg, guint32 size)
 Construct compressed control PDU descriptor from message, for UDP traffic.
pmsg_tgmsg_to_ctrl_pmsg (gconstpointer msg, guint32 size)
 Construct control PDU descriptor from message.
pmsg_tgmsg_to_ctrl_pmsg_extend (gconstpointer msg, guint32 size, pmsg_free_t free_cb, gpointer arg)
 Construct extended control PDU (with free routine) from message.
pmsg_tgmsg_split_to_pmsg (gconstpointer head, gconstpointer data, guint32 size)
 Construct PDU from header and data.
pmsg_tgmsg_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_ctrl_sendto_one (struct gnutella_node *n, gconstpointer msg, guint32 size)
 Send control 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 *l, gconstpointer msg, guint32 size)
 Broadcast message to all nodes in the list.
void gmsg_split_sendto_all (const GSList *l, 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 (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_sendto_route (struct gnutella_node *n, struct route_dest *rt)
 Send message held in current node according to route specification.
gboolean gmsg_can_drop (gconstpointer pdu, gint size)
 Test whether the Gnutella message can be safely dropped on the connection.
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.
gint gmsg_cmp (gconstpointer pdu1, gconstpointer pdu2)
 Perform a priority comparison between two messages, given as the whole PDU.
const gchar * gmsg_infostr (gconstpointer msg)
gchar * gmsg_infostr_full (gconstpointer msg)
gchar * gmsg_infostr_full_split (gconstpointer head, gconstpointer data)
void gmsg_install_presend (pmsg_t *mb)
 Install "pre-send" callback for certain types of messages.
void gmsg_log_dropped (gconstpointer msg, const gchar *reason,...) G_GNUC_PRINTF(2
void gmsg_log_bad (const struct gnutella_node *n, const gchar *reason,...) G_GNUC_PRINTF(2
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_search_sendto_all (const GSList *l, gnet_search_t sh, gconstpointer msg, guint32 size)
 Broadcast our search message to all nodes in the list.


Enumeration Type Documentation

enum gmsg_valid_t
 

Enumeration values:
GMSG_VALID 
GMSG_VALID_MARKED 
GMSG_INVALID 
GMSG_VALID_NO_PROCESS 


Function Documentation

gboolean gmsg_can_drop gconstpointer  pdu,
gint  size
 

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.

gint gmsg_cmp gconstpointer  pdu1,
gconstpointer  pdu2
 

Perform a priority comparison between two messages, given as the whole PDU.

Returns:
algebraic -1/0/+1 depending on relative order.

void gmsg_ctrl_sendto_one struct gnutella_node n,
gconstpointer  msg,
guint32  size
 

Send control message to one node.

A control message is inserted ahead any other queued regular data.

guint16 gmsg_flags gconstpointer  msg  )  [inline, static]
 

Returns the flags (16-bit quantity) of a gnutella message.

guint8 gmsg_function gconstpointer  data  )  [inline, static]
 

guint8 gmsg_hops gconstpointer  data  )  [inline, static]
 

const gchar* gmsg_infostr gconstpointer  msg  ) 
 

Returns:
formatted static string:
msg_type (payload length) [hops=x, TTL=x]

gchar* gmsg_infostr_full gconstpointer  msg  ) 
 

Returns:
formatted static string:
msg_type (payload length) [hops=x, TTL=x]

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.

gchar* gmsg_infostr_full_split gconstpointer  head,
gconstpointer  data
 

Returns:
formatted static string:
msg_type (payload length) [hops=x, TTL=x]

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

void gmsg_init void   ) 
 

Initialization of the Gnutella message structures.

void gmsg_install_presend pmsg_t mb  ) 
 

Install "pre-send" callback for certain types of messages.

gboolean gmsg_is_oob_query gconstpointer  msg  ) 
 

Check whether query message starting at `msg' is flagged for OOB hit delivery.

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

void gmsg_log_dropped gconstpointer  msg,
const gchar *  reason,
  ...
 

void gmsg_mb_sendto_all const GSList *  sl,
pmsg_t mb
 

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.

void gmsg_mb_sendto_one struct gnutella_node n,
pmsg_t mb
 

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.

const gchar* gmsg_name guint  function  ) 
 

Convert message function number into name.

void gmsg_search_sendto_all const GSList *  l,
gnet_search_t  sh,
gconstpointer  msg,
guint32  size
 

Broadcast our search message to all nodes in the list.

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_sendto_all const GSList *  l,
gconstpointer  msg,
guint32  size
 

Broadcast message to all nodes in the list.

void gmsg_sendto_one struct gnutella_node n,
gconstpointer  msg,
guint32  size
 

Send message to one node.

void gmsg_sendto_route struct gnutella_node n,
struct route_dest rt
 

Send message held in current node according to route specification.

guint16 gmsg_size gconstpointer  msg  )  [inline, static]
 

Returns the size (16-bit quantity) of a gnutella message.

gmsg_valid_t gmsg_size_valid gconstpointer  msg,
guint16 *  size
 

Returns whether the size field is properly architected as flags and size.

Parameters:
msg the head of the message
size where the message size is returned if valid
Returns:
GMSG_VALID if we can process the message, GMSG_INVALID if the message should be dropped and the connection closed, GMSG_VALID_NO_PROCESS if the message is valid but cannot be interpreted locally.

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.

void gmsg_split_sendto_all const GSList *  l,
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 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.

We never broadcast anything to a leaf node. Those are handled specially.

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.

pmsg_t* gmsg_split_to_pmsg gconstpointer  head,
gconstpointer  data,
guint32  size
 

Construct PDU from header and data.

Parameters:
head pointer to the Gnutella header
data pointer to the Gnutella payload
size the total size of the message, header + payload

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.

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.

pmsg_t* gmsg_to_deflated_pmsg gconstpointer  msg,
guint32  size
 

Construct compressed control PDU descriptor from message, for UDP traffic.

The message payload is deflated only when the resulting size is smaller than the raw uncompressed form.

Message data is copied into the new data buffer, so caller may release its memory.

pmsg_t* gmsg_to_pmsg gconstpointer  msg,
guint32  size
 

Construct regular PDU descriptor from message.

Message data is copied into the new data buffer, so caller may release its memory.


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