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

ggep.c File Reference


Detailed Description

Gnutella Generic Extension Protocol (GGEP).

Author:
Raphael Manfredi
Date:
2002-2004

#include "common.h"
#include "ggep.h"
#include "extensions.h"
#include "lib/cobs.h"
#include "lib/misc.h"
#include "lib/walloc.h"
#include "lib/zlib_util.h"
#include "if/gnet_property_priv.h"
#include "lib/override.h"

Functions

 RCSID ("$Id:ggep.c, v 1.22 2005/09/10 08:17:28 daichik Exp $")
gboolean ggep_stream_is_valid (ggep_stream_t *gs)
 Check whether a GGEP stream descriptor is valid.

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.

size_t ggep_stream_avail (ggep_stream_t *gs)
void ggep_stream_cleanup (ggep_stream_t *gs)
 Called when there is an error during the writing of the payload.

gboolean ggep_stream_appendc (ggep_stream_t *gs, gchar c)
 Append char to the GGEP stream.

gboolean ggep_stream_append (ggep_stream_t *gs, gconstpointer data, size_t len)
 Append data to the GGEP stream.

gboolean ggep_stream_begin (ggep_stream_t *gs, const gchar *id, guint32 wflags)
 Begin emission of GGEP extension.

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.


Function Documentation

gboolean ggep_stream_append ggep_stream_t gs,
gconstpointer  data,
size_t  len
[inline, static]
 

Append data to the GGEP stream.

Returns:
FALSE if there's not enough room in the output.

gboolean ggep_stream_appendc ggep_stream_t gs,
gchar  c
[inline, static]
 

Append char to the GGEP stream.

Returns:
FALSE if there's not enough room in the output.

size_t ggep_stream_avail ggep_stream_t gs  )  [inline, static]
 

Returns:
the number of bytes that can still be written to the stream at maximum.

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

Begin emission of GGEP extension.

Parameters:
gs a GGEP stream
id the ID of the GGEP extension
wflags whether COBS / deflate should be used.
Returns:
TRUE if OK, FALSE if there's not enough room in the output. On error, the stream is left in a clean state.

void ggep_stream_cleanup ggep_stream_t gs  )  [static]
 

Called when there is an error during the writing of the payload.

Restore the stream to the state it had before we began.

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.

RCSID "$Id:ggep.  c,
v 1.22 2005/09/10 08:17:28 daichik Exp $" 
 


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