Revision 6575ae37 util/udpSocket.h

View differences:

util/udpSocket.h
49 49
#ifndef UDPSOCKET_H
50 50
#define UDPSOCKET_H
51 51

  
52
#include <string.h>
52
#include <stdlib.h>
53
#include <unistd.h>
54
#include <sys/types.h>
55
#include <event2/event.h>
56
#include <time.h>
57

  
58
#ifndef WIN32
59
#include <arpa/inet.h>
60
#include <netdb.h>
53 61
#include <netinet/in.h>
62
#include <sys/socket.h>
63
#include <fcntl.h>
64
#else
65

  
66
#include <winsock2.h>
67

  
68
struct iovec {
69
  void *iov_base;
70
  size_t iov_len;
71
};
72

  
73
const char *inet_ntop(int af, const void *src,
74
       char *dst, size_t size);
75
int inet_pton(int af, const char * src, void * dst);
76
#endif
54 77

  
55 78
/**
56 79
 * The maximum buffer size for a send or received packet.  
......
112 135
 * @param bufferSize The size of the send buffer. 
113 136
 * @param *socketaddr The address of the remote socket
114 137
 */
115
int sendPacket(const int udpSocket, struct iovec *iov, int len, struct sockaddr_in *socketaddr);
138
int sendPacketFinal(const int udpSocket, struct iovec *iov, int len, struct sockaddr_in *socketaddr);
116 139

  
117
/** 
118
  * Decide if a packet should be throttled
119
  * The implementation follows a leaky bucket algorithm: 
120
  * if the packet would fill the bucket beyond its limit, it is to be discarded
121
  *
122
  * @param len The length of the packet to be sent
123
  * @return OK or THROTTLE 
124
*/
125
int outputRateControl(int len);
126

  
127
/**
128
  * Configure the parameters for output rate control.
129
  * These values may also be set while packets are being transmitted.
130
  * @param bucketsize The size of the bucket in kbytes
131
  * @param drainrate The amount of kbytes draining in a second. If drainrate is 0, then rateControl is completely disabled (all packets are passed).
132
*/
133
void setOutputRateParams(int bucketsize, int drainrate);
134 140

  
135 141
/**
136 142
 * Receive a udp packet
......
163 169
 */
164 170
int closeSocket(const int udpSocket);
165 171

  
172
/** 
173
  * Decide if a packet should be throttled
174
  * The implementation follows a leaky bucket algorithm: 
175
  * if the packet would fill the bucket beyond its limit, it is to be discarded
176
  *
177
  * @param len The length of the packet to be sent
178
  * @return OK or THROTTLE 
179
*/
180
int outputRateControl(int len);
181

  
182
/**
183
  * Configure the parameters for output rate control.
184
  * These values may also be set while packets are being transmitted.
185
  * @param bucketsize The size of the bucket in bytes
186
  * @param drainrate The darining rate in bits/s. If drainrate is 0, then rateControl is completely disabled (all packets are passed).
187
*/
188
void setOutputRateParams(int bucketsize, int drainrate);
189

  
190

  
191

  
166 192
#endif

Also available in: Unified diff