1/* Copyright (C) 2007-2008 The Android Open Source Project 2** 3** This software is licensed under the terms of the GNU General Public 4** License version 2, as published by the Free Software Foundation, and 5** may be copied, distributed, and modified under those terms. 6** 7** This program is distributed in the hope that it will be useful, 8** but WITHOUT ANY WARRANTY; without even the implied warranty of 9** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10** GNU General Public License for more details. 11*/ 12#ifndef _SLIRP_SHAPER_H_ 13#define _SLIRP_SHAPER_H_ 14 15#include <stddef.h> 16 17/* a NetShaper object is used to limit the throughput of data packets 18 * at a fixed rate expressed in bits/seconds 19 */ 20typedef struct NetShaperRec_* NetShaper; 21typedef void (*NetShaperSendFunc)( void* data, size_t size, void* opaque); 22 23NetShaper netshaper_create ( int do_copy, 24 NetShaperSendFunc send_func ); 25 26void netshaper_set_rate(NetShaper shaper, double rate ); 27 28void netshaper_send( NetShaper shaper, void* data, size_t size ); 29 30void netshaper_send_aux( NetShaper shaper, void* data, size_t size, void* opaque ); 31 32int netshaper_can_send( NetShaper shaper ); 33 34void netshaper_destroy (NetShaper shaper); 35 36/* a NetDelay object is used to simulate network connection latencies */ 37typedef struct NetDelayRec_* NetDelay; 38 39NetDelay netdelay_create( NetShaperSendFunc send_func ); 40void netdelay_set_latency( NetDelay delay, int min_ms, int max_ms ); 41void netdelay_send( NetDelay delay, const void* data, size_t size ); 42void netdelay_send_aux( NetDelay delay, const void* data, size_t size, void* opaque ); 43void netdelay_destroy( NetDelay delay ); 44 45/** in vl.c */ 46/* network traffic shaper and delayer */ 47extern NetShaper slirp_shaper_in; 48extern NetShaper slirp_shaper_out; 49extern NetDelay slirp_delay_in; 50 51#endif /* _SLIRP_SHAPER_H_ */ 52