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

tx.c File Reference


Detailed Description

Network TX drivers.

This file is the "ancestor" class of all TX drivers, and therefore only implements general routines that are mostly common, as well as provides type-checked entry points for dynamically dispatched routines, such as tx_write().

Author:
Raphael Manfredi
Date:
2002-2005

#include "common.h"
#include "tx.h"
#include "nodes.h"
#include "lib/walloc.h"
#include "lib/override.h"

Data Structures

struct  tx_close_arg
 Argument for tx_close_next(). More...


Defines

#define TX_INIT(o, a)   ((o)->ops->init((o), (a)))
#define TX_DESTROY(o)   ((o)->ops->destroy((o)))
#define TX_WRITE(o, d, l)   ((o)->ops->write((o), (d), (l)))
#define TX_WRITEV(o, i, c)   ((o)->ops->writev((o), (i), (c)))
#define TX_SENDTO(o, t, d, l)   ((o)->ops->sendto((o), (t), (d), (l)))
#define TX_ENABLE(o)   ((o)->ops->enable((o)))
#define TX_DISABLE(o)   ((o)->ops->disable((o)))
#define TX_PENDING(o)   ((o)->ops->pending((o)))
#define TX_BIO_SOURCE(o)   ((o)->ops->bio_source((o)))
#define TX_FLUSH(o)   ((o)->ops->flush((o)))
#define TX_SHUTDOWN(o)   ((o)->ops->shutdown((o)))
#define TX_CLOSE(o, c, a)   ((o)->ops->close((o), (c), (a)))

Functions

 RCSID ("$Id:tx.c, v 1.21 2005/11/30 16:43:41 rmanfredi Exp $")
txdrv_ttx_make (gpointer owner, gnet_host_t *host, const struct txdrv_ops *ops, gpointer args)
 Create a new network driver, equipped with the `ops' operations and initialize its specific parameters by calling the init routine with `args'.

void tx_attached (txdrv_t *tx, txdrv_t *utx)
 Called when an upper driver (utx) is attached on top of us.

txdrv_ttx_make_above (txdrv_t *ltx, const struct txdrv_ops *ops, gpointer args)
 Createion routine for a driver to be stacked above specified lower `ltx'.

void tx_shutdown (txdrv_t *tx)
 Shutdown stack, disallowing further writes.

void tx_deep_free (txdrv_t *tx)
 Dispose of the driver resources, recursively.

void tx_free (txdrv_t *tx)
 Dispose of the driver resources, asynchronously.

void tx_collect (void)
 Collect freed stacks.

ssize_t tx_write (txdrv_t *tx, gpointer data, size_t len)
 Write `len' bytes starting at `data'.

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

