Stream Namespace Reference

Interface between a user of a stream and the provider of a stream. More...

Data Structures

struct  ConnectAccept
 Accept a connection. More...
 
struct  ConnectIndication
 Connection indication. More...
 
struct  ConnectRequest
 Request a connection. More...
 
struct  DataIndication
 Data read from provider. More...
 
struct  DataRequest
 Information for sending data. More...
 
struct  DisconnectRequest
 Disconnect the stream. More...
 
struct  External
 Push an external endpoint into the provider. More...
 
struct  ipv4_addr
 
struct  ipv6_addr
 
struct  LengthFnxRequest
 Sets length function. More...
 
struct  ListenRequest
 Listen request. More...
 
class  Provider
 Provider of a stream interface. More...
 
struct  proxy_hdr_v2
 
struct  ProxyBuf
 
struct  ProxyIndication
 PROXY indication. More...
 
struct  ReadRequest
 Data read from provider. More...
 
struct  ReleaseBuf
 Release buffer. More...
 
class  SocketPoll
 Stream provider using sockets and using poll. More...
 
struct  StartTLS
 Initiate SSL/TLS on the stream. More...
 
struct  StatusIndication
 Status indication. More...
 
struct  StreamControl
 
class  SyncSocketPoll
 Synchronised class. More...
 
class  User
 Virtual class defining interface to stream user. More...
 

Typedefs

typedef size_t LengthFnx(const char *buf)
 Typedef for datagram length function.
 
using ReadFunction = size_t(*)(char *, size_t)
 
using string_iter = std::string::const_iterator
 

Enumerations

enum  StreamControlOption { StreamControlNoDelay , StreamControlKeepAlive , StreamControlTOS }
 Control the stream with various options. More...
 

Functions

bool read_ipv4 (string_iter &start, const string_iter end, std::uint32_t &addr)
 
bool read_ipv6 (string_iter &start, const string_iter end, in6_addr &addr)
 
bool read_port (string_iter &start, string_iter end, std::uint16_t &port)
 
bool read_proxy_ipv4 (const std::string &addr, ipv4_addr &proxy_header)
 
bool read_proxy_ipv6 (const std::string &addr, ipv6_addr &proxy_header)
 

Variables

const char v2sig [13] = "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A"
 

Detailed Description

Interface between a user of a stream and the provider of a stream.

Typedef Documentation

◆ LengthFnx

typedef size_t Stream::LengthFnx(const char *buf)

Typedef for datagram length function.

Definition at line 120 of file StreamInterface.h.

◆ ReadFunction

using Stream::ReadFunction = typedef size_t (*)(char *, size_t)

Definition at line 26 of file Proxy.h.

◆ string_iter

using Stream::string_iter = typedef std::string::const_iterator

Definition at line 50 of file Proxy.h.

Enumeration Type Documentation

◆ StreamControlOption

Control the stream with various options.

Enumerator
StreamControlKeepAlive 

No delay flag.

StreamControlTOS 

Keep alive flag.

Type of service flag

Definition at line 107 of file StreamInterface.h.

107 {
108 StreamControlNoDelay,
111 };
@ StreamControlTOS
Keep alive flag.
@ StreamControlKeepAlive
No delay flag.

Function Documentation

◆ read_ipv4()

bool Stream::read_ipv4 ( string_iter &  start,
const string_iter  end,
std::uint32_t &  addr 
)

Definition at line 19 of file Proxy.C.

20 {
21 auto p(start);
22 while (p != end && (std::isdigit(*p) || '.' == *p)) {
23 ++p;
24 }
25 if (!(p == end || ' ' == *p)) {
26 return false;
27 }
28 std::string tmp(start, p);
29 int r = inet_pton(AF_INET, tmp.c_str(), &addr);
30 if (1 == r) {
31 start = (p == end) ? p : p+1;
32 return true;
33 }
34 return false;
35 }

◆ read_ipv6()

bool Stream::read_ipv6 ( string_iter &  start,
const string_iter  end,
in6_addr &  addr 
)

Definition at line 37 of file Proxy.C.

38 {
39 auto p(start);
40 while (p != end && (std::isdigit(*p) || ':' == *p || ('a' <= *p && 'f' >= *p) ||
41 ('A' <= *p && 'F' >= *p))) {
42 ++p;
43 }
44 if (!(p == end || ' ' == *p)) {
45 return false;
46 }
47 std::string tmp(start, p);
48 int r = inet_pton(AF_INET6, tmp.c_str(), &addr);
49 if (1 == r) {
50 start = (p == end) ? p : p+1;
51 return true;
52 }
53 return false;
54 }

◆ read_port()

bool Stream::read_port ( string_iter &  start,
string_iter  end,
std::uint16_t &  port 
)

Definition at line 56 of file Proxy.C.

57 {
58 auto p(start);
59 bool in_digits = false;
60 while (p != end && isdigit(*p)) {
61 in_digits = true;
62 ++p;
63 }
64 if (!in_digits) {
65 return false;
66 }
67 if (!(p == end || ' ' == *p)) {
68 return false;
69 }
70 const std::string port_str(start, p);
71 if (port_str.length() > 5) {
72 return false;
73 }
74 auto port_int = std::atoi(port_str.c_str());
75 if (port_int > 65535) {
76 return false;
77 }
78 port = port_int;
79 start = (p == end) ? p : p+1;
80 return true;
81 }

◆ read_proxy_ipv4()

bool Stream::read_proxy_ipv4 ( const std::string &  addr,
ipv4_addr proxy_header 
)

Definition at line 83 of file Proxy.C.

84 {
85 auto end(addr.end());
86 auto p(addr.begin());
87 if (!read_ipv4(p, end, proxy_header.src_addr)) {
88 return false;
89 }
90 if (!read_ipv4(p, end, proxy_header.dst_addr)) {
91 return false;
92 }
93 if (!read_port(p, end, proxy_header.src_port)) {
94 return false;
95 }
96 if (!read_port(p, end, proxy_header.dst_port)) {
97 return false;
98 }
99 return true;
100 }

◆ read_proxy_ipv6()

bool Stream::read_proxy_ipv6 ( const std::string &  addr,
ipv6_addr proxy_header 
)

Definition at line 102 of file Proxy.C.

103 {
104 auto end(addr.end());
105 auto p(addr.begin());
106 if (!read_ipv6(p, end, proxy_header.src_addr)) {
107 return false;
108 }
109 if (!read_ipv6(p, end, proxy_header.dst_addr)) {
110 return false;
111 }
112 if (!read_port(p, end, proxy_header.src_port)) {
113 return false;
114 }
115 if (!read_port(p, end, proxy_header.dst_port)) {
116 return false;
117 }
118 return true;
119 }

Variable Documentation

◆ v2sig

const char Stream::v2sig[13] = "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A"

Definition at line 55 of file Proxy.h.

All rights reserved © 2002 - 2024 Isode Ltd.