UCommon
Public Member Functions | Protected Attributes
ucommon::SSLBuffer Class Reference

Secure socket buffer. More...

#include <secure.h>

Inheritance diagram for ucommon::SSLBuffer:
Inheritance graph
[legend]
Collaboration diagram for ucommon::SSLBuffer:
Collaboration graph
[legend]

Public Member Functions

bool _flush (void)
 Flush buffer to physical i/o.
 
bool _pending (void)
 Check for pending tcp or ssl data. More...
 
size_t _pull (char *address, size_t size)
 Method to pull buffer from physical i/o (read). More...
 
size_t _push (const char *address, size_t size)
 Method to push buffer into physical i/o (write). More...
 
void close (void)
 
bool is_secure (void)
 
void open (const char *host, const char *service, size_t size=536)
 Connect a ssl client session to a specific host uri. More...
 
void release (void)
 
 SSLBuffer (secure::client_t context)
 
 SSLBuffer (const TCPServer *server, secure::server_t context, size_t size=536)
 
- Public Member Functions inherited from ucommon::TCPBuffer
void close (void)
 Close active connection.
 
void open (const TCPServer *server, size_t size=536)
 Connect a tcp socket to a client from a listener. More...
 
void open (const char *host, const char *service, size_t size=536)
 Connect a tcp client session to a specific host uri. More...
 
 TCPBuffer ()
 Construct an unconnected tcp client and specify our service profile.
 
 TCPBuffer (const TCPServer *server, size_t size=536)
 Construct a tcp server session from a listening socket. More...
 
 TCPBuffer (const char *host, const char *service, size_t size=536)
 Construct a tcp client session connected to a specific host uri. More...
 
virtual ~TCPBuffer ()
 Destroy the tcp socket and release all resources.
 
- Public Member Functions inherited from ucommon::BufferProtocol
const char * endl (void)
 
bool eof (void)
 Check if at end of input. More...
 
int err (void)
 
bool flush (void)
 Flush buffered memory to physical I/O. More...
 
size_t get (void *address, size_t count)
 Get memory from the buffer. More...
 
bool is_input (void)
 See if input active. More...
 
bool is_open (void)
 See if buffer open. More...
 
bool is_output (void)
 See if output active. More...
 
bool is_pending (void)
 See if pending input. More...
 
 operator bool ()
 See if buffer open. More...
 
bool operator! ()
 See if buffer closed. More...
 
size_t printf (const char *format,...)
 Print formatted string to the buffer. More...
 
void purge (void)
 Purge any pending input or output buffer data.
 
size_t put (const void *address, size_t count)
 Put memory into the buffer. More...
 
template<typename T >
size_t read (T &data)
 
template<typename T >
size_t read (T *data, unsigned count)
 
void reset (void)
 Reset input buffer state. More...
 
void seteof (void)
 Set eof flag.
 
template<typename T >
size_t write (const T &data)
 
template<typename T >
size_t write (const T *data, unsigned count)
 
- Public Member Functions inherited from ucommon::CharacterProtocol
int getchar (void)
 Get the next character. More...
 
size_t getline (char *string, size_t size)
 Get text as a line of input from the buffer. More...
 
size_t getline (String &buffer)
 Get a string as a line of input from the buffer. More...
 
size_t input (InputProtocol &format)
 
size_t load (StringPager *list)
 Load input to a string list. More...
 
size_t print (const PrintProtocol &format)
 
int putchar (int code)
 Put the next character. More...
 
size_t putchars (const char *string, size_t count=0)
 
size_t putline (const char *string)
 Put a string as a line of output to the buffer. More...
 
size_t save (const StringPager *list)
 Save output from a string list. More...
 

Protected Attributes

secure::bufio_t bio
 
bool server
 
secure::session_t ssl
 
bool verify
 

Additional Inherited Members

- Public Types inherited from ucommon::BufferProtocol
enum  mode_t { RDONLY, WRONLY, RDWR }
 
- Protected Member Functions inherited from ucommon::TCPBuffer
bool _blocking (void)
 Return true if blocking.
 
void _buffer (size_t size)
 
void _clear (void)
 Method to clear low level i/o error.
 
int _err (void) const
 Method to get low level i/o error. More...
 
socket_t getsocket (void) const
 Get the low level socket object. More...
 
- Static Protected Member Functions inherited from ucommon::Socket
static socket_t acceptfrom (socket_t socket, struct sockaddr_storage *address=((void *) 0))
 Accept a socket connection from a remote host. More...
 
static int bindto (socket_t socket, const char *address, const char *service, int protocol=0)
 Bind the socket descriptor to a known interface and service port. More...
 
