• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
20 typedef struct NetShaperRec_*  NetShaper;
21 typedef void (*NetShaperSendFunc)( void*  data, size_t  size, void*  opaque);
22 
23 NetShaper   netshaper_create  ( int                do_copy,
24                                 NetShaperSendFunc  send_func );
25 
26 void        netshaper_set_rate(NetShaper  shaper, double  rate );
27 
28 void        netshaper_send( NetShaper  shaper, void* data, size_t  size );
29 
30 void        netshaper_send_aux( NetShaper  shaper, void* data, size_t  size, void*  opaque );
31 
32 int         netshaper_can_send( NetShaper  shaper );
33 
34 void        netshaper_destroy (NetShaper   shaper);
35 
36 /* a NetDelay object is used to simulate network connection latencies */
37 typedef struct NetDelayRec_*  NetDelay;
38 
39 NetDelay   netdelay_create( NetShaperSendFunc  send_func );
40 void       netdelay_set_latency( NetDelay  delay, int  min_ms, int  max_ms );
41 void       netdelay_send( NetDelay  delay, const void*  data, size_t  size );
42 void       netdelay_send_aux( NetDelay  delay, const void*  data, size_t  size, void*  opaque );
43 void       netdelay_destroy( NetDelay  delay );
44 
45 /** in vl.c */
46 /* network traffic shaper and delayer */
47 extern NetShaper   slirp_shaper_in;
48 extern NetShaper   slirp_shaper_out;
49 extern NetDelay    slirp_delay_in;
50 
51 #endif /* _SLIRP_SHAPER_H_ */
52