|
|
|
|
@ -12,35 +12,6 @@
|
|
|
|
|
|
|
|
|
|
#define DEBUG_CATEGORY_ETCP_API DEBUG_CATEGORY_ETCP |
|
|
|
|
|
|
|
|
|
void etcp_conn_set_init_cbk(struct ETCP_CONN* e, etcp_cbk_fn fn, void* arg) { |
|
|
|
|
if (!e) return; |
|
|
|
|
struct etcp_cbk_entry* entry = e->init_cbks; |
|
|
|
|
while (entry) { struct etcp_cbk_entry* next = entry->next; u_free(entry); entry = next; } |
|
|
|
|
e->init_cbks = NULL; |
|
|
|
|
if (fn) etcp_conn_add_init_cbk(e, fn, arg); |
|
|
|
|
} |
|
|
|
|
void etcp_conn_set_up_cbk(struct ETCP_CONN* e, etcp_cbk_fn fn, void* arg) { |
|
|
|
|
if (!e) return; |
|
|
|
|
struct etcp_cbk_entry* entry = e->up_cbks; |
|
|
|
|
while (entry) { struct etcp_cbk_entry* next = entry->next; u_free(entry); entry = next; } |
|
|
|
|
e->up_cbks = NULL; |
|
|
|
|
if (fn) etcp_conn_add_up_cbk(e, fn, arg); |
|
|
|
|
} |
|
|
|
|
void etcp_conn_set_down_cbk(struct ETCP_CONN* e, etcp_cbk_fn fn, void* arg) { |
|
|
|
|
if (!e) return; |
|
|
|
|
struct etcp_cbk_entry* entry = e->down_cbks; |
|
|
|
|
while (entry) { struct etcp_cbk_entry* next = entry->next; u_free(entry); entry = next; } |
|
|
|
|
e->down_cbks = NULL; |
|
|
|
|
if (fn) etcp_conn_add_down_cbk(e, fn, arg); |
|
|
|
|
} |
|
|
|
|
void etcp_set_new_conn_cbk(struct UTUN_INSTANCE* inst, etcp_cbk_fn fn, void* arg) { |
|
|
|
|
if (!inst) return; |
|
|
|
|
struct etcp_cbk_entry* entry = inst->new_conn_cbks; |
|
|
|
|
while (entry) { struct etcp_cbk_entry* next = entry->next; u_free(entry); entry = next; } |
|
|
|
|
inst->new_conn_cbks = NULL; |
|
|
|
|
if (fn) etcp_add_new_conn_cbk(inst, fn, arg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void etcp_cbk_add_to_chain(struct etcp_cbk_entry** head, etcp_cbk_fn fn, void* arg) { |
|
|
|
|
if (!head || !fn) return; |
|
|
|
|
struct etcp_cbk_entry* e = u_malloc(sizeof(struct etcp_cbk_entry)); |
|
|
|
|
@ -89,14 +60,6 @@ static void etcp_status_cbk_remove_chain(struct etcp_status_cbk_entry** head, et
|
|
|
|
|
} |
|
|
|
|
void etcp_add_conn_status_cbk(struct UTUN_INSTANCE* inst, etcp_conn_status_fn fn, void* arg) { if (inst) etcp_status_cbk_add_chain(&inst->conn_status_cbks, fn, arg); } |
|
|
|
|
void etcp_remove_conn_status_cbk(struct UTUN_INSTANCE* inst, etcp_conn_status_fn fn, void* arg) { if (inst) etcp_status_cbk_remove_chain(&inst->conn_status_cbks, fn, arg); } |
|
|
|
|
void etcp_set_conn_status_cbk(struct UTUN_INSTANCE* inst, etcp_conn_status_fn fn, void* arg) { |
|
|
|
|
if (!inst) return; |
|
|
|
|
struct etcp_status_cbk_entry* entry = inst->conn_status_cbks; |
|
|
|
|
while (entry) { struct etcp_status_cbk_entry* next = entry->next; u_free(entry); entry = next; } |
|
|
|
|
inst->conn_status_cbks = NULL; |
|
|
|
|
if (fn) etcp_status_cbk_add_chain(&inst->conn_status_cbks, fn, arg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void etcp_set_routing_exchange_state(struct ETCP_CONN* conn, uint8_t new_state) { |
|
|
|
|
if (!conn) return; |
|
|
|
|
conn->routing_exchange_active = new_state; |
|
|
|
|
|