annotate src/io/tx_layer.h @ 0:d39e1d0d75b6

initial add
author paulo@hit-nxdomain.opendns.com
date Sat, 20 Feb 2010 21:18:28 -0800
parents
children
rev   line source
paulo@0 1 /*
paulo@0 2 * $Id: tx_layer.h,v 1.5 2004/01/31 13:33:17 hipnod Exp $
paulo@0 3 *
paulo@0 4 * Copyright (C) 2003 giFT project (gift.sourceforge.net)
paulo@0 5 *
paulo@0 6 * This program is free software; you can redistribute it and/or modify it
paulo@0 7 * under the terms of the GNU General Public License as published by the
paulo@0 8 * Free Software Foundation; either version 2, or (at your option) any
paulo@0 9 * later version.
paulo@0 10 *
paulo@0 11 * This program is distributed in the hope that it will be useful, but
paulo@0 12 * WITHOUT ANY WARRANTY; without even the implied warranty of
paulo@0 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
paulo@0 14 * General Public License for more details.
paulo@0 15 */
paulo@0 16
paulo@0 17 #ifndef GIFT_GT_TX_LAYER_H_
paulo@0 18 #define GIFT_GT_TX_LAYER_H_
paulo@0 19
paulo@0 20 /*****************************************************************************/
paulo@0 21
paulo@0 22 struct tx_layer_ops;
paulo@0 23 struct tx_layer;
paulo@0 24
paulo@0 25 struct io_buf;
paulo@0 26 struct gt_tx_stack;
paulo@0 27
paulo@0 28 /*
paulo@0 29 * Return codes from the TX stack functions that lets the caller know
paulo@0 30 * what processing occured.
paulo@0 31 */
paulo@0 32 typedef enum tx_status
paulo@0 33 {
paulo@0 34 TX_OK,
paulo@0 35 TX_FULL, /* lower layer became saturated */
paulo@0 36 TX_EMPTY, /* no waiting data */
paulo@0 37 TX_PARTIAL, /* buffer partially read */
paulo@0 38 TX_ERROR, /* general error */
paulo@0 39 } tx_status_t;
paulo@0 40
paulo@0 41 struct tx_layer_ops
paulo@0 42 {
paulo@0 43 BOOL (*init) (struct tx_layer *tx);
paulo@0 44 void (*destroy) (struct tx_layer *tx);
paulo@0 45
paulo@0 46 /*
paulo@0 47 * If the layer is capable of consuming data (for example
paulo@0 48 * by sending it out on a connection), begin or stop flushing by obeying
paulo@0 49 * the 'stop' argument. Only the bottommost layer in a stack
paulo@0 50 * should implement this.
paulo@0 51 */
paulo@0 52 void (*toggle) (struct tx_layer *tx, BOOL stop);
paulo@0 53
paulo@0 54 /* upper layer has sent us a buffer */
paulo@0 55 tx_status_t (*queue) (struct tx_layer *tx, struct io_buf *io_buf);
paulo@0 56
paulo@0 57 /* lower layer wants us to send a buffer */
paulo@0 58 tx_status_t (*ready) (struct tx_layer *tx); /* lower layer wants data */
paulo@0 59
paulo@0 60 /* enable/disable this layer completely */
paulo@0 61 void (*enable) (struct tx_layer *tx);
paulo@0 62 void (*disable) (struct tx_layer *tx);
paulo@0 63 };
paulo@0 64
paulo@0 65 struct tx_layer
paulo@0 66 {
paulo@0 67 void *udata;
paulo@0 68 struct tx_layer_ops *ops;
paulo@0 69
paulo@0 70 struct tx_layer *upper;
paulo@0 71 struct tx_layer *lower;
paulo@0 72
paulo@0 73 /* leftovers from previous queue operations */
paulo@0 74 struct io_buf *partial_buf;
paulo@0 75
paulo@0 76 struct gt_tx_stack *stack;
paulo@0 77 const char *name;
paulo@0 78 };
paulo@0 79
paulo@0 80 /*****************************************************************************/
paulo@0 81
paulo@0 82 struct tx_layer *gt_tx_layer_new (struct gt_tx_stack *stack,
paulo@0 83 const char *name,
paulo@0 84 struct tx_layer_ops *ops);
paulo@0 85 void gt_tx_layer_free (struct tx_layer *layer);
paulo@0 86
paulo@0 87 void gt_tx_layer_enable (struct tx_layer *layer);
paulo@0 88 void gt_tx_layer_disable (struct tx_layer *layer);
paulo@0 89
paulo@0 90 tx_status_t gt_tx_layer_queue (struct tx_layer *layer,
paulo@0 91 struct io_buf *buf);
paulo@0 92 tx_status_t gt_tx_layer_ready (struct tx_layer *layer);
paulo@0 93
paulo@0 94 /*****************************************************************************/
paulo@0 95
paulo@0 96 #endif /* GIFT_GT_TX_LAYER_H_ */