]> git.sesse.net Git - cubemap/blob - udpstream.h
The SO_MAX_PACING_RATE patches are now released in 3.13.
[cubemap] / udpstream.h
1 #ifndef _UDPSTREAM_H
2 #define _UDPSTREAM_H 1
3
4 // A single UDP destination. This is done a lot less efficient than HTTP streaming
5 // since we expect to have so few of them, which also means things are a lot simpler.
6 // In particular, we run in the input's thread, so there is no backlog, which means
7 // that there is no state (UDP itself is, of course, stateless).
8
9 #include <arpa/inet.h>
10 #include <netinet/in.h>
11 #include <stddef.h>
12 #include <stdint.h>
13 #include <sys/types.h>
14
15 class MarkPool;
16
17 class UDPStream {
18 public:
19         // <mark_pool> can be NULL. Does not take ownership of the mark pool.
20         UDPStream(const sockaddr_in6 &dst, MarkPool *mark_pool, uint32_t pacing_rate);
21         ~UDPStream();
22
23         void send(const char *data, size_t bytes);
24
25 private:
26         UDPStream(const UDPStream& other);
27
28         sockaddr_in6 dst;
29         int sock;
30         MarkPool *mark_pool;
31         int fwmark;
32         uint32_t pacing_rate;
33 };
34
35 #endif  // !defined(_UDPSTREAM_H)