static int bindto (socket_t socket, const struct sockaddr *address)
 Bind the socket descriptor to a known interface. More...
 
static int blocking (socket_t socket, bool enable)
 Set socket blocking I/O mode of socket descriptor. More...
 
static int broadcast (socket_t socket, bool enable)
 Set socket for unicast mode broadcasts on socket descriptor. More...
 
static void cancel (socket_t socket)
 Cancel pending i/o by shutting down the socket. More...
 
static bool ccid (socket_t socket, uint8_t id)
 Set congestion control id. More...
 
static int connectto (socket_t socket, struct addrinfo *list)
 Connect socket descriptor to a remote host from an address list. More...
 
static unsigned copy (struct sockaddr *target, const struct sockaddr *origin)
 Copy a socket address. More...
 
static socket_t create (int family, int type, int protocol)
 Create a socket object unbound. More...
 
static socket_t create (const struct addrinfo *address, int type, int protocol)
 Create a connected socket. More...
 
static socket_t create (const char *iface, const char *service, int family=0, int type=0, int protocol=0)
 Create a bound socket for a service. More...
 
static socket_t create (const Socket::address &address)
 Create a connected socket for a service. More...
 
static int disconnect (socket_t socket)
 Disconnect a connected socket descriptor. More...
 
static int drop (socket_t socket, const struct addrinfo *list)
 Drop socket descriptor from multicast group. More...
 
static bool eq_from (const struct sockaddr_storage *address1, const struct sockaddr_storage *address2)
 Compare socket addresses. More...
 
static bool eq_host (const struct sockaddr *address1, const struct sockaddr *address2)
 Compare socket host addresses. More...
 
static bool eq_inet (const struct sockaddr_internet *address1, const struct sockaddr_internet *address2)
 Compare socket addresses. More...
 
static bool eq_subnet (const struct sockaddr *address1, const struct sockaddr *address2)
 See if both addresses are in the same subnet. More...
 
static bool equal (const struct sockaddr *address1, const struct sockaddr *address2)
 Compare socket addresses. More...
 
static int error (socket_t socket)
 Get socket error code of socket descriptor. More...
 
static int error (void)
 Return error code of last socket operation,. More...
 
static int family (socket_t socket)
 Get the address family of the socket descriptor. More...
 
static int family (const struct sockaddr_storage &address)
 Get the address family of a socket address object. More...
 
static int family (const struct sockaddr_internet &address)
 Get the address family of an internet socket address object. More...
 
static struct addrinfohinting (socket_t socket, struct addrinfo *hint)
 Create an address info lookup hint based on the family and type properties of a socket descriptor. More...
 
static char * hostname (const struct sockaddr *address, char *buffer, size_t size)
 Lookup and return the host name associated with a socket address. More...
 
static void init (void)
 Initialize socket subsystem.
 
static void init (const char *program)
 Initialize with program name. More...
 
static bool is_null (const char *string)
 Simple function to validate that a given IP address string is a "zero" address. More...
 
static bool is_numeric (const char *string)
 Simple function to validate that a given IP address string is a numeric address. More...
 
static int join (socket_t socket, const struct addrinfo *list)
 Join socket descriptor to multicast group. More...
 
static int keepalive (socket_t socket, bool enable)
 Set socket for keepalive packets for socket descriptor. More...
 
static unsigned keyhost (const struct sockaddr *address, unsigned size)
 Convert a socket host address into a hash map index. More...
 
static unsigned keyindex (const struct sockaddr *address, unsigned size)
 Convert a socket address and service into a hash map index. More...
 
static socklen_t len (const struct sockaddr *address)
 Get the size of a socket address. More...
 
static int listento (socket_t socket, const struct sockaddr *address, int backlog=5)
 Bind the socket descriptor to a known interface listen on service port. More...
 
static int local (socket_t socket, struct sockaddr_storage *address)
 Get local address to which the socket is bound. More...
 
static int loopback (socket_t socket, bool enable)
 Set loopback to read multicast packets socket descriptor broadcasts. More...
 
static int multicast (socket_t socket, unsigned ttl=1)
 Set multicast mode and multicast broadcast range for socket descriptor. More...
 
static int nodelay (socket_t socket)
 Set tcp nodelay option on socket descriptor. More...
 
static unsigned pending (socket_t socket)
 Get the number of bytes pending in the receive buffer of a socket descriptor. More...
 
static ssize_t printf (socket_t socket, const char *format,...)
 Print formatted string to socket. More...
 
static int priority (socket_t socket, int scheduling)
 Set packet priority of socket descriptor. More...
 
