2
* $Id: tx.h,v 1.6 2005/06/25 01:37:41 daichik Exp $
4
* Copyright (c) 2002-2003, Raphael Manfredi
6
*----------------------------------------------------------------------
7
* This file is part of gtk-gnutella.
9
* gtk-gnutella is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* gtk-gnutella is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with gtk-gnutella; if not, write to the Free Software
22
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
*----------------------------------------------------------------------
32
* @author Raphael Manfredi
41
#include "if/core/hosts.h"
47
typedef void (*tx_service_t)(gpointer obj);
53
typedef struct txdriver {
54
struct gnutella_node *node; /**< Node to which this driver belongs */
55
const struct txdrv_ops *ops; /**< Dynamically dispatched operations */
56
gint flags; /**< Driver flags */
57
tx_service_t srv_routine; /**< Service routine of upper TX layer */
58
gpointer srv_arg; /**< Service routine argument */
59
gpointer opaque; /**< Used by heirs to store specific info */
66
#define TX_SERVICE 0x00000001 /**< Servicing of upper layer needed */
69
* Operations defined on all drivers.
73
gpointer (*init)(txdrv_t *tx, gpointer args);
74
void (*destroy)(txdrv_t *tx);
75
ssize_t (*write)(txdrv_t *tx, gpointer data, size_t len);
76
ssize_t (*writev)(txdrv_t *tx, struct iovec *iov, gint iovcnt);
77
ssize_t (*sendto)(txdrv_t *tx, gnet_host_t *to, gpointer data, size_t len);
78
void (*enable)(txdrv_t *tx);
79
void (*disable)(txdrv_t *tx);
80
size_t (*pending)(txdrv_t *tx);
81
void (*flush)(txdrv_t *tx);
82
struct bio_source *(*bio_source)(txdrv_t *tx);
89
txdrv_t *tx_make(struct gnutella_node *n, const struct txdrv_ops *ops,
91
void tx_free(txdrv_t *d);
92
ssize_t tx_write(txdrv_t *tx, gpointer data, size_t len);
93
ssize_t tx_writev(txdrv_t *tx, struct iovec *iov, gint iovcnt);
94
ssize_t tx_sendto(txdrv_t *tx, gnet_host_t *to, gpointer data, size_t len);
95
void tx_srv_register(txdrv_t *d, tx_service_t srv_fn, gpointer srv_arg);
96
void tx_srv_enable(txdrv_t *tx);
97
void tx_srv_disable(txdrv_t *tx);
98
size_t tx_pending(txdrv_t *tx);
99
struct bio_source *tx_bio_source(txdrv_t *tx);
100
ssize_t tx_no_write(txdrv_t *tx, gpointer data, size_t len);
101
ssize_t tx_no_writev(txdrv_t *tx, struct iovec *iov, gint iovcnt);
102
ssize_t tx_no_sendto(txdrv_t *tx, gnet_host_t *to, gpointer data, size_t len);
103
void tx_flush(txdrv_t *d);
105
#endif /* _core_tx_h_ */
107
/* vi: set ts=4 sw=4 cindent: */