int tcp_parse(const tcp_head_t* tcp, uint32_t sip, uint32_t dip, uint16_t tcpbytes) { int ret; // tcp checksum if (is_local_address(sip)) { ret = _tcp_checksum(tcp, sip, dip, tcpbytes); if (ret < 0) { return ret; } } // tcp head option ret = _tcp_head_option(tcp, sip, dip); if (ret < 0) { return ret; } // tcpp link link_key_t key; link_key_init(&key, sip, dip, ntohs(tcp->sport), ntohs(tcp->dport)); struct link_value_t* val = link_find_insert(&key, is_local_address(sip)); if (!val) return GAZE_TCP_LINK_FAIL; // tcp flag ret = _tcp_flag(tcp, &key, val, tcpbytes); if (ret < 0) { return ret; } // tcp finish ret = link_value_is_finish(val); if (ret == 0) { link_erase(&key); } PRINTF("\n\n"); return GAZE_OK; }
static void restor_hanlder(void) { sigaction(SIGALRM, &old_act, NULL); sigprocmask(SIG_SETMASK, &old_mask, NULL); link_erase(tim_link); free(num_bit); pthread_mutex_destroy(&mut_init); pthread_mutex_destroy(&mut_numb); }