~ubuntu-branches/ubuntu/karmic/gtk-gnutella/karmic

« back to all changes in this revision

Viewing changes to src/core/tx.h

  • Committer: Bazaar Package Importer
  • Author(s): Anand Kumria
  • Date: 2005-08-04 11:32:05 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050804113205-q746i4lgo3rtlegn
Tags: 0.95.4-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: tx.h,v 1.6 2005/06/25 01:37:41 daichik Exp $
 
3
 *
 
4
 * Copyright (c) 2002-2003, Raphael Manfredi
 
5
 *
 
6
 *----------------------------------------------------------------------
 
7
 * This file is part of gtk-gnutella.
 
8
 *
 
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.
 
13
 *
 
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.
 
18
 *
 
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
 
21
 *  Foundation, Inc.:
 
22
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 *----------------------------------------------------------------------
 
24
 */
 
25
 
 
26
/**
 
27
 * @ingroup core
 
28
 * @file
 
29
 *
 
30
 * Network driver.
 
31
 *
 
32
 * @author Raphael Manfredi
 
33
 * @date 2002-2003
 
34
 */
 
35
 
 
36
#ifndef _core_tx_h_
 
37
#define _core_tx_h_
 
38
 
 
39
#include <glib.h>
 
40
 
 
41
#include "if/core/hosts.h"
 
42
 
 
43
struct txdrv_ops;
 
44
struct iovec;
 
45
struct bio_source;
 
46
 
 
47
typedef void (*tx_service_t)(gpointer obj);
 
48
 
 
49
/**
 
50
 * A network driver.
 
51
 */
 
52
 
 
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 */
 
60
} txdrv_t;
 
61
 
 
62
/*
 
63
 * Driver flags.
 
64
 */
 
65
 
 
66
#define TX_SERVICE              0x00000001      /**< Servicing of upper layer needed */
 
67
 
 
68
/**
 
69
 * Operations defined on all drivers.
 
70
 */
 
71
 
 
72
struct txdrv_ops {
 
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);
 
83
};
 
84
 
 
85
/*
 
86
 * Public interface
 
87
 */
 
88
 
 
89
txdrv_t *tx_make(struct gnutella_node *n, const struct txdrv_ops *ops,
 
90
        gpointer args);
 
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);
 
104
 
 
105
#endif  /* _core_tx_h_ */
 
106
 
 
107
/* vi: set ts=4 sw=4 cindent: */
 
108