Skip to content

Commit

Permalink
reformat / name update
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Aug 15, 2024
1 parent 413e4bb commit c09e109
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 38 deletions.
12 changes: 6 additions & 6 deletions ww/devices/capture/capture_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,15 @@ capture_device_t *createCaptureDevice(const char *name, uint32_t queue_number, v
LOGE("CaptureDevice: unable to set netfilter queue maximum length to %u", kQueueLen);
}

generic_pool_t *sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile,
generic_pool_t *reader_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile,
allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle);
buffer_pool_t *bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small,
sb_pool, GSTATE.ram_profile);
buffer_pool_t *reader_bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small,
reader_sb_pool, GSTATE.ram_profile);

generic_pool_t *writer_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, 1,
allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle);
buffer_pool_t *writer_bpool =
createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, sb_pool, 1);
createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, writer_sb_pool, 1);

capture_device_t *cdev = globalMalloc(sizeof(capture_device_t));

Expand All @@ -464,12 +464,12 @@ capture_device_t *createCaptureDevice(const char *name, uint32_t queue_number, v
.routine_writer = routineWriteToCapture,
.socket = socket_netfilter,
.queue_number = queue_number,
.reader_shift_buffer_pool = sb_pool,
.reader_shift_buffer_pool = reader_sb_pool,
.read_event_callback = cb,
.userdata = userdata,
.writer_buffer_channel = hchanOpen(sizeof(void *), kCaptureWriteChannelQueueMax),
.reader_message_pool = newMasterPoolWithCap(kMasterMessagePoolCap),
.reader_buffer_pool = bpool,
.reader_buffer_pool = reader_bpool,
.writer_shift_buffer_pool = writer_sb_pool,
.writer_buffer_pool = writer_bpool};

Expand Down
23 changes: 12 additions & 11 deletions ww/devices/raw/raw_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,26 @@ raw_device_t *createRawDevice(const char *name, uint32_t mark, void *userdata, R

raw_device_t *rdev = globalMalloc(sizeof(raw_device_t));

generic_pool_t *sb_pool = NULL;
buffer_pool_t *bpool = NULL;
master_pool_t *mpool = NULL;
generic_pool_t *reader_sb_pool = NULL;
buffer_pool_t *reader_bpool = NULL;
master_pool_t *reader_message_pool = NULL;
if (cb != NULL)
{
// if the user really wanted to read from raw socket
sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile,
reader_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile,
allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle);
bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, sb_pool,
reader_bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, reader_sb_pool,
GSTATE.ram_profile);
mpool = newMasterPoolWithCap(kMasterMessagePoolCap);
reader_message_pool = newMasterPoolWithCap(kMasterMessagePoolCap);

installMasterPoolAllocCallbacks(mpool, allocRawMsgPoolHandle, destroyRawMsgPoolHandle);
installMasterPoolAllocCallbacks(reader_message_pool, allocRawMsgPoolHandle, destroyRawMsgPoolHandle);
}


generic_pool_t *writer_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, GSTATE.ram_profile,
allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle);
buffer_pool_t *writer_bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large,
GSTATE.masterpool_buffer_pools_small, sb_pool, GSTATE.ram_profile);
GSTATE.masterpool_buffer_pools_small, writer_sb_pool, GSTATE.ram_profile);

*rdev = (raw_device_t) {.name = strdup(name),
.running = false,
Expand All @@ -241,12 +242,12 @@ raw_device_t *createRawDevice(const char *name, uint32_t mark, void *userdata, R
.routine_writer = routineWriteToRaw,
.socket = rsocket,
.mark = mark,
.reader_shift_buffer_pool = sb_pool,
.reader_shift_buffer_pool = reader_sb_pool,
.read_event_callback = cb,
.userdata = userdata,
.writer_buffer_channel = hchanOpen(sizeof(void *), kRawWriteChannelQueueMax),
.reader_message_pool = mpool,
.reader_buffer_pool = bpool,
.reader_message_pool = reader_message_pool,
.reader_buffer_pool = reader_bpool,
.writer_shift_buffer_pool = writer_sb_pool,
.writer_buffer_pool = writer_bpool};

Expand Down
12 changes: 6 additions & 6 deletions ww/devices/tun/tun_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,15 @@ tun_device_t *createTunDevice(const char *name, bool offload, void *userdata, Tu
return NULL;
}

generic_pool_t *sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile,
generic_pool_t *reader_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile,
allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle);
buffer_pool_t *bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small,
sb_pool, (0) + GSTATE.ram_profile);
buffer_pool_t *reader_bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small,
reader_sb_pool, (0) + GSTATE.ram_profile);

