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

extensions.h File Reference


Detailed Description

Gnutella message extension handling.

Author:
Raphael Manfredi
Date:
2002-2003

#include <glib.h>

Go to the source code of this file.

Data Structures

struct  extvec
 A public extension descriptor. More...


Defines

#define GGEP_NAME(x)   ext_ggep_name(CAT2(EXT_T_GGEP_,x))
#define GGEP_GTKG_NAME(x)   ext_ggep_name(CAT2(EXT_T_GGEP_GTKG_,x))
#define MAX_EXTVEC   32 /**< Maximum amount of extensions in vector */
 Maximum amount of extensions in vector.


Typedefs

typedef enum ext_type ext_type_t
 Known extension types.

typedef enum ext_token ext_token_t
 Extension tokens.

typedef extvec extvec_t
 A public extension descriptor.


Enumerations

enum  ext_type {
  EXT_UNKNOWN = 0, EXT_XML, EXT_HUGE, EXT_GGEP,
  EXT_NONE, EXT_TYPE_COUNT
}
 Known extension types. More...

enum  ext_token {
  EXT_T_UNKNOWN = 0, EXT_T_URN_BITPRINT, EXT_T_URN_SHA1, EXT_T_URN_EMPTY,
  EXT_T_XML, EXT_T_UNKNOWN_GGEP, EXT_T_OVERHEAD, EXT_T_GGEP_LIME_XML,
  EXT_T_GGEP_ALT, EXT_T_GGEP_BH, EXT_T_GGEP_CT, EXT_T_GGEP_DU,
  EXT_T_GGEP_GTKG_IPV6, EXT_T_GGEP_GTKG_TLS, EXT_T_GGEP_GTKGV1, EXT_T_GGEP_GUE,
  EXT_T_GGEP_H, EXT_T_GGEP_HNAME, EXT_T_GGEP_IP, EXT_T_GGEP_IPP,
  EXT_T_GGEP_LF, EXT_T_GGEP_LOC, EXT_T_GGEP_PATH, EXT_T_GGEP_PHC,
  EXT_T_GGEP_PUSH, EXT_T_GGEP_SCP, EXT_T_GGEP_T, EXT_T_GGEP_UDPHC,
  EXT_T_GGEP_UP, EXT_T_GGEP_VC, EXT_T_GGEP_u, EXT_T_TOKEN_COUNT
}
 Extension tokens. More...


Functions

void ext_init (void)
 Initialize the extension subsystem.

void ext_close (void)
 Free resources used by the extension subsystem.

void ext_prepare (extvec_t *exv, gint exvcnt)
 Prepare the vector for parsing, by ensuring the `opaque' pointers are all set to NULL.

gint ext_parse (gchar *buf, gint len, extvec_t *exv, gint exvcnt)
 Parse extension block of `len' bytes starting at `buf' and fill the supplied extension vector `exv', whose size is `exvcnt' entries.

void ext_reset (extvec_t *exv, gint exvcnt)
 Reset an extension vector by disposing of the opaque structures and of any allocated "virtual" payload.

gboolean ext_is_printable (const extvec_t *e)
gboolean ext_is_ascii (const extvec_t *e)
gboolean ext_has_ascii_word (const extvec_t *e)
void ext_dump (FILE *fd, const extvec_t *extvec, gint extcnt, const gchar *prefix, const gchar *postfix, gboolean payload)
 Dump all extensions in vector to specified stdio stream.

const gchar * ext_payload (const extvec_t *e)
guint16 ext_paylen (const extvec_t *e)
const gchar * ext_base (const extvec_t *e)
guint16 ext_headlen (const extvec_t *e)
guint16 ext_len (const extvec_t *e)
const gchar * ext_ggep_id_str (const extvec_t *e)
const gchar * ext_ggep_name (ext_token_t id)


Define Documentation

#define GGEP_GTKG_NAME  )     ext_ggep_name(CAT2(EXT_T_GGEP_GTKG_,x))
 

#define GGEP_NAME  )     ext_ggep_name(CAT2(EXT_T_GGEP_,x))
 

#define MAX_EXTVEC   32 /**< Maximum amount of extensions in vector */
 

Maximum amount of extensions in vector.


Typedef Documentation

typedef enum ext_token ext_token_t
 

Extension tokens.

typedef enum ext_type ext_type_t
 

Known extension types.

typedef struct extvec extvec_t
 

A public extension descriptor.

An extension block is structured thustly:

  • <.................len.......................>
  • <..headlen.><..........paylen...............>
  • +-----------+-------------------------------+
  • | header | extension payload |
  • +-----------+-------------------------------+
  • ^ ^
  • base payload

To be able to transparently handle decompression and COBS decoding of GGEP extensions, the public structure exposes no data fields. Everything must be fetched through accessors, which will make COBS and decompression invisible.

Each of the fields shown above can be accessed via ext_xxx(). For instance, access to the payload must be made through ext_payload(), and access to the whole length via ext_len().


