Example #1
0
/* Dispose one event*/
void dispose_event(int fd)
{
    struct msg_server_s *msg;

    event_cnt++;
    if(fd == raw_sock){
        retrieve_raw_sockets(fd);
    }else{
        msg = msg_client_recv(fd);
        if(NULL == msg ){
            fprintf(stderr, "NULL msg :\n");
            log_info(LOG_ERR, "NULL msg from msg_client_recv");
            exit(EXIT_FAILURE);
        }   
        process((char*)msg, REMOTE);
    }   
#if (TCPCOPY_OFFLINE)
    if(!read_pcap_over){
        log_info(LOG_DEBUG, "send_packets_from_pcap");
        send_packets_from_pcap(0);
    }
#endif
    if((event_cnt%1000000) == 0){
        check_resource_usage();
    }
}
Example #2
0
void
tcp_copy_release_resources(void)
{
#if (TC_PCAP)
    int i;
#endif 
    tc_log_info(LOG_WARN, 0, "sig %d received", tc_over); 

    tc_output_stat();

    tc_dest_sess_table();

    check_resource_usage(NULL);
#if (TC_PLUGIN)
    if (clt_settings.plugin && clt_settings.plugin->exit_module) {
        clt_settings.plugin->exit_module(&clt_settings);
    }
#endif

    tc_event_loop_finish(&event_loop);
    tc_log_info(LOG_NOTICE, 0, "tc_event_loop_finish over");

#if (TC_DIGEST)
    tc_destroy_sha1();
    tc_destroy_digests();
#endif

#if (TC_PCAP)
    for (i = 0; i < clt_settings.devices.device_num; i++) {
        if (clt_settings.devices.device[i].pcap != NULL) {
            pcap_close(clt_settings.devices.device[i].pcap);
            clt_settings.devices.device[i].pcap = NULL;
        }
    }
#endif

#if (TC_OFFLINE)
    if (clt_settings.pcap != NULL) {
        pcap_close(clt_settings.pcap);
        clt_settings.pcap = NULL;
    }
#endif

    if (tc_raw_socket_out > 0) {
        tc_socket_close(tc_raw_socket_out);
        tc_raw_socket_out = TC_INVALID_SOCK;
    }

#if (TC_PCAP_SND)
    tc_pcap_over();
#endif
    tc_destroy_pool(clt_settings.pool);

    tc_log_end();
}
Example #3
0
/* Dispose one event*/
void dispose_event(int fd)
{
    event_cnt++;
    if (fd == raw_sock){
        retrieve_raw_sockets(fd);
    }else{
        log_info(LOG_WARN, "source from other");
    }   
#if (UDPCOPY_OFFLINE)
    if (!read_pcap_over){
        log_info(LOG_DEBUG, "send_packets_from_pcap");
        send_packets_from_pcap(0);
    }
#endif
    if ((event_cnt%1000000) == 0){
        check_resource_usage();
    }
}