static int tc_nl_event_process(tc_event_t *rev) { int i, pass_through_flag = 0; char buffer[65535]; unsigned long packet_id; tc_ip_header_t *ip_hdr; packet_id = 0; if (tc_nl_socket_recv(rev->fd, buffer, 65535) == TC_ERROR) { return TC_ERROR; } ip_hdr = tc_nl_ip_header(buffer); packet_id = tc_nl_packet_id(buffer); if (ip_hdr != NULL) { /* check if it is the valid user to pass through firewall */ for (i = 0; i < srv_settings.passed_ips.num; i++) { if (srv_settings.passed_ips.ips[i] == ip_hdr->daddr) { pass_through_flag = 1; break; } } if (pass_through_flag) { #if (INTERCEPT_THREAD) put_nl_verdict_to_pool(rev->fd, NF_ACCEPT, packet_id); #else /* pass through the firewall */ dispose_netlink_packet(rev->fd, NF_ACCEPT, packet_id); #endif } else { tot_resp_packs++; #if (INTERCEPT_THREAD) /* put response packet header to pool*/ put_resp_header_to_pool(ip_hdr); /* drop the packet */ put_nl_verdict_to_pool(rev->fd, NF_DROP, packet_id); #else router_update(ip_hdr); tc_nl_check_cleaning(); /* drop the packet */ dispose_netlink_packet(rev->fd, NF_DROP, packet_id); #endif } } return TC_OK; }
static void * interception_process_msg(void *tid) { int len; char resp[65536]; tc_ip_header_t *ip_hdr; for (;;) { ip_hdr = get_resp_ip_hdr_from_pool(resp, &len); if (ip_hdr == NULL) { tc_log_info(LOG_WARN, 0, "ip header is null"); } router_update(ip_hdr, len); tc_nl_check_cleaning(); } return NULL; }