EPS Conduits  v0.0.2-2413
networking over networking
common.hpp File Reference
#include "eps-windows.hpp"
#include <map>
#include <set>
#include <vector>
#include <string>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ip/address_v4.hpp>
#include <boost/system/error_code.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/asio/posix/stream_descriptor.hpp>
Include dependency graph for common.hpp:
This graph shows which files directly or indirectly include this file:

Namespaces

 EPS
 

Typedefs

typedef std::map< std::string, std::string > EPS::StrMap
 Map of string-to-string. More...
 
typedef boost::asio::ip::tcp::endpoint EPS::TCPEP
 Convenient alias for boost TCP endpoint. More...
 
typedef boost::asio::ip::address_v4 EPS::IPv4
 Convenient alias for boost IPv4 address. More...
 
typedef boost::system::error_code EPS::EC
 Convenient alias for boost error codes. More...
 
typedef boost::uuids::uuid EPS::UUID
 Convenient alias for boost UUIDs. More...
 
typedef uint8_t EPS::UUID16[16]
 UUID POD (uuid data) More...
 
typedef std::set< UUID > EPS::UUIDSet
 Set of UUIDs. More...
 
typedef std::set< EPS::IPv4EPS::IPv4Set
 Set of IPv4 addresses. More...
 
typedef std::vector< EPS::IPv4EPS::IPv4Vec
 Vector of IPv4 addresses. More...
 
typedef boost::asio::posix::stream_descriptor EPS::ASIO_STREAM
 TUN/TAP stream descriptor. More...
 
typedef int EPS::FILE_HANDLE_DESCRIPTOR
 native file descriptor More...
 

Enumerations

enum  EPS::EMode {
  EPS::kInvalid = 0,
  EPS::kClient = 1,
  EPS::kServer = 2
}
 Enum to let some of the common code know if it is working in client or server mode. More...
 

Functions

std::string EPS::ipset_to_string (const IPv4Set &s)
 Convert a set of IPv4 addresses to a debug string. More...
 
std::string EPS::mode_to_string (const EPS::EMode mode)
 Convert the mode to a text string. More...
 
std::string EPS::cpp_demangle (const std::string &str)
 Demangle the given C++ name. This is compiler-specific. More...
 
void EPS::parse_network_and_mask (const std::string &str, IPv4 &network, IPv4 &netmask)
 Parse the network+mask string. More...
 
int EPS::get_random (const int min_val=0, const int max_val=99)
 Get a random int value between the specified range (inclusive). More...
 
std::string EPS::read_file (const std::string &filename)
 Read the entire file and return it as a text string. More...
 
void EPS::write_file (const std::string &filename, const std::string &text)
 Overwrite the filename with this content. More...
 
std::string EPS::hex_out (const uint8_t *data, const size_t len, const int number_of_rows_to_display=4)
 Produce hex output for the given data. More...
 
std::string EPS::get_utc_timestamp (time_t tt=0)
 Format the given time (or now) into a UTC timestamp. More...
 
std::string EPS::get_local_timestamp (time_t tt=0)
 Format the given time (or now) into a local timestamp. More...
 
std::string EPS::to_hex_string (const uint8_t *data, const size_t len)
 Format the given bytes to a hex string. More...
 
void EPS::from_hex_string (uint8_t *data, const size_t len, std::string str)
 Parse the given hex string and populate data. More...
 
std::string EPS::get_eps_conf_template (void)
 Get the content of the template/default eps.conf file. More...
 
std::string EPS::get_os_name (void)
 Get a "pretty" text string that describes the OS name. More...
 
std::string EPS::get_approximate_time (const time_t timestamp)
 Pretty-print a timestamp (in reference to now). More...
 
time_t EPS::get_boot_timestamp (void)
 Return a timestamp representing when the system was last rebooted. More...
 
size_t EPS::number_of_pkcs_padding_bytes (const size_t &len)
 PKCS padding adds between 1 and 16 bytes to our own length. More...
 
size_t EPS::length_including_pkcs_padding (const size_t &len)
 
std::string EPS::proto_to_string (const uint16_t proto_in_host_order)
 Convert the protocol field in the TAP packets to a readable string. More...
 
std::string EPS::proto_to_string (const EPS::CommData1 *cd1)
 Convert the protocol field in the TAP packets to a readable string. More...
 
std::string EPS::format (const long double &value, std::string &postfix)
 Format the value similar to KBytes or KBytes/sec. More...
 
std::string EPS::format_bytes (const uint64_t &value)
 Format the value similar to KBytes or KBytes/sec. More...
 
std::string EPS::format_bps (const uint64_t &value, int seconds)
 Format the value similar to KBytes or KBytes/sec. More...
 
std::string & EPS::trim (std::string &str)
 Trim whitespace from string. More...
 
std::string EPS::trim (const std::string &str)
 Trim whitespace from string. More...
 

Variables

static const size_t EPS::cipher_block_size = 16
 the size of blocks required for encryption/decryption More...
 
static const size_t EPS::bps_string_size = 32
 the size of the character-based BPS text fields More...
 
static const size_t EPS::network_buffer_size = 2048
 the size of arrays to allocate for incoming, outgoing, encryption and decryption network buffers More...