1 #ifndef SUBORDINATION_PPL_SOCKET_PIPELINE_HH     2 #define SUBORDINATION_PPL_SOCKET_PIPELINE_HH     5 #include <unordered_map>     8 #include <unistdx/base/log_message>     9 #include <unistdx/it/field_iterator>    10 #include <unistdx/net/socket_address>    11 #include <unistdx/net/interface_address>    13 #include <subordination/kernel/kernel_instance_registry.hh>    14 #include <subordination/kernel/kstream.hh>    15 #include <subordination/ppl/basic_socket_pipeline.hh>    16 #include <subordination/ppl/local_server.hh>    20     template <
class K, 
class S, 
class R>
    23     template <
class K, 
class S, 
class R>
    26     template <
class K, 
class S, 
class R>
    29     template<
class K, 
class S, 
class R>
    33         typedef S socket_type;
    34         typedef R router_type;
    35         typedef sys::ipv4_address addr_type;
    36         typedef sys::interface_address<addr_type> ifaddr_type;
    42         using typename base_pipeline::kernel_type;
    43         using typename base_pipeline::mutex_type;
    44         using typename base_pipeline::lock_type;
    45         using typename base_pipeline::sem_type;
    46         using typename base_pipeline::kernel_pool;
    47         using typename base_pipeline::duration;
    52         typedef sys::ipaddr_traits<addr_type> traits_type;
    54         typedef typename server_container_type::iterator server_iterator;
    55         typedef typename server_container_type::const_iterator
    56             server_const_iterator;
    59         typedef typename client_container_type::iterator client_iterator;
    60         typedef ifaddr_type::rep_type rep_type;
    61         typedef mobile_kernel::id_type id_type;
    62         typedef sys::field_iterator<server_const_iterator,0> ifaddr_iterator;
    65         typedef uint32_t weight_type;
    72         client_iterator _iterator = this->_clients.
end();
    75         weight_type _weightcnt = 0;
    76         sys::port_type _port = 33333;
    79         bool _uselocalhost = 
true;
    98         add_client(
const sys::socket_address& addr) {
    99             lock_type lock(this->_mutex);
   100             this->do_add_client(addr);
   104         stop_client(
const sys::socket_address& addr);
   107         set_client_weight(
const sys::socket_address& addr, weight_type new_weight);
   110         add_server(
const ifaddr_type& rhs) {
   112                 sys::socket_address(rhs.address(), this->_port),
   118         add_server(
const sys::socket_address& rhs, addr_type netmask);
   124         set_port(sys::port_type rhs) noexcept {
   128         inline sys::port_type
   129         port() 
const noexcept {
   133         inline server_const_iterator
   134         servers_begin() 
const noexcept {
   135             return this->_servers.
begin();
   138         inline server_const_iterator
   139         servers_end() 
const noexcept {
   140             return this->_servers.
end();
   144         use_localhost(
bool b) noexcept {
   145             this->_uselocalhost = b;
   149         remove_server(
const ifaddr_type& interface_address);
   157         remove_client(
const sys::socket_address& vaddr);
   160         remove_client(client_iterator result);
   163         remove_server(server_iterator result);
   166         find_server(
const ifaddr_type& interface_address);
   169         find_server(sys::fd_type fd);
   172         find_server(
const sys::socket_address& dest);
   175         ensure_identity(kernel_type* k, 
const sys::socket_address& dest);
   182         end_reached() 
const noexcept {
   183             return this->_iterator == this->_clients.
end();
   187         reset_iterator() noexcept {
   188             this->_iterator = this->_clients.
end();
   189             this->_weightcnt = 0;
   193         current_client() 
const noexcept {
   194             return *this->_iterator->second;
   198         current_client() noexcept {
   199             return *this->_iterator->second;
   203         advance_client_iterator() noexcept {
   205             this->_weightcnt = 0;
   211         inline sys::socket_address
   212         virtual_addr(
const sys::socket_address& addr)
 const {
   213             return addr.family() == sys::family_type::unix
   215                    : sys::socket_address(addr, this->_port);
   219         process_kernels() 
override;
   222         process_kernel(kernel_type* k);
   225         find_or_create_client(
const sys::socket_address& addr);
   228         do_add_client(
const sys::socket_address& addr);
   231         do_add_client(socket_type&& sock, sys::socket_address vaddr);
   233         template <
class K1, 
class S1, 
class R1>
   236         template <
class K1, 
class S1, 
class R1>
   239         template <
class K1, 
class S1, 
class R1>
   246 #endif // vim:filetype=cpp 
Definition: socket_pipeline.hh:30
 
Definition: basic_socket_pipeline.hh:41
 
Definition: socket_pipeline.cc:174
 
Definition: socket_pipeline.cc:52
 
Definition: socket_pipeline.hh:27
 
Definition: foreign_kernel.hh:9