-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
155 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,43 @@ | ||
#pragma once | ||
#include "buffer_pool.h" | ||
#include "master_pool.h" | ||
#include "hloop.h" | ||
#include "hplatform.h" | ||
#include "hthread.h" | ||
#include <stdint.h> | ||
|
||
#define TUN_LOG_EVERYTHING true | ||
|
||
#ifdef OS_UNIX | ||
typedef int tun_handle_t; | ||
#else | ||
typedef void *tun_handle_t; // Windows handle (void* can hold HANDLE) | ||
#endif | ||
|
||
struct tun_device_s; | ||
|
||
typedef void (*TunReadEventHandle)(struct tun_device_s *tdev, void *userdata, shift_buffer_t *buf, tid_t tid); | ||
|
||
typedef struct tun_device_s | ||
{ | ||
char *name; | ||
char *name; | ||
// hio_t *io; not using fd multiplexer | ||
tun_handle_t handle; | ||
hthread_t readThread; | ||
hthread_t writeThread; | ||
atomic_bool stop; | ||
atomic_bool up; | ||
|
||
tun_handle_t handle; | ||
hthread_t readThread; | ||
hthread_t writeThread; | ||
hthread_routine routine_reader; | ||
hthread_routine routine_writer; | ||
master_pool_t *reader_message_pool; | ||
generic_pool_t *reader_shift_buffer_pool; | ||
buffer_pool_t *reader_buffer_pool; | ||
struct hchan_s *writer_buffer_channel; | ||
TunReadEventHandle read_event_callback; | ||
void *userdata; | ||
atomic_bool notstop; | ||
atomic_bool up; | ||
|
||
} tun_device_t; | ||
|
||
tun_device_t *createTunDevice(const char *name, bool offload); | ||
tun_device_t *createTunDevice(const char *name, bool offload, void *userdata, TunReadEventHandle cb); | ||
void bringTunDeviceUP(tun_device_t *tdev); | ||
void writeToTunDevce(tun_device_t *tdev, shift_buffer_t *buf); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters