Skip to content

Commit

Permalink
continue reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Apr 20, 2024
1 parent 0f38763 commit b0cab43
Show file tree
Hide file tree
Showing 24 changed files with 616 additions and 1,260 deletions.
81 changes: 29 additions & 52 deletions tunnels/adapters/connector/connector.c
Original file line number Diff line number Diff line change
@@ -1,79 +1,56 @@
#include "connector.h"
#include "loggers/network_logger.h"
#include "types.h"
#include "utils/sockutils.h"
#include "loggers/network_logger.h"


static void tcpUpStream(tunnel_t *self, context_t *c)
{
}
static void tcpDownStream(tunnel_t *self, context_t *c)
{
}
static void udpUpStream(tunnel_t *self, context_t *c)
{
}
static void udpDownStream(tunnel_t *self, context_t *c)
{
}

static void upStream(tunnel_t *self, context_t *c)
{
}
static void downStream(tunnel_t *self, context_t *c)
{
}

tunnel_t *newConnector(node_instance_context_t *instance_info)
{
connector_state_t *state = malloc(sizeof(connector_state_t));
memset(state, 0, sizeof(connector_state_t));
const cJSON *settings = instance_info->node_settings_json;

if (!(cJSON_IsObject(settings) && settings->child != NULL))
if (! (cJSON_IsObject(settings) && settings->child != NULL))
{
LOGF("JSON Error: Connector->settings (object field) : The object was empty or invalid");
return NULL;
}

const cJSON *tcp_settings = cJSON_GetObjectItemCaseSensitive(settings, "tcp");
if ((cJSON_IsObject(tcp_settings) && settings->child != NULL))
{
getBoolFromJsonObject(&(state->tcp_no_delay), tcp_settings, "nodelay");
getBoolFromJsonObject(&(state->tcp_fast_open), tcp_settings, "fastopen");
getBoolFromJsonObject(&(state->reuse_addr), tcp_settings, "reuseaddr");
int ds = 0;
getIntFromJsonObject(&ds, tcp_settings, "domain-strategy");
state->domain_strategy = ds;
}
else
{
// memset set everything to 0...
}

state->dest_addr = parseDynamicStrValueFromJsonObject(settings, "address",2,
"src_context->address",
"dest_context->address");

if (state->dest_addr.status == kDvsEmpty)
{
LOGF("JSON Error: Connector->settings->address (string field) : The vaule was empty or invalid");
return NULL;
}

state->dest_port = parseDynamicNumericValueFromJsonObject(settings, "port",2,
"src_context->port",
"dest_context->port");

if (state->dest_port.status == kDvsEmpty)
{
LOGF("JSON Error: Connector->settings->port (number field) : The vaule was empty or invalid");
return NULL;
}
if(state->dest_addr.status == kDvsConstant){
state->dest_atype = getHostAddrType(state->dest_addr.value_ptr);
state->dest_domain_len = strlen(state->dest_addr.value_ptr);
}


tunnel_t *t = newTunnel();
t->state = state;

t->upStream = &upStream;
t->downStream = &downStream;

tunnel_t *t = newTunnel();
t->state = state;
t->upStream = &upStream;
t->downStream = &downStream;
atomic_thread_fence(memory_order_release);

return t;
}
api_result_t apiConnector(tunnel_t *self, char *msg)
api_result_t apiConnector(tunnel_t *self,const char *msg)
{
(void)(self); (void)(msg); return (api_result_t){0}; // TODO
(void) (self);
(void) (msg);
return (api_result_t){0};
}
tunnel_t *destroyConnector(tunnel_t *self)
{
(void) (self);
return NULL;
}
tunnel_metadata_t getMetadataConnector()
Expand Down
8 changes: 3 additions & 5 deletions tunnels/adapters/connector/connector.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#pragma once
#include "api.h"


// con <-----\ /-----> TCP Connect || Udp Associate
// con <------> Connector <------> TCP Connect || Udp Associate
// con <-----/ \-----> TCP Connect || Udp Associate
//


tunnel_t *newConnector(node_instance_context_t *instance_info);
api_result_t apiConnector(tunnel_t *self, char *msg);
tunnel_t *destroyConnector(tunnel_t *self);
tunnel_t * newConnector(node_instance_context_t *instance_info);
api_result_t apiConnector(tunnel_t *self, const char *msg);
tunnel_t * destroyConnector(tunnel_t *self);
tunnel_metadata_t getMetadataConnector();
Loading

0 comments on commit b0cab43

Please sign in to comment.