static struct addrinfoquery (const char *host, const char *service, int type=SOCK_STREAM, int protocol=0)
 Get an address list directly. More...
 
static socklen_t query (socket_t socket, struct sockaddr_storage *address, const char *hostname, const char *service)
 Lookup a host name and service address based on the addressing family and socket type of a socket descriptor. More...
 
static char * query (const struct sockaddr *address, char *buffer, socklen_t size)
 Get the hostname of a socket address. More...
 
static void query (int family)
 Set default socket family preference for query options when the socket type is otherwise not specified. More...
 
static ssize_t readline (socket_t socket, char *data, size_t size, timeout_t timeout=Timer::inf)
 Read a newline of text data from the socket and save in NULL terminated string. More...
 
static ssize_t recvfrom (socket_t socket, void *buffer, size_t size, int flags=0, struct sockaddr_storage *address=((void *) 0))
 Get data waiting in receive queue. More...
 
static ssize_t recvinet (socket_t socket, void *buffer, size_t size, int flags=0, struct sockaddr_internet *address=((void *) 0))
 Get internet data waiting in receive queue. More...
 
static int recvsize (socket_t socket, unsigned size)
 Set the receive size of a socket descriptor. More...
 
static void release (struct addrinfo *list)
 Release an address list directly. More...
 
static void release (socket_t socket)
 Release (close) a socket. More...
 
static int remote (socket_t socket, struct sockaddr_storage *address)
 Get remote address to which the socket is connected. More...
 
static ssize_t replyto (socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_storage *address)
 Send reply on socket. More...
 
static unsigned segsize (socket_t socket, unsigned size=0)
 Set segment size and get MTU. More...
 
static ssize_t sendinet (socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_internet *address)
 Send to internet socket. More...
 
static int sendsize (socket_t socket, unsigned size)
 Set the send size of a socket descriptor. More...
 
static ssize_t sendto (socket_t socket, const void *buffer, size_t size, int flags=0, const struct sockaddr *address=((void *) 0))
 Send data on socket. More...
 
static int sendwait (socket_t socket, unsigned size)
 Set the size to wait before sending. More...
 
static short service (const struct sockaddr *address)
 Get the service port of a socket. More...
 
static short service (const struct sockaddr_internet *address)
 Get the service port of an inet socket. More...
 
static unsigned store (struct sockaddr_storage *storage, const struct sockaddr *address)
 Store an address into an address object. More...
 
static unsigned store (struct sockaddr_internet *storage, const struct sockaddr *address)
 Store an address into an internet address object. More...
 
static int tos (socket_t socket, int type)
 Set type of service of socket descriptor. More...
 
static int ttl (socket_t socket, unsigned char time)
 Set the time to live for the socket descriptor. More...
 
static int type (socket_t socket)
 Get the type of a socket. More...
 
static void v4mapping (bool enable)
 Set the default socket behavior for v6-v4 mapping. More...
 
static int via (struct sockaddr *address, const struct sockaddr *destination)
 Get the socket address of the interface needed to reach a destination address. More...
 
static bool wait (socket_t socket, timeout_t timeout=0)
 Test for pending input data. More...
 

Detailed Description

Secure socket buffer.

This is used to create ssl socket connections for both clients and servers. The use depends in part on the type of context created and passed at construction time. If no context is passed (NULL), then this reverts to TCPBuffer behavior.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 216 of file secure.h.

Member Function Documentation

bool ucommon::SSLBuffer::_pending ( void  )
virtual

Check for pending tcp or ssl data.

Returns
true if data pending.

Reimplemented from ucommon::TCPBuffer.

size_t ucommon::SSLBuffer::_pull ( char *  address,
size_t  size 
)
virtual

Method to pull buffer from physical i/o (read).

The address is passed to this virtual since it is hidden as private.

Parameters
addressof buffer to pull data into.
sizeof buffer area being pulled..
Returns
number of read written, 0 on error or end of data.

Reimplemented from ucommon::TCPBuffer.

size_t ucommon::SSLBuffer::_push ( const char *  address,
size_t  size 
)
virtual

Method to push buffer into physical i/o (write).

The address is passed to this virtual since it is hidden as private.

Parameters
addressof data to push.
sizeof data to push.
Returns
number of bytes written, 0 on error.

Reimplemented from ucommon::TCPBuffer.

void ucommon::SSLBuffer::open ( const char *  host,
const char *  service,
size_t  size = 536 
)

Connect a ssl client session to a specific host uri.

If the socket was already connected, it is automatically closed first.

Parameters
hostwe are connecting to.
serviceto connect to.
sizeof buffer and tcp fragments.

The documentation for this class was generated from the following file: