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

core/bsched.h

Go to the documentation of this file.
00001 /*
00002  * $Id: bsched.h 12599 2006-12-10 15:21:49Z cbiere $
00003  *
00004  * Copyright (c) 2002-2003, Raphael Manfredi
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *----------------------------------------------------------------------
00024  */
00025 
00036 #ifndef _core_bsched_h_
00037 #define _core_bsched_h_
00038 
00039 #include "common.h"
00040 
00041 #include "sockets.h"        /* For enum socket_type */
00042 
00043 #include "lib/inputevt.h"
00044 #include "lib/tm.h"
00045 #include "if/core/hosts.h"  /* For gnet_host_t */
00046 #include "if/core/nodes.h"  /* For node_peer_t */
00047 #include "if/core/bsched.h"
00048 
00049 typedef struct sendfile_ctx {
00050     void *map;
00051     off_t map_start, map_end;
00052 } sendfile_ctx_t;
00053 
00054 struct iovec;
00055 
00056 /*
00057  * Public interface.
00058  */
00059 
00060 void bsched_early_init(void);
00061 void bsched_init(void);
00062 void bsched_shutdown(void);
00063 void bsched_close(void);
00064 void bsched_set_peermode(node_peer_t mode);
00065 void bsched_enable(bsched_bws_t bs);
00066 void bsched_disable(bsched_bws_t bs);
00067 void bsched_enable_all(void);
00068 bio_source_t *bsched_source_add(bsched_bws_t bs, wrap_io_t *wio, guint32 flags,
00069     inputevt_handler_t callback, gpointer arg);
00070 void bsched_source_remove(bio_source_t *bio);
00071 void bsched_set_bandwidth(bsched_bws_t bs, gint bandwidth);
00072 bio_source_t *bsched_source_add(bsched_bws_t bs, wrap_io_t *wio, guint32 flags,
00073     inputevt_handler_t callback, gpointer arg);
00074 void bio_add_callback(bio_source_t *bio,
00075     inputevt_handler_t callback, gpointer arg);
00076 void bio_remove_callback(bio_source_t *bio);
00077 ssize_t bio_write(bio_source_t *bio, gconstpointer data, size_t len);
00078 ssize_t bio_writev(bio_source_t *bio, struct iovec *iov, gint iovcnt);
00079 ssize_t bio_sendto(bio_source_t *bio, const gnet_host_t *to,
00080     gconstpointer data, size_t len);
00081 ssize_t bio_sendfile(sendfile_ctx_t *ctx, bio_source_t *bio, gint in_fd,
00082     off_t *offset, size_t len);
00083 ssize_t bio_read(bio_source_t *bio, gpointer data, size_t len);
00084 ssize_t bio_readv(bio_source_t *bio, struct iovec *iov, gint iovcnt);
00085 ssize_t bws_write(bsched_bws_t bs, wrap_io_t *wio,
00086             gconstpointer data, size_t len);
00087 ssize_t bws_read(bsched_bws_t bs, wrap_io_t *wio, gpointer data, size_t len);
00088 void bsched_timer(void);
00089 
00090 void bws_sock_connect(enum socket_type type);
00091 void bws_sock_connected(enum socket_type type);
00092 void bws_sock_accepted(enum socket_type type);
00093 void bws_sock_connect_timeout(enum socket_type type);
00094 void bws_sock_connect_failed(enum socket_type type);
00095 void bws_sock_closed(enum socket_type type, gboolean remote);
00096 gboolean bws_can_connect(enum socket_type type);
00097 
00098 void bws_udp_count_written(gint len);
00099 void bws_udp_count_read(gint len);
00100 
00101 gboolean bsched_enough_up_bandwidth(void);
00102 gboolean bsched_saturated(bsched_bws_t bws);
00103 gulong bsched_bps(bsched_bws_t bws);
00104 gulong bsched_avg_bps(bsched_bws_t bws);
00105 gulong bsched_pct(bsched_bws_t bws);
00106 gulong bsched_avg_pct(bsched_bws_t bws);
00107 gulong bsched_bw_per_second(bsched_bws_t bws);
00108 
00109 void bsched_config_steal_http_gnet(void);
00110 void bsched_config_steal_gnet(void);
00111 
00112 #endif  /* _core_bsched_h_ */
00113 
00114 /* vi: set ts=4 sw=4 cindent: */

Generated on Sat Jun 30 17:53:22 2007 for gtk-gnutella by  doxygen 1.3.9.1