ssize_t tx_sendto (txdrv_t *tx, gnet_host_t *to, gpointer data, size_t len)
 Send buffer datagram to specified destination `to'.

void tx_srv_register (txdrv_t *tx, tx_service_t srv_fn, gpointer srv_arg)
 Register service routine from upper TX layer.

void tx_srv_enable (txdrv_t *tx)
 Record that upper layer wants its service routine enabled.

void tx_srv_disable (txdrv_t *tx)
 Record that upper layer wants its service routine disabled.

size_t tx_pending (txdrv_t *tx)
txdrv_ttx_deep_bottom (txdrv_t *tx)
void tx_eager_mode (txdrv_t *tx, gboolean on)
 Set stack in "eager" mode: in that mode, servicing is always enabled in the whole stack, meaning the bottom layer always invokes the queue service routines whenever it can accept more data.

bio_sourcetx_bio_source (txdrv_t *tx)
 The I/O source of the lowest layer (link) that physically sends the information.

void tx_flush (txdrv_t *tx)
 Request that data be sent immediately.

gboolean tx_has_error (txdrv_t *tx)
void tx_close_next (txdrv_t *tx, gpointer arg)
 Callback invoked when a layer in the TX stack was closed, i.e.

void tx_close (txdrv_t *tx, tx_closed_t cb, gpointer arg)
 Close the transmission by ensuring each layer properly finishes sending its data.

void tx_close_noop (txdrv_t *tx, tx_closed_t cb, gpointer arg)
 No-operation closing routine for layers that don't need anything special.

ssize_t tx_no_write (txdrv_t *unused_tx, gpointer unused_data, size_t unused_len)
 The write() operation is forbidden.

ssize_t tx_no_writev (txdrv_t *unused_tx, struct iovec *unused_iov, gint unused_iovcnt)
 The writev() operation is forbidden.

ssize_t tx_no_sendto (txdrv_t *unused_tx, gnet_host_t *unused_to, gpointer unused_data, size_t unused_len)
 The sendto() operation is forbidden.

bio_sourcetx_no_source (txdrv_t *unused_tx)
 No I/O source can be fetched from this layer.


Variables

GSList * tx_freed = NULL
 To guarantee that destruction of the stack always happens asynchronously with respect to the caller (i.e.


Define Documentation

#define TX_BIO_SOURCE  )     ((o)->ops->bio_source((o)))
 

#define TX_CLOSE o,
c,
 )     ((o)->ops->close((o), (c), (a)))
 

#define TX_DESTROY  )     ((o)->ops->destroy((o)))
 

#define TX_DISABLE  )     ((o)->ops->disable((o)))
 

#define TX_ENABLE  )     ((o)->ops->enable((o)))
 

#define TX_FLUSH  )     ((o)->ops->flush((o)))
 

#define TX_INIT o,
 )     ((o)->ops->init((o), (a)))
 

#define TX_PENDING  )     ((o)->ops->pending((o)))
 

#define TX_SENDTO o,
t,
d,
 )     ((o)->ops->sendto((o), (t), (d), (l)))
 

#define TX_SHUTDOWN  )     ((o)->ops->shutdown((o)))
 

#define TX_WRITE o,
d,
 )     ((o)->ops->write((o), (d), (l)))
 

#define TX_WRITEV o,
i,
 )     ((o)->ops->writev((o), (i), (c)))
 


Function Documentation

RCSID "$Id:tx.  c,
v 1.21 2005/11/30 16:43:41 rmanfredi Exp $" 
 

void tx_attached txdrv_t tx,
txdrv_t utx
[static]
 

Called when an upper driver (utx) is attached on top of us.

struct bio_source* tx_bio_source txdrv_t tx  ) 
 

The I/O source of the lowest layer (link) that physically sends the information.

void tx_close txdrv_t tx,
tx_closed_t  cb,
gpointer  arg
 

Close the transmission by ensuring each layer properly finishes sending its data.

When the whole stack is done, invoke the specified callback.

void tx_close_next txdrv_t tx,
gpointer  arg
[static]
 

Callback invoked when a layer in the TX stack was closed, i.e.

has no longer any buffered data. Proceed to the next layer if any, otherwise invoke the user callback.

void tx_close_noop txdrv_t tx,
tx_closed_t  cb,
gpointer  arg
 

No-operation closing routine for layers that don't need anything special.

void tx_collect void   ) 
 

Collect freed stacks.

txdrv_t* tx_deep_bottom txdrv_t tx  )  [static]
 

Returns:
the driver at the bottom of the stack.

void tx_deep_free txdrv_t tx  )  [static]
 

Dispose of the driver resources, recursively.

void tx_eager_mode txdrv_t tx,
gboolean  on
 

Set stack in "eager" mode: in that mode, servicing is always enabled in the whole stack, meaning the bottom layer always invokes the queue service routines whenever it can accept more data.

This mode is appropriate when the data to send is already generated or easily computed on demand and the limiting factor is the output bandwidth.

void tx_flush txdrv_t tx  ) 
 

Request that data be sent immediately.

void tx_free txdrv_t tx  ) 
 

Dispose of the driver resources, asynchronously.

It must be called on the top layer only.

gboolean tx_has_error txdrv_t tx  ) 
 

Returns:
TRUE if there is an error reported by any layer underneath.

txdrv_t* tx_make gpointer  owner,
gnet_host_t host,
const struct txdrv_ops ops,
gpointer  args
 

Create a new network driver, equipped with the `ops' operations and initialize its specific parameters by calling the init routine with `args'.

Returns:
NULL if there is an initialization problem.

txdrv_t* tx_make_above txdrv_t ltx,
const struct txdrv_ops ops,
gpointer  args
 

Createion routine for a driver to be stacked above specified lower `ltx'.

Returns:
NULL if there is an initialization problem.

ssize_t tx_no_sendto txdrv_t unused_tx,
gnet_host_t unused_to,
gpointer  unused_data,
size_t  unused_len
 

The sendto() operation is forbidden.

struct bio_source* tx_no_source txdrv_t unused_tx  ) 
 

No I/O source can be fetched from this layer.

ssize_t tx_no_write txdrv_t unused_tx,
gpointer  unused_data,
size_t  unused_len
 

The write() operation is forbidden.

ssize_t tx_no_writev txdrv_t unused_tx,
struct iovec *  unused_iov,
gint  unused_iovcnt
 

The writev() operation is forbidden.

size_t tx_pending txdrv_t tx  ) 
 

Returns:
amount of data pending in the whole stack.

ssize_t tx_sendto txdrv_t tx,
gnet_host_t to,
gpointer  data,
size_t  len
 

Send buffer datagram to specified destination `to'.

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

void tx_shutdown txdrv_t tx  ) 
 

Shutdown stack, disallowing further writes.

void tx_srv_disable txdrv_t tx  ) 
 

Record that upper layer wants its service routine disabled.

void tx_srv_enable txdrv_t tx  ) 
 

Record that upper layer wants its service routine enabled.

void tx_srv_register txdrv_t tx,
tx_service_t  srv_fn,
gpointer  srv_arg
 

Register service routine from upper TX layer.

ssize_t tx_write txdrv_t tx,
gpointer  data,
size_t  len
 

Write `len' bytes starting at `data'.

Returns:
the amount of bytes written, or -1 with errno set on error.

ssize_t tx_writev txdrv_t tx,
struct iovec *  iov,
gint  iovcnt
 

Write I/O vector.

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


Variable Documentation

GSList* tx_freed = NULL [static]
 

To guarantee that destruction of the stack always happens asynchronously with respect to the caller (i.e.

it is not happening in the same calling stack), freed stacks are remembered and periodically collected.


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