Skip to content

Commit

Permalink
reformat / v1.31
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Aug 15, 2024
1 parent 068e273 commit 0ef82e2
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 1,639 deletions.
2 changes: 1 addition & 1 deletion tunnels/layer3/receiver/receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ enum mode_dynamic_value_status
kDvsSourceMode = kDvsFirstOption,
kDvsDestMode
};
struct ip6_hdr;


static void upStream(tunnel_t *self, context_t *c)
{
Expand Down
6 changes: 2 additions & 4 deletions tunnels/layer3/sender/sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ static void printSendingIPPacketInfo(const unsigned char *buffer, unsigned int l
LOGD(logbuf);
}


static void upStream(tunnel_t *self, context_t *c)
{
layer3_senderstate_t *state = TSTATE(self);
Expand All @@ -88,7 +87,7 @@ static void upStream(tunnel_t *self, context_t *c)
if (packet->ip4_header.protocol == 6)
{
struct tcpheader *tcp_header = (struct tcpheader *) (rawBufMut(c->payload) + ip_header_len);
tcpCheckSum4(&(packet->ip4_header),tcp_header);
tcpCheckSum4(&(packet->ip4_header), tcp_header);
}
}
else if (packet->ip6_header.version == 6)
Expand All @@ -98,7 +97,7 @@ static void upStream(tunnel_t *self, context_t *c)
if (packet->ip6_header.nexthdr == 6)
{
struct tcpheader *tcp_header = (struct tcpheader *) (rawBufMut(c->payload) + ip_header_len);
tcpCheckSum6(&(packet->ip6_header),tcp_header);
tcpCheckSum6(&(packet->ip6_header), tcp_header);
}
}
else
Expand All @@ -107,7 +106,6 @@ static void upStream(tunnel_t *self, context_t *c)
exit(1);
}


state->tun_device_tunnel->upStream(state->tun_device_tunnel, c);
}

Expand Down
2 changes: 0 additions & 2 deletions tunnels/layer3/tcp_manipulator/tcp_manipulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ static void upStream(tunnel_t *self, context_t *c)

handleResetBitAction(tcp_header, &(state->reset_bit_action));

// reCalculateCheckSum(tcp_header, transport_palyoad_len);

self->up->upStream(self->up, c);
}

Expand Down
1 change: 0 additions & 1 deletion ww/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ add_library(ww STATIC
frand.c
pipe_line.c
utils/utils.c
utils/btree.c
managers/signal_manager.c
managers/socket_manager.c
managers/node_manager.c
Expand Down
2 changes: 2 additions & 0 deletions ww/buffer_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ unsigned int getBufferPoolLargeBufferDefaultSize(void)
{
return LARGE_BUFFER_SIZE;
}

unsigned int getBufferPoolSmallBufferDefaultSize(void)
{
return SMALL_BUFFER_SIZE;
Expand Down Expand Up @@ -197,6 +198,7 @@ shift_buffer_t *popSmallBuffer(buffer_pool_t *pool)

void reuseBuffer(buffer_pool_t *pool, shift_buffer_t *b)
{

#if defined(DEBUG) && defined(BYPASS_BUFFERPOOL)
destroyShiftBuffer(pool->shift_buffer_pool,b);
return;
Expand Down
2 changes: 2 additions & 0 deletions ww/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ void acquireUpdateLock(config_file_t *state)
{
hmutex_lock(&(state->guard));
}

void releaseUpdateLock(config_file_t *state)
{
hmutex_unlock(&(state->guard));
}

// only use if you acquired lock before
void unsafeCommitChanges(config_file_t *state)
{
Expand Down
1 change: 1 addition & 0 deletions ww/context_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ context_t *contextQueuePop(context_queue_t *self)
context_t *context = queue_pull_front(&self->q);
return context;
}

size_t contextQueueLen(context_queue_t *self)
{
return queue_size(&self->q);
Expand Down
3 changes: 3 additions & 0 deletions ww/idle_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct idle_table_s
hhybridmutex_t mutex;
uint64_t last_update_ms;
uintptr_t memptr;

} ATTR_ALIGNED_LINE_CACHE;

void idleCallBack(htimer_t *timer);
Expand Down Expand Up @@ -92,6 +93,7 @@ idle_item_t *newIdleItem(idle_table_t *self, hash_t key, void *userdata, ExpireC
hhybridmutex_unlock(&(self->mutex));
return item;
}

void keepIdleItemForAtleast(idle_table_t *self, idle_item_t *item, uint64_t age_ms)
{
if (item->removed)
Expand All @@ -104,6 +106,7 @@ void keepIdleItemForAtleast(idle_table_t *self, idle_item_t *item, uint64_t age_
heapq_idles_t_make_heap(&self->hqueue);
hhybridmutex_unlock(&(self->mutex));
}

idle_item_t *getIdleItemByHash(tid_t tid, idle_table_t *self, hash_t key)
{
hhybridmutex_lock(&(self->mutex));
Expand Down
2 changes: 2 additions & 0 deletions ww/managers/socket_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ static inline void incrementDistributeTid(void)
state->last_round_tid = 0;
}
}

static void distributeSocket(void *io, socket_filter_t *filter, uint16_t local_port)
{

Expand Down Expand Up @@ -653,6 +654,7 @@ static void listenTcpSinglePort(hloop_t *loop, socket_filter_t *filter, char *ho
}
filter->v6_dualstack = hio_localaddr(filter->listen_io)->sa_family == AF_INET6;
}

static void listenTcp(hloop_t *loop, uint8_t *ports_overlapped)
{
for (int ri = (kFilterLevels - 1); ri >= 0; ri--)
Expand Down
2 changes: 2 additions & 0 deletions ww/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum node_flags
// this node can be a chain head (begin of the chain)
kNodeFlagChainHead = (1 << 1)
};

typedef struct tunnel_metadata_s
{
int32_t version;
Expand All @@ -43,4 +44,5 @@ typedef struct node_s
tunnel_metadata_t metadata;
uint32_t refrenced;
bool route_starter;

} node_t;
9 changes: 4 additions & 5 deletions ww/tunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ typedef struct line_s
and it can contain a payload buffer, or be just a flag context
the only flag that also has a payload is `first` , other flags have no payload
*/
typedef struct context_s
{
Expand Down Expand Up @@ -408,9 +406,10 @@ static inline buffer_pool_t *getContextBufferPool(const context_t *const c)
return getWorkerBufferPool(c->line->tid);
}

// same as c->payload = NULL, this is necessary before destroying a context to prevent bugs, dose nothing on release
// build

/*
same as c->payload = NULL, this is necessary before destroying a context to prevent bugs, dose nothing on release
build
*/
static inline void dropContexPayload(context_t *const c)
{
#if defined(RELEASE)
Expand Down
Loading

0 comments on commit 0ef82e2

Please sign in to comment.