generic_pool_t *writer_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, 1,
allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle);
buffer_pool_t *writer_bpool =
createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, sb_pool, 1);
createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, writer_sb_pool, 1);

tun_device_t *tdev = globalMalloc(sizeof(tun_device_t));

Expand All @@ -338,9 +338,9 @@ tun_device_t *createTunDevice(const char *name, bool offload, void *userdata, Tu
.read_event_callback = cb,
.userdata = userdata,
.writer_buffer_channel = hchanOpen(sizeof(void *), kTunWriteChannelQueueMax),
.reader_shift_buffer_pool = sb_pool,
.reader_shift_buffer_pool = reader_sb_pool,
.reader_message_pool = newMasterPoolWithCap(kMasterMessagePoolCap),
.reader_buffer_pool = bpool,
.reader_buffer_pool = reader_bpool,
.writer_shift_buffer_pool = writer_sb_pool,
.writer_buffer_pool = writer_bpool

Expand Down
27 changes: 12 additions & 15 deletions ww/ww.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,24 @@ static void initalizeWorker(worker_t *worker, tid_t tid)
{
*worker = (worker_t) {.tid = tid};

worker->context_pool = newGenericPoolWithCap(GSTATE.masterpool_context_pools, (16) + GSTATE.ram_profile,
allocContextPoolHandle, destroyContextPoolHandle);
GSTATE.shortcut_context_pools[tid] = getWorker(tid)->context_pool;

worker->line_pool = newGenericPoolWithCap(GSTATE.masterpool_line_pools, (8) + GSTATE.ram_profile,
allocLinePoolHandle, destroyLinePoolHandle);
GSTATE.shortcut_line_pools[tid] = getWorker(tid)->line_pool;

worker->loop = hloop_new(HLOOP_FLAG_AUTO_FREE, worker->buffer_pool, tid);
worker->context_pool = newGenericPoolWithCap(GSTATE.masterpool_context_pools, (16) + GSTATE.ram_profile,
allocContextPoolHandle, destroyContextPoolHandle);
worker->line_pool = newGenericPoolWithCap(GSTATE.masterpool_line_pools, (8) + GSTATE.ram_profile,
allocLinePoolHandle, destroyLinePoolHandle);
worker->pipeline_msg_pool = newGenericPoolWithCap(GSTATE.masterpool_pipeline_msg_pools, (8) + GSTATE.ram_profile,
allocPipeLineMsgPoolHandle, destroyPipeLineMsgPoolHandle);
GSTATE.shortcut_pipeline_msg_pools[tid] = getWorker(tid)->pipeline_msg_pool;

worker->shift_buffer_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile,
allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle);
GSTATE.shortcut_shift_buffer_pools[tid] = getWorker(tid)->shift_buffer_pool;

worker->buffer_pool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small,
worker->shift_buffer_pool, (0) + GSTATE.ram_profile);
GSTATE.shortcut_buffer_pools[tid] = getWorker(tid)->buffer_pool;

worker->loop = hloop_new(HLOOP_FLAG_AUTO_FREE, worker->buffer_pool, tid);
GSTATE.shortcut_loops[tid] = getWorker(tid)->loop;
GSTATE.shortcut_context_pools[tid] = worker->context_pool;
GSTATE.shortcut_line_pools[tid] = worker->line_pool;
GSTATE.shortcut_pipeline_msg_pools[tid] = worker->pipeline_msg_pool;
GSTATE.shortcut_shift_buffer_pools[tid] = worker->shift_buffer_pool;
GSTATE.shortcut_buffer_pools[tid] = worker->buffer_pool;
GSTATE.shortcut_loops[tid] = worker->loop;
}

static void runWorker(worker_t *worker)
Expand Down Expand Up @@ -188,6 +184,7 @@ void createWW(const ww_construction_data_t init_data)
GSTATE.signal_manager = createSignalManager();
startSignalManager();
}

// [Section] setup SocketMangager
{
GSTATE.socekt_manager = createSocketManager();
Expand Down

0 comments on commit c09e109

Please sign in to comment.