Namespaces | |
Cipher | |
Cipher takes care of calling OpenSSL to encrypt and decrypt NetBuffer objects. | |
Classes | |
class | ClientHull |
Client hull. More... | |
struct | CommAddress1 |
Communication header: send a number of important addresses sent by the server to the clients on startup. More... | |
struct | CommData1 |
Communication header: data packet. More... | |
struct | CommHeader1 |
Communication header: common fields to all communication commands. More... | |
struct | CommHello2 |
Communication header: initial "hello" sent between clients and servers when they first connect. More... | |
struct | CommList2 |
Communication header: list all devices. More... | |
struct | CommList2Data |
Represents a single EPS client. More... | |
struct | CommStats1 |
Communication header: send stats information. More... | |
class | Connection |
Base class for TCP and UDP connections between peer devices. More... | |
struct | EthernetHeader |
typical 14-byte ethernet header. (Ignores 802.1Q.) More... | |
class | Hull |
The Hull is the base class for both the client and server. More... | |
struct | Ipv4Header |
typical 20-byte IPV4 header. More... | |
class | NetBuffer |
NetBuffer objects manage blocks of buffer bytes used for either reading from, and writing to sockets. More... | |
class | Packet |
Simple class to dissect a packet and look for a few key identifiers, such as is_ipv4() and is_ipv4_tcp(). More... | |
class | ServerHull |
Server hull. More... | |
struct | Statistics |
Track all of the transfer and bandwidth statistics. More... | |
class | Stats |
Manage the EPS::Statistics structure. Differentiate between total statistics, and those gathered in the last minute. More... | |
class | TCPConnection |
TCP connection. More... | |
class | Tracker |
Manage all tracker records. More... | |
struct | TrackerData |
Used to track everything we know about a particular EPS client. More... | |
class | UDPConnection |
UDP connection. More... | |
Typedefs | |
typedef std::map< std::string, std::string > | StrMap |
Map of string-to-string. More... | |
typedef boost::asio::ip::tcp::endpoint | TCPEP |
Convenient alias for boost TCP endpoint. More... | |
typedef boost::asio::ip::address_v4 | IPv4 |
Convenient alias for boost IPv4 address. More... | |
typedef boost::system::error_code | EC |
Convenient alias for boost error codes. More... | |
typedef boost::uuids::uuid | UUID |
Convenient alias for boost UUIDs. More... | |
typedef uint8_t | UUID16[16] |
UUID POD (uuid data) More... | |
typedef std::set< UUID > | UUIDSet |
Set of UUIDs. More... | |
typedef std::set< EPS::IPv4 > | IPv4Set |
Set of IPv4 addresses. More... | |
typedef std::vector< EPS::IPv4 > | IPv4Vec |
Vector of IPv4 addresses. More... | |
typedef boost::asio::posix::stream_descriptor | ASIO_STREAM |
TUN/TAP stream descriptor. More... | |
typedef int | FILE_HANDLE_DESCRIPTOR |
native file descriptor More... | |
typedef std::deque< EPS::NetBuffer * > | NBDeque |
Asio async_write() calls cannot overlap, so store pending buffers to send in a deque. More... | |
typedef uint8_t | MAC[6] |
typedef std::shared_ptr< EPS::TCPConnection > | TConnPtr |
TCP connections are dynamically allocated when a socket is needed, so this type allows us to easily manage the lifespan of all connections. More... | |
typedef std::set< TConnPtr > | TCPConns |
When multiple TCP connections need to be grouped. More... | |
typedef std::map< UUID, EPS::TrackerData > | TrackerMap |
Map between client UUIDs and a tracker record. This is the central "database" that makes up the Tracker functionality. More... | |
typedef std::map< IPv4, UUID > | DestinationMap |
Map between an IP address and the corresponding UUID. This is a secondary index to quickly find an entry given an IP address. More... | |
typedef std::map< EPS::UUID, CommStats1 > | MUuidStats |
forward declaration More... | |
typedef std::map< EPS::UUID, EPS::UUIDSet > | MUuidMesh |
Enumerations | |
enum | EMode { kInvalid = 0, kClient = 1, kServer = 2 } |
Enum to let some of the common code know if it is working in client or server mode. More... | |
enum | ECommType { kUnknown = 0, kMinValid = 1, kHello1 = kMinValid, kAddress1 = 2, kData1 = 3, kList1 = 4, kStats1 = 5, kHello2 = 6, kList2 = 7, kMax } |
Communication structure types. More... | |
Functions | |
bool | validate_network_against_existing_routes (const uint32_t &eps_network_in_host_order, const uint32_t &eps_netmask_in_host_order) |
Verify that the network doesn't conflict with any existing network setting. More... | |
void | raise_tun_tap_interface (const uint32_t ip_address_in_network_order, std::string &device_name, FILE_HANDLE_DESCRIPTOR &device_fd) |
Raise the expected TUN/TAP interface. More... | |
void | set_tun_tap_routes (const uint32_t &network_in_network_order, const uint32_t &netmask_in_network_order, const std::string &device_name) |
Setup a route for the TUN/TAP interface. More... | |
void | close_tun_tap_interface (std::string &device_name, FILE_HANDLE_DESCRIPTOR &device_fd) |
Cleanly shut down the TUN/TAP interface. More... | |
std::string | ipset_to_string (const IPv4Set &s) |
Convert a set of IPv4 addresses to a debug string. More... | |
std::string | mode_to_string (const EPS::EMode mode) |
Convert the mode to a text string. More... | |
std::string | cpp_demangle (const std::string &str) |
Demangle the given C++ name. This is compiler-specific. More... | |
void | parse_network_and_mask (const std::string &str, IPv4 &network, IPv4 &netmask) |
Parse the network+mask string. More... | |
int | 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 | read_file (const std::string &filename) |
Read the entire file and return it as a text string. More... | |
void | write_file (const std::string &filename, const std::string &text) |
Overwrite the filename with this content. More... | |
std::string | 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 | get_utc_timestamp (time_t tt=0) |
Format the given time (or now) into a UTC timestamp. More... | |
std::string | get_local_timestamp (time_t tt=0) |
Format the given time (or now) into a local timestamp. More... | |
std::string | to_hex_string (const uint8_t *data, const size_t len) |
Format the given bytes to a hex string. More... | |
void | from_hex_string (uint8_t *data, const size_t len, std::string str) |
Parse the given hex string and populate data. More... | |
std::string | get_eps_conf_template (void) |
Get the content of the template/default eps.conf file. More... | |
std::string | get_os_name (void) |
Get a "pretty" text string that describes the OS name. More... | |
std::string | get_approximate_time (const time_t timestamp) |
Pretty-print a timestamp (in reference to now). More... | |
time_t | get_boot_timestamp (void) |
Return a timestamp representing when the system was last rebooted. More... | |
void | initialize_logging (const EPS::EMode mode) |
Initialize boost::log for EPS client/server. More... | |
void | initialize_file_logging (const std::string &filename) |
Add the specified filename to the logging output. More... | |
void | reset_logging (void) |
Reset boost::log and disable logging. More... | |
void | log_backtrace (void) |
Log a line for every function name in the call stack. More... | |
size_t | number_of_pkcs_padding_bytes (const size_t &len) |
PKCS padding adds between 1 and 16 bytes to our own length. More... | |
size_t | length_including_pkcs_padding (const size_t &len) |
std::string | 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 | proto_to_string (const EPS::CommData1 *cd1) |
Convert the protocol field in the TAP packets to a readable string. More... | |
std::string | format (const long double &value, std::string &postfix) |
Format the value similar to KBytes or KBytes/sec. More... | |
std::string | format_bytes (const uint64_t &value) |
Format the value similar to KBytes or KBytes/sec. More... | |
std::string | format_bps (const uint64_t &value, int seconds) |
Format the value similar to KBytes or KBytes/sec. More... | |
std::string & | trim (std::string &str) |
Trim whitespace from string. More... | |
std::string | trim (const std::string &str) |
Trim whitespace from string. More... | |
std::string | comm_type_to_string (const uint8_t type) |
Convert EPS::ECommType to a user-readable text string. More... | |
std::string | comm_type_to_string (const EPS::ECommType type) |
Convert EPS::ECommType to a user-readable text string. More... | |
Variables | |
static const size_t | cipher_block_size = 16 |
the size of blocks required for encryption/decryption More... | |
static const size_t | bps_string_size = 32 |
the size of the character-based BPS text fields More... | |
static const size_t | network_buffer_size = 2048 |
the size of arrays to allocate for incoming, outgoing, encryption and decryption network buffers More... | |
typedef boost::asio::posix::stream_descriptor EPS::ASIO_STREAM |
TUN/TAP stream descriptor.
typedef std::map<IPv4, UUID> EPS::DestinationMap |
Map between an IP address and the corresponding UUID. This is a secondary index to quickly find an entry given an IP address.
typedef boost::system::error_code EPS::EC |
Convenient alias for boost error codes.
typedef int EPS::FILE_HANDLE_DESCRIPTOR |
native file descriptor
typedef boost::asio::ip::address_v4 EPS::IPv4 |
Convenient alias for boost IPv4 address.
typedef std::set<EPS::IPv4> EPS::IPv4Set |
Set of IPv4 addresses.
typedef std::vector<EPS::IPv4> EPS::IPv4Vec |
Vector of IPv4 addresses.
typedef uint8_t EPS::MAC[6] |
typedef std::map<EPS::UUID, EPS::UUIDSet> EPS::MUuidMesh |
typedef std::map<EPS::UUID, CommStats1> EPS::MUuidStats |
forward declaration
typedef std::deque<EPS::NetBuffer*> EPS::NBDeque |
Asio async_write() calls cannot overlap, so store pending buffers to send in a deque.
typedef std::map<std::string, std::string> EPS::StrMap |
Map of string-to-string.
typedef std::shared_ptr<EPS::TCPConnection> EPS::TConnPtr |
TCP connections are dynamically allocated when a socket is needed, so this type allows us to easily manage the lifespan of all connections.
typedef std::set<TConnPtr> EPS::TCPConns |
When multiple TCP connections need to be grouped.
typedef boost::asio::ip::tcp::endpoint EPS::TCPEP |
Convenient alias for boost TCP endpoint.
typedef std::map<UUID, EPS::TrackerData> EPS::TrackerMap |
Map between client UUIDs and a tracker record. This is the central "database" that makes up the Tracker functionality.
typedef boost::uuids::uuid EPS::UUID |
Convenient alias for boost UUIDs.
typedef uint8_t EPS::UUID16[16] |
UUID POD (uuid data)
typedef std::set<UUID> EPS::UUIDSet |
Set of UUIDs.
enum EPS::ECommType |
Communication structure types.
Enumerator | |
---|---|
kUnknown | |
kMinValid | |
kHello1 | see EPS::CommHello1 (no longer supported, replaced by EPS:CommHello2) |
kAddress1 | |
kData1 | see EPS::CommData1 |
kList1 | see EPS::CommList1 (no longer supported, replaced by EPS::CommList2) |
kStats1 | see EPS::CommStats1 |
kHello2 | see EPS::CommHello2 (introduced in protocol version 4) |
kList2 | see EPS::CommList2 (introduced in protocol version 4) |
kMax | remember to update EPS::comm_type_to_string() if you add a new comm type |
enum EPS::EMode |
void EPS::close_tun_tap_interface | ( | std::string & | device_name, |
FILE_HANDLE_DESCRIPTOR & | device_fd | ||
) |
Cleanly shut down the TUN/TAP interface.
std::string EPS::comm_type_to_string | ( | const uint8_t | type | ) |
Convert EPS::ECommType to a user-readable text string.
std::string EPS::comm_type_to_string | ( | const EPS::ECommType | type | ) |
Convert EPS::ECommType to a user-readable text string.
std::string EPS::cpp_demangle | ( | const std::string & | str | ) |
Demangle the given C++ name. This is compiler-specific.
std::string EPS::format | ( | const long double & | value, |
std::string & | postfix | ||
) |
Format the value similar to KBytes or KBytes/sec.
std::string EPS::format_bps | ( | const uint64_t & | value, |
int | seconds | ||
) |
Format the value similar to KBytes or KBytes/sec.
std::string EPS::format_bytes | ( | const uint64_t & | value | ) |
Format the value similar to KBytes or KBytes/sec.
void EPS::from_hex_string | ( | uint8_t * | data, |
const size_t | len, | ||
std::string | str | ||
) |
Parse the given hex string and populate data.
std::string EPS::get_approximate_time | ( | const time_t | timestamp | ) |
Pretty-print a timestamp (in reference to now).
Figure out how long ago was "timestamp". Return an approximate text string, not a precise value. As the timestamp gets older, the precision is eroded. For example, valid strings returned could be "3 minutes ago" or "3 months ago".
time_t EPS::get_boot_timestamp | ( | void | ) |
Return a timestamp representing when the system was last rebooted.
std::string EPS::get_eps_conf_template | ( | void | ) |
Get the content of the template/default eps.conf file.
The contents of the template eps.conf file are generated from eps.ini using xxd.
std::string EPS::get_local_timestamp | ( | time_t | tt = 0 | ) |
Format the given time (or now) into a local timestamp.
std::string EPS::get_os_name | ( | void | ) |
Get a "pretty" text string that describes the OS name.
From the /etc/os-release
text file, try and extract PRETTY_NAME
. For example:
VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31"
or:
ID_LIKE=debian PRETTY_NAME="Ubuntu 14.04.1 LTS" VERSION_ID="14.04"
or:
VERSION_ID=20 PRETTY_NAME="Fedora 20 (Heisenbug)" ANSI_COLOR="0;34"
If os-release doesn't yield a usable name, see if /etc/issue
has something we can use.
Otherwise, the name used will be the output from running uname -sr
, such as "Linux 3.13.0-37-generic".
int EPS::get_random | ( | const int | min_val = 0 , |
const int | max_val = 99 |
||
) |
Get a random int value between the specified range (inclusive).
std::string EPS::get_utc_timestamp | ( | time_t | tt = 0 | ) |
Format the given time (or now) into a UTC timestamp.
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.
If number_of_rows_to_display is set to 1 or less, then all rows will be shown without skipping. Otherwise, the middle section of large buffers will be skipped to reduce the number of lines logged, keeping both the start and end of the buffer intact.
void EPS::initialize_file_logging | ( | const std::string & | filename | ) |
Add the specified filename to the logging output.
void EPS::initialize_logging | ( | const EPS::EMode | mode | ) |
Initialize boost::log for EPS client/server.
std::string EPS::ipset_to_string | ( | const IPv4Set & | s | ) |
Convert a set of IPv4 addresses to a debug string.
size_t EPS::length_including_pkcs_padding | ( | const size_t & | len | ) |
This method returns the full length, meaning our own size plus the number of padding bytes required.
void EPS::log_backtrace | ( | void | ) |
Log a line for every function name in the call stack.
std::string EPS::mode_to_string | ( | const EPS::EMode | mode | ) |
Convert the mode to a text string.
size_t EPS::number_of_pkcs_padding_bytes | ( | const size_t & | len | ) |
PKCS padding adds between 1 and 16 bytes to our own length.
AES requires exactly 16-bytes blocks. If a block is an exact multiple of 16 bytes, then another 16 bytes is added. Otherwise, between 1 and 15 bytes of padding are added to get an exact multiple of 16. This method returns the number of padding bytes needed to obtain a multiple of the AES block size.
Parse the network+mask string.
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.
std::string EPS::proto_to_string | ( | const EPS::CommData1 * | cd1 | ) |
Convert the protocol field in the TAP packets to a readable string.
void EPS::raise_tun_tap_interface | ( | const uint32_t | ip_address_in_network_order, |
std::string & | device_name, | ||
FILE_HANDLE_DESCRIPTOR & | device_fd | ||
) |
Raise the expected TUN/TAP interface.
std::string EPS::read_file | ( | const std::string & | filename | ) |
Read the entire file and return it as a text string.
void EPS::reset_logging | ( | void | ) |
Reset boost::log and disable logging.
void EPS::set_tun_tap_routes | ( | const uint32_t & | network_in_network_order, |
const uint32_t & | netmask_in_network_order, | ||
const std::string & | device_name | ||
) |
Setup a route for the TUN/TAP interface.
std::string EPS::to_hex_string | ( | const uint8_t * | data, |
const size_t | len | ||
) |
Format the given bytes to a hex string.
std::string & EPS::trim | ( | std::string & | str | ) |
Trim whitespace from string.
std::string EPS::trim | ( | const std::string & | str | ) |
Trim whitespace from string.
bool EPS::validate_network_against_existing_routes | ( | const uint32_t & | eps_network_in_host_order, |
const uint32_t & | eps_netmask_in_host_order | ||
) |
void EPS::write_file | ( | const std::string & | filename, |
const std::string & | text | ||
) |
Overwrite the filename with this content.
|
static |
the size of the character-based BPS text fields
|
static |
the size of blocks required for encryption/decryption
|
static |
the size of arrays to allocate for incoming, outgoing, encryption and decryption network buffers