sf-rfw.c
Go to the documentation of this file.
37PADICO_MODULE_DECLARE(SocketFactory_Reverse_Forward, sfrfw_module_init, NULL, sfrfw_module_finalize);
199static void sfrfw_client_acceptor(void*key, int new_fd, const struct sockaddr*addr, socklen_t addrlen);
209 padico_topo_host_t padico_server_host = padico_topo_host_resolve_byinaddr(&(server_addr->sin_addr));
230 rc = (*sf.driver->bind)(sf._status, (struct sockaddr*) &client_addr, (socklen_t*) &client_addrlen);
262static void sfrfw_client_acceptor(void*key, int new_fd, const struct sockaddr*addr, socklen_t addrlen)
302 padico_string_catf(s_launch,"<SocketFactory_Reverse_Forward:Connect serverHost=\"%s\" serverPort=\"%d\" " ,
306 padico_control_send_async(status->gateway, padico_string_get(s_launch), &sfrfw_launch_gateway_notifer, status);
318 padico_out(10, "closing gateway=%s id=%d.\n", padico_topo_node_getname(status->gateway), status->gateway_id);
320 padico_string_catf(s_close,"<SocketFactory_Reverse_Forward:Close id=\"%d\"/>", status->gateway_id);
332static puk_instance_t sfrfw_gateway_get_socket(padico_topo_host_t padico_server_host, uint16_t port);
369 status->server_instance = sfrfw_gateway_get_socket(padico_server_host, (uint16_t) atoi(s_server_port));
417static puk_instance_t sfrfw_gateway_get_socket(padico_topo_host_t padico_server_host, uint16_t port)
420 assembly = padico_ns_host_selector(padico_server_host, "inet", sfrfw_gateway.iface_sf, port, IPPROTO_TCP);
423 padico_out(50, "host=%s served by assembly %s\n", padico_topo_host_getname(padico_server_host), assembly->name);
438 status->server_io = padico_io_register(fd, PADICO_IO_EVENT_READ, &sfrfw_gateway_server_read_callback, status);
464 padico_out(20, "reverse connect to client node=%s ..\n", padico_topo_host_getname(status->client_host));
465 status->client_instance = sfrfw_gateway_get_socket(status->client_host, ntohs(status->client_port));
474 //TODO: the sockets of the gateway will be closed but the client will not be informed of the error.
483 padico_out(10, "connect to addr=%s port=%d\n", inet_ntoa(client_addr.sin_addr), ntohs(status->client_port));
501 status->client_io = padico_io_register(fd, PADICO_IO_EVENT_READ, &sfrfw_gateway_client_read_callback, status);
572 struct sfrfw_gateway_status_s*status = sfrfw_connections_hashtable_lookup(&sfrfw_gateway.connections, id);
assert(slab_size > 0)
void(* padico_socketfactory_connector_t)(void *key, int fd)
Definition SocketFactory.h:34
static void puk_instance_context_indirect_SocketFactory(puk_instance_t instance, const char *label, struct puk_receptacle_SocketFactory_s *receptacle)
Definition SocketFactory.h:77
static void puk_instance_indirect_SocketFactory(puk_instance_t instance, const char *label, struct puk_receptacle_SocketFactory_s *receptacle)
Definition SocketFactory.h:77
@ padico_vsock_caps_directconnect
don't attempt to send an assembly request- directconnect only (through real sockets)
Definition VLink-API.h:179
@ padico_vsock_caps_clientonly
only usable as client- no server-side implementation
Definition VLink-API.h:183
puk_component_t padico_ns_host_selector(padico_topo_host_t host, const char *profile, puk_iface_t iface, uint16_t port, int protocol)
Definition ns-netselector.c:207
static void padico_control_send_async(padico_topo_node_t node, const char *cmd, padico_task_notifier_t notify, void *key)
Send an async request on the control channel.
Definition PadicoControl.h:108
static void padico_control_send_oneway(padico_topo_node_t node, const char *msg)
Send a "one way" message on the control channel.
Definition PadicoControl.h:102
void padico_tm_bgthread_start(padico_tm_bgthread_pool_t pool, padico_thread_fun_t f, void *arg, const char *name)
Definition tm-rttask.c:126
void padico_tm_bgthread_pool_wait(padico_tm_bgthread_pool_t pool)
finalize a pool of threads: waits for all thread to complete
Definition tm-rttask.c:78
padico_tm_bgthread_pool_t padico_tm_bgthread_pool_create(const char *name)
create a new thread pool
Definition tm-rttask.c:56
static const struct puk_component_driver_s sfrfw_component_driver
instanciation facet for SocketFactory-reverse-forward
Definition sf-rfw.c:74
static const struct padico_socketfactory_s sfrfw_sf_driver
'SocketFactory' facet for SocketFactory-reverse-forward
Definition sf-rfw.c:58
void padico_io_activate(padico_sysio_t io)
Activates the I/O handle - when not activated, the callback is not triggered.
Definition sysio.c:278
padico_sysio_t padico_io_register(int fd, unsigned int what, padico_sysio_callback_t callback, void *key)
Registers a file descriptor for polling.
Definition sysio.c:205
ssize_t padico_sysio_read(int fildes, void *buf, ssize_t nbyte)
Definition sysio.c:620
void padico_io_deactivate(padico_sysio_t io)
Deactivate the I/O handle - should be used for temporarly deactivate callback trigger.
Definition sysio.c:288
ssize_t padico_sysio_out(int fildes, const void *buf, size_t nbyte)
Definition sysio.c:808
padico_topo_host_t padico_topo_host_resolve_byinaddr(const struct in_addr *addr)
Get a host description record from an inet address (create if it didn't exist)
Definition topology.c:2452
const char * padico_topo_node_getname(padico_topo_node_t node)
Get the canonical name of a node.
Definition topology.c:1917
const struct in_addr * padico_topo_host_getaddr(padico_topo_host_t host)
Get the canonical IP address of a host.
Definition topology.c:1977
padico_topo_node_t padico_topo_getnodebyname(const char *nodename)
node lookup, by node name
Definition topology.c:2389
const char * padico_topo_host_getname(padico_topo_host_t host)
Get the canonical name of a host.
Definition topology.c:1944
padico_topo_host_t padico_topo_host_resolvebyname(const char *hostname)
resolve a host from name
Definition topology.c:2681
struct @32::@33 param
static struct @73 sfrfw_gateway
static int sfrfw_gateway_server_read_callback(int fd, void *key)
Definition sf-rfw.c:443
static puk_instance_t sfrfw_gateway_get_socket(padico_topo_host_t padico_server_host, uint16_t port)
Definition sf-rfw.c:417
static void sfrfw_client_acceptor(void *key, int new_fd, const struct sockaddr *addr, socklen_t addrlen)
Definition sf-rfw.c:262
static void sfrfw_gateway_set_error(puk_parse_entity_t e, char *error)
Definition sf-rfw.c:427
static void sfrfw_gateway_server_callback_connector(void *key, int fd)
Definition sf-rfw.c:434
static void sfrfw_gateway_connect_client(struct sfrfw_gateway_status_s *status)
Definition sf-rfw.c:462
static int sfrfw_launch_gateway(const char *server_host, const uint16_t server_port, struct sfrfw_status_s *status, const uint16_t client_port)
Definition sf-rfw.c:296
static void sfrfw_gateway_close_end_handler(puk_parse_entity_t e)
Definition sf-rfw.c:566
static void sfrfw_gateway_connect_server_end_handler(puk_parse_entity_t e)
Definition sf-rfw.c:345
static int sfrfw_gateway_client_read_callback(int fd, void *key)
Definition sf-rfw.c:506
static void sfrfw_gateway_close(struct sfrfw_gateway_status_s *status)
Definition sf-rfw.c:536
static void * sfrfw_instantiate(puk_instance_t, puk_context_t)
Definition sf-rfw.c:165
static int sfrfw_connect(void *_status, const struct sockaddr *_addr, socklen_t addrlen, padico_socketfactory_connector_t notifier, void *key)
Definition sf-rfw.c:203
static void sfrfw_launch_gateway_notifer(padico_rc_t rc, void *_key)
Definition sf-rfw.c:276
static int sfrfw_create(void *_status, int family, int type, int protocol)
Definition sf-rfw.c:188
static void sfrfw_gateway_client_callback_connector(void *key, int fd)
Definition sf-rfw.c:495
Definition SocketFactory.h:37
int(* create)(void *_status, int family, int type, int protocol)
create the socket attached to the SocketFactory instance
Definition SocketFactory.h:41
int(* listen)(void *_status, int backlog, const struct sockaddr *addr, socklen_t addrlen, padico_socketfactory_acceptor_t notifier, void *key)
listens incoming connections on the socket
Definition SocketFactory.h:56
int(* connect)(void *_status, const struct sockaddr *addr, socklen_t addrlen, padico_socketfactory_connector_t notifier, void *key)
connects the socket to the given address
Definition SocketFactory.h:64
int(* bind)(void *_status, struct sockaddr *addr, socklen_t *addrlen)
binds the socket to the given address (expected: AF_INET family) or performs autobind (AF_PADICO fami...
Definition SocketFactory.h:48
a thread pool, to control and wait running threads
Definition PadicoTM.h:174
struct padico_socketfactory_s * driver
Definition SocketFactory.h:77
Definition sf-rfw.c:107
Definition sf-rfw.c:194
Definition sf-rfw.c:92