Enumeration Type Documentation

enum ext_token
 

Extension tokens.

Enumeration values:
EXT_T_UNKNOWN  Unknown.
EXT_T_URN_BITPRINT  urn:bitprint:
EXT_T_URN_SHA1  urn:sha1:
EXT_T_URN_EMPTY  urn:
EXT_T_XML  XML payload.
EXT_T_UNKNOWN_GGEP  Unknown GGEP extension.
EXT_T_OVERHEAD  Pure overhead.
EXT_T_GGEP_LIME_XML  LimeWire XML metadata, in query hits.
EXT_T_GGEP_ALT  Alternate locations in query hits.
EXT_T_GGEP_BH  Browseable host indication.
EXT_T_GGEP_CT  Resource creation time.
EXT_T_GGEP_DU  Daily Uptime.
EXT_T_GGEP_GTKG_IPV6  GTKG IPv6 address.
EXT_T_GGEP_GTKG_TLS  GTKG TLS support indication.
EXT_T_GGEP_GTKGV1  GTKG version indication #1.
EXT_T_GGEP_GUE  GUESS support.
EXT_T_GGEP_H  GGEP binary hash value.
EXT_T_GGEP_HNAME  Hostname info, in query hits.
EXT_T_GGEP_IP  IP:Port, in ping and pongs (F2F).
EXT_T_GGEP_IPP  IP:Port, in pongs (UHC).
EXT_T_GGEP_LF  Large File, in query hits.
EXT_T_GGEP_LOC  Locale preferences.
EXT_T_GGEP_PATH  Shared file path, in query hits.
EXT_T_GGEP_PHC  Packed HostCaches, in pongs (UHC).
EXT_T_GGEP_PUSH  Push proxy info, in query hits.
EXT_T_GGEP_SCP  Support Cached Pongs, in pings (UHC).
EXT_T_GGEP_T  Textual information in query hits.
EXT_T_GGEP_UDPHC  UDP HostCache, in pongs (UHC).
EXT_T_GGEP_UP  UltraPeer information.
EXT_T_GGEP_VC  Vendor Code.
EXT_T_GGEP_u  HUGE URN in ASCII.
EXT_T_TOKEN_COUNT 

enum ext_type
 

Known extension types.

Enumeration values:
EXT_UNKNOWN  Unknown extension.
EXT_XML  XML extension.
EXT_HUGE  Hash/URN Gnutella Extensions.
EXT_GGEP  Gnutella Generic Extension Protocol.
EXT_NONE  Not really an extension, only overhead.
EXT_TYPE_COUNT 


Function Documentation

const gchar* ext_base const extvec_t e  ) 
 

Returns:
a pointer to the extension's header.
Warning:
the actual "virtual" payload may not be contiguous to the end of the header: don't read past the ext_headlen() first bytes of the header.

void ext_close void   ) 
 

Free resources used by the extension subsystem.

void ext_dump FILE *  fd,
const extvec_t exv,
gint  exvcnt,
const gchar *  prefix,
const gchar *  postfix,
gboolean  payload
 

Dump all extensions in vector to specified stdio stream.

The `prefix' and `postfix' strings, if non-NULL, are emitted before and after the extension summary.

If `payload' is true, the payload is dumped in hexadecimal if it contains non-printable characters, as text otherwise.

const gchar* ext_ggep_id_str const extvec_t e  ) 
 

Returns:
extension's GGEP ID, or "" if not a GGEP one.

const gchar* ext_ggep_name ext_token_t  id  ) 
 

gboolean ext_has_ascii_word const extvec_t e  ) 
 

Returns:
TRUE if extension is ASCII and contains at least a character.

guint16 ext_headlen const extvec_t e  ) 
 

Returns:
the length of the extensions's header.

void ext_init void   ) 
 

Initialize the extension subsystem.

gboolean ext_is_ascii const extvec_t e  ) 
 

Returns:
TRUE if extension is ASCII.

gboolean ext_is_printable const extvec_t e  ) 
 

Returns:
TRUE if extension is printable.

guint16 ext_len const extvec_t e  ) 
 

Returns:
the total length of the extension (payload + extension header).

gint ext_parse gchar *  buf,
gint  len,
extvec_t exv,
gint  exvcnt
 

Parse extension block of `len' bytes starting at `buf' and fill the supplied extension vector `exv', whose size is `exvcnt' entries.

Returns:
the number of filled entries.

guint16 ext_paylen const extvec_t e  ) 
 

Returns:
a pointer to the extension's payload length.

const gchar* ext_payload const extvec_t e  ) 
 

Returns:
a pointer to the extension's payload.

void ext_prepare extvec_t exv,
gint  exvcnt
 

Prepare the vector for parsing, by ensuring the `opaque' pointers are all set to NULL.

void ext_reset extvec_t exv,
gint  exvcnt
 

Reset an extension vector by disposing of the opaque structures and of any allocated "virtual" payload.


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