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

« back to all changes in this revision

Viewing changes to src/tx.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Kleineidam
  • Date: 2004-05-22 15:26:55 UTC
  • Revision ID: james.westby@ubuntu.com-20040522152655-lyi6iaswmy4hq4wy
Tags: upstream-0.93.3.0
ImportĀ upstreamĀ versionĀ 0.93.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: tx.h,v 1.8 2003/07/15 09:07:59 rmanfredi Exp $
 
3
 *
 
4
 * Copyright (c) 2002-2003, Raphael Manfredi
 
5
 *
 
6
 * Network driver.
 
7
 *
 
8
 *----------------------------------------------------------------------
 
9
 * This file is part of gtk-gnutella.
 
10
 *
 
11
 *  gtk-gnutella is free software; you can redistribute it and/or modify
 
12
 *  it under the terms of the GNU General Public License as published by
 
13
 *  the Free Software Foundation; either version 2 of the License, or
 
14
 *  (at your option) any later version.
 
15
 *
 
16
 *  gtk-gnutella is distributed in the hope that it will be useful,
 
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 *  GNU General Public License for more details.
 
20
 *
 
21
 *  You should have received a copy of the GNU General Public License
 
22
 *  along with gtk-gnutella; if not, write to the Free Software
 
23
 *  Foundation, Inc.:
 
24
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
25
 *----------------------------------------------------------------------
 
26
 */
 
27
 
 
28
#ifndef _tx_h_
 
29
#define _tx_h_
 
30
 
 
31
#include <glib.h>
 
32
 
 
33
struct txdrv_ops;
 
34
struct iovec;
 
35
struct bio_source;
 
36
 
 
37
typedef void (*tx_service_t)(gpointer obj);
 
38
 
 
39
/*
 
40
 * A network driver
 
41
 *
 
42
 */
 
43
typedef struct txdriver {
 
44
        struct gnutella_node *node;             /* Node to which this driver belongs */
 
45
        struct txdrv_ops *ops;                  /* Dynamically dispatched operations */
 
46
        gint flags;                                             /* Driver flags */
 
47
        tx_service_t srv_routine;               /* Service routine of upper TX layer */
 
48
        gpointer srv_arg;                               /* Service routine argument */
 
49
        gpointer opaque;                                /* Used by heirs to store specific info */
 
50
} txdrv_t;
 
51
 
 
52
/*
 
53
 * Driver flags.
 
54
 */
 
55
 
 
56
#define TX_SERVICE              0x00000001      /* Servicing of upper layer needed */
 
57
 
 
58
/*
 
59
 * Operations defined on all drivers.
 
60
 */
 
61
 
 
62
struct txdrv_ops {
 
63
        gpointer (*init)(txdrv_t *tx, gpointer args);
 
64
        void (*destroy)(txdrv_t *tx);
 
65
        gint (*write)(txdrv_t *tx, gpointer data, gint len);
 
66
        gint (*writev)(txdrv_t *tx, struct iovec *iov, gint iovcnt);
 
67
        void (*enable)(txdrv_t *tx);
 
68
        void (*disable)(txdrv_t *tx);
 
69
        gint (*pending)(txdrv_t *tx);
 
70
        struct bio_source *(*bio_source)(txdrv_t *tx);
 
71
};
 
72
 
 
73
/*
 
74
 * Public interface
 
75
 */
 
76
 
 
77
txdrv_t *tx_make(struct gnutella_node *n, struct txdrv_ops *ops, gpointer args);
 
78
void tx_free(txdrv_t *d);
 
79
gint tx_write(txdrv_t *tx, gpointer data, gint len);
 
80
gint tx_writev(txdrv_t *tx, struct iovec *iov, gint iovcnt);
 
81
void tx_srv_register(txdrv_t *d, tx_service_t srv_fn, gpointer srv_arg);
 
82
void tx_srv_enable(txdrv_t *tx);
 
83
void tx_srv_disable(txdrv_t *tx);
 
84
gint tx_pending(txdrv_t *tx);
 
85
struct bio_source *tx_bio_source(txdrv_t *tx);
 
86
 
 
87
#endif  /* _tx_h_ */
 
88
 
 
89
/* vi: set ts=4: */
 
90