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

ggep.h File Reference


Detailed Description

Gnutella Generic Extension Protocol (GGEP).

Author:
Raphael Manfredi
Date:
2002-2003

#include "extensions.h"
#include "lib/cobs.h"
#include "lib/zlib_util.h"
#include <glib.h>

Go to the source code of this file.

Data Structures

struct  ggep_stream
 Structure keeping track of incremental GGEP writes. More...


Defines

#define GGEP_MAGIC   '\xc3' /**< GGEP extension prefix */
 GGEP extension prefix.

#define GGEP_F_LAST   0x80U /**< Last extension in GGEP block */
 Last extension in GGEP block.

#define GGEP_F_COBS   0x40U /**< Whether COBS was used on payload */
 Whether COBS was used on payload.

#define GGEP_F_DEFLATE   0x20U /**< Whether payload was deflated */
 Whether payload was deflated.

#define GGEP_F_MBZ   0x10U /**< Bits that Must Be Zero */
 Bits that Must Be Zero.

#define GGEP_F_IDLEN   0x0fU /**< Where ID length is stored */
 Where ID length is stored.

#define GGEP_L_CONT   '\x80' /**< Continuation present */
 Continuation present.

#define GGEP_L_LAST   '\x40' /**< Last byte */
 Last byte.

#define GGEP_L_VALUE   '\x3f' /**< Value */
 Value.

#define GGEP_L_VSHIFT   6
#define GGEP_L_XFLAGS   (GGEP_L_CONT | GGEP_L_LAST)
#define GGEP_H_SHA1   0x01 /**< Binary SHA1 */
 Binary SHA1.

#define GGEP_H_BITPRINT   0x02 /**< Bitprint (SHA1 + Tiger tree root) */
 Bitprint (SHA1 + Tiger tree root).

#define GGEP_H_MD5   0x03 /**< Binary MD5 */
 Binary MD5.

#define GGEP_H_UUID   0x04 /**< Binary UUID (GUID-like) */
 Binary UUID (GUID-like).

#define GGEP_H_MD4   0x05 /**< Binary MD4 */
 Binary MD4.

#define GGEP_W_LAST   0x00000001 /**< This is the last extension */
 This is the last extension.

#define GGEP_W_COBS   0x00000002 /**< Attempt COBS encoding, if needed */
 Attempt COBS encoding, if needed.

#define GGEP_W_DEFLATE   0x00000004 /**< Attempt payload compression */
 Attempt payload compression.

#define GGEP_W_FIRST   0x00000008 /**< First extension, write GGEP_MAGIC */
 First extension, write GGEP_MAGIC.


Typedefs

typedef ggep_stream ggep_stream_t
 Structure keeping track of incremental GGEP writes.


Enumerations

enum  ggep_magic { GGEP_MAGIC_ID = 0x62961da4U }

Functions

gint ggep_decode_into (extvec_t *exv, gchar *buf, size_t len)
void ggep_stream_init (ggep_stream_t *gs, gpointer data, size_t len)
 Initialize a GGEP stream object, capable of receiving multiple GGEP extensions, written into the supplied buffer.

gboolean ggep_stream_begin (ggep_stream_t *gs, const char *id, guint32 wflags)
gboolean ggep_stream_writev (ggep_stream_t *gs, const struct iovec *iov, gint iovcnt)
 The vectorized version of ggep_stream_write().

gboolean ggep_stream_write (ggep_stream_t *gs, gconstpointer data, size_t len)
 Write data into the payload of the extension begun with ggep_stream_begin().

gboolean ggep_stream_end (ggep_stream_t *gs)
 End the extension begun with ggep_stream_begin().

size_t ggep_stream_close (ggep_stream_t *gs)
 We're done with the stream, close it.

gboolean ggep_stream_packv (ggep_stream_t *gs, const gchar *id, const struct iovec *iov, gint iovcnt, guint32 wflags)
 The vectorized version of ggep_stream_pack().

gboolean ggep_stream_pack (ggep_stream_t *gs, const gchar *id, gconstpointer payload, size_t plen, guint32 wflags)
 Pack extension data in initialized stream.

gboolean ggep_stream_is_valid (ggep_stream_t *gs)
 Check whether a GGEP stream descriptor is valid.


Define Documentation

#define GGEP_F_COBS   0x40U /**< Whether COBS was used on payload */
 

Whether COBS was used on payload.

#define GGEP_F_DEFLATE   0x20U /**< Whether payload was deflated */
 

Whether payload was deflated.

#define GGEP_F_IDLEN   0x0fU /**< Where ID length is stored */
 

Where ID length is stored.

#define GGEP_F_LAST   0x80U /**< Last extension in GGEP block */
 

Last extension in GGEP block.

#define GGEP_F_MBZ   0x10U /**< Bits that Must Be Zero */
 

Bits that Must Be Zero.

#define GGEP_H_BITPRINT   0x02 /**< Bitprint (SHA1 + Tiger tree root) */
 

Bitprint (SHA1 + Tiger tree root).

#define GGEP_H_MD4   0x05 /**< Binary MD4 */
 

Binary MD4.

#define GGEP_H_MD5   0x03 /**< Binary MD5 */
 

Binary MD5.

#define GGEP_H_SHA1   0x01 /**< Binary SHA1 */
 

Binary SHA1.

#define GGEP_H_UUID   0x04 /**< Binary UUID (GUID-like) */
 

Binary UUID (GUID-like).

#define GGEP_L_CONT   '\x80' /**< Continuation present */
 

Continuation present.

#define GGEP_L_LAST   '\x40' /**< Last byte */
 

Last byte.

#define GGEP_L_VALUE   '\x3f' /**< Value */
 

Value.

#define GGEP_L_VSHIFT   6
 

#define GGEP_L_XFLAGS   (GGEP_L_CONT | GGEP_L_LAST)
 

#define GGEP_MAGIC   '\xc3' /**< GGEP extension prefix */
 

GGEP extension prefix.

#define GGEP_W_COBS   0x00000002 /**< Attempt COBS encoding, if needed */
 

Attempt COBS encoding, if needed.

#define GGEP_W_DEFLATE   0x00000004 /**< Attempt payload compression */
 

Attempt payload compression.

#define GGEP_W_FIRST   0x00000008 /**< First extension, write GGEP_MAGIC */
 

First extension, write GGEP_MAGIC.

#define GGEP_W_LAST   0x00000001 /**< This is the last extension */
 

This is the last extension.


Typedef Documentation

typedef struct ggep_stream ggep_stream_t
 

Structure keeping track of incremental GGEP writes.


Enumeration Type Documentation

enum ggep_magic
 

Enumeration values:
GGEP_MAGIC_ID 


Function Documentation

gint ggep_decode_into extvec_t exv,
gchar *  buf,
size_t  len
 

gboolean ggep_stream_begin ggep_stream_t gs,
const char *  id,
guint32  wflags
 

size_t ggep_stream_close ggep_stream_t gs  ) 
 

We're done with the stream, close it.

Returns:
the length of the writen data in the whole stream.

gboolean ggep_stream_end ggep_stream_t gs  ) 
 

End the extension begun with ggep_stream_begin().

Returns:
TRUE if OK. On error, the stream is brought back to a clean state.

void ggep_stream_init ggep_stream_t gs,
gpointer  data,
size_t  len
 

Initialize a GGEP stream object, capable of receiving multiple GGEP extensions, written into the supplied buffer.

Parameters:
gs a GGEP stream
data start of buffer where data will be written
len length of supplied buffer

gboolean ggep_stream_is_valid ggep_stream_t gs  ) 
 

Check whether a GGEP stream descriptor is valid.

gboolean ggep_stream_pack ggep_stream_t gs,
const gchar *  id,
gconstpointer  payload,
size_t  plen,
guint32  wflags
 

Pack extension data in initialized stream.

The extension's name is `id' and its payload is represented by `plen' bytes starting at `payload'.

If `GGEP_W_COBS' is set, COBS encoding is attempted if there is a NUL byte within the payload.

If `GGEP_W_DEFLATE' is set, we attempt to deflate the payload. If the output is larger than the initial size, we emit the original payload instead.

Returns:
TRUE if written successfully. On error, the stream is reset as if the write attempt had not taken place, so one may continue writing shorter extension, if the error is due to a lack of space in the stream.

gboolean ggep_stream_packv ggep_stream_t gs,
const gchar *  id,
const struct iovec *  iov,
gint  iovcnt,
guint32  wflags
 

The vectorized version of ggep_stream_pack().

Returns:
TRUE if written successfully.

gboolean ggep_stream_write ggep_stream_t gs,
gconstpointer  data,
size_t  len
 

Write data into the payload of the extension begun with ggep_stream_begin().

Returns:
TRUE if OK. On error, the stream is brought back to a clean state.

gboolean ggep_stream_writev ggep_stream_t gs,
const struct iovec *  iov,
gint  iovcnt
 

The vectorized version of ggep_stream_write().

Returns:
TRUE if OK. On error, the stream is brought back to a clean state.


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