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

tx_chunk.c File Reference


Detailed Description

Network driver -- chunked-encoding level.

This driver performed a "chunked" encoding of the data it receives before transmitting them. The specification of that encoding are those of HTTP/1.1, namely:

Chunked-Body = *chunk last-chunk trailer CRLF

chunk = chunk-size [ chunk-extension ] CRLF chunk-data CRLF chunk-size = 1*HEX last-chunk = 1*("0") [ chunk-extension ] CRLF

chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) chunk-ext-name = token chunk-ext-val = token | quoted-string chunk-data = chunk-size(OCTET) trailer = *(entity-header CRLF)

Author:
Raphael Manfredi
Date:
2005

#include "common.h"
#include "tx.h"
#include "tx_chunk.h"
#include "if/gnet_property_priv.h"
#include "lib/cq.h"
#include "lib/glib-missing.h"
#include "lib/walloc.h"
#include "lib/override.h"

Data Structures

struct  attr
 Private attributes for the decompressing layer. More...


Defines

#define CHUNK_DIGITS   4 /* At most that many digits in hexa */

Functions

 RCSID ("$Id:tx_chunk.c, v 1.12 2005/10/31 06:31:48 cbiere Exp $")
ssize_t chunk_flush_header (txdrv_t *tx)
 Flush the chunk header by sending it to the wire.

ssize_t chunk_begin (txdrv_t *tx, size_t len, gboolean final)
 Begin new chunk of said length, committing to write that much at least until the new chunk header.

ssize_t chunk_acceptable (txdrv_t *tx, size_t len)
 Compute how much data we can still send within the current chunk, knowing that we're offered `len' bytes from the upper layer.

void chunk_service (gpointer data)
 Service routine for the chunking stage.

gpointer tx_chunk_init (txdrv_t *tx, gpointer unused_args)
 Initialize the driver.

void tx_chunk_destroy (txdrv_t *tx)
 Get rid of the driver's private data.

ssize_t tx_chunk_write (txdrv_t *tx, gpointer data, size_t len)
 Write data buffer.

ssize_t tx_chunk_writev (txdrv_t *tx, struct iovec *iov, gint iovcnt)
 Write I/O vector.

void tx_chunk_enable (txdrv_t *unused_tx)
 Allow servicing of upper TX queue.

void tx_chunk_disable (txdrv_t *unused_tx)
 Disable servicing of upper TX queue.

size_t tx_chunk_pending (txdrv_t *tx)
void tx_chunk_flush (txdrv_t *tx)
 Send buffered data, if any.

void tx_chunk_shutdown (txdrv_t *tx)
 Disable all further transmission.

void tx_chunk_close (txdrv_t *tx, tx_closed_t cb, gpointer arg)
 Close the layer, flushing all the data there is.

const struct txdrv_opstx_chunk_get_ops (void)

Variables

const struct txdrv_ops tx_chunk_ops


Define Documentation

#define CHUNK_DIGITS   4 /* At most that many digits in hexa */
 


Function Documentation

ssize_t chunk_acceptable txdrv_t tx,
size_t  len
[static]
 

Compute how much data we can still send within the current chunk, knowing that we're offered `len' bytes from the upper layer.

ssize_t chunk_begin txdrv_t tx,
size_t  len,
gboolean  final
[static]
 

Begin new chunk of said length, committing to write that much at least until the new chunk header.

Returns:
+1 if we were able to flush the whole header, 0 if not and -1 if we encountered an error.

ssize_t chunk_flush_header txdrv_t tx  )  [static]
 

Flush the chunk header by sending it to the wire.

Returns:
+1 if we were able to flush the whole header, 0 if we need to be called again and -1 on errors..

void chunk_service gpointer  data  )  [static]
 

Service routine for the chunking stage.

Called by lower layer when it is ready to process more data.

RCSID "$Id:tx_chunk.  c,
v 1.12 2005/10/31 06:31:48 cbiere Exp $" 
 

void tx_chunk_close txdrv_t tx,
tx_closed_t  cb,
gpointer  arg
[static]
 

Close the layer, flushing all the data there is.

Once this is done, invoke the supplied callback.

void tx_chunk_destroy txdrv_t tx  )  [static]
 

Get rid of the driver's private data.

void tx_chunk_disable txdrv_t unused_tx  )  [static]
 

Disable servicing of upper TX queue.

void tx_chunk_enable txdrv_t unused_tx  )  [static]
 

Allow servicing of upper TX queue.

void tx_chunk_flush txdrv_t tx  )  [static]
 

Send buffered data, if any.

const struct txdrv_ops* tx_chunk_get_ops void   ) 
 

gpointer tx_chunk_init txdrv_t tx,
gpointer  unused_args
[static]
 

Initialize the driver.

Always succeeds, so never returns NULL.

size_t tx_chunk_pending txdrv_t tx  )  [static]
 

Returns:
the amount of data buffered locally.

void tx_chunk_shutdown txdrv_t tx  )  [static]
 

Disable all further transmission.

ssize_t tx_chunk_write txdrv_t tx,
gpointer  data,
size_t  len
[static]
 

Write data buffer.

Returns:
amount of data bytes written, or -1 on error.

ssize_t tx_chunk_writev txdrv_t tx,
struct iovec *  iov,
gint  iovcnt
[static]
 

Write I/O vector.

Returns:
amount of bytes written, or -1 on error.


Variable Documentation

const struct txdrv_ops tx_chunk_ops [static]
 

Initial value:

 {
    tx_chunk_init,      
    tx_chunk_destroy,   
    tx_chunk_write,     
    tx_chunk_writev,    
    tx_no_sendto,       
    tx_chunk_enable,    
    tx_chunk_disable,   
    tx_chunk_pending,   
    tx_chunk_flush,     
    tx_chunk_shutdown,  
    tx_chunk_close,     
    tx_no_source,       
}


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