Exemple #1
0
static void interception_process(int fd)
{
    int                    diff, new_fd, i, pass_through_flag = 0;
    time_t                 now;
    unsigned long          packet_id;
    struct iphdr           *ip_header;
    struct msg_client_s    *c_msg;

    if(fd == msg_listen_sock){
        new_fd = accept(msg_listen_sock, NULL, NULL);   
        set_sock_no_delay(new_fd);
        if(new_fd != -1){
            select_server_add(new_fd);
        }
    }else if(fd == firewall_sock){
        packet_id = 0;
        ip_header = nl_firewall_recv(firewall_sock, &packet_id);
        if(ip_header != 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_header->daddr){
                    pass_through_flag = 1;
                    break;
                }
            }
            if(pass_through_flag){
                /* Pass through the firewall */
                dispose_netlink_packet(NF_ACCEPT, packet_id);   
            }else{
                router_update(ip_header);
                now  = time(0);
                diff = now - last_clean_time;
                if(diff > CHECK_INTERVAL){
                    route_delete_obsolete(now);
                    delay_table_delete_obsolete(now);
                    last_clean_time = now;
                }
                 /* Drop the packet */
                dispose_netlink_packet(NF_DROP, packet_id);     
            }
        }
    }else{
        c_msg = msg_server_recv(fd);
        if(c_msg){
            if(c_msg->type == CLIENT_ADD){
                tc_log_debug1(LOG_NOTICE, "add client router:%u", 
                        ntohs(c_msg->client_port));
                router_add(c_msg->client_ip, c_msg->client_port, fd);
            }else if(c_msg->type == CLIENT_DEL){
                tc_log_debug1(LOG_NOTICE, "del client router:%u", 
                        ntohs(c_msg->client_port));
                router_del(c_msg->client_ip, c_msg->client_port);
            }
        }else{
            close(fd);
            select_server_del(fd);
            log_info(LOG_NOTICE, "close sock:%d", fd);
        }
    }
}
Exemple #2
0
static void
tc_nl_check_cleaning()
{
    int      diff;
    time_t   now;

    now  = tc_time();
    diff = now - last_clean_time;
    if (diff > CHECK_INTERVAL) {
        route_delete_obsolete(now);
        last_clean_time = now;
    }
}
static void
tc_nl_check_cleaning()
{
    int      diff;
    time_t   now;

    now  = tc_time();
    diff = now - last_clean_time;
    if (diff > CHECK_INTERVAL) {
        tc_log_info(LOG_NOTICE, 0, "total response packets:%llu",
                tot_resp_packs);
        route_delete_obsolete(now);
        last_clean_time = now;
    }
}
Exemple #4
0
static void
tc_check_cleaning()
{
    int      diff;
    time_t   now;

    now  = tc_time();
    diff = now - last_clean_time;
    if (diff > CHECK_INTERVAL) {
        tc_log_info(LOG_NOTICE, 0, "total resp packets:%llu, all:%llu",
                tot_copy_resp_packs, tot_resp_packs);
#if (!TCPCOPY_SINGLE)  
        route_delete_obsolete(now);
#endif
        last_clean_time = now;
    }
}