コード例 #1
0
ファイル: proxy-tcp-splice.c プロジェクト: jkasarherou/lbtk
static void tunnel_release (tunnel_t *t)
{
    channel_close(&t->front);
    channel_close(&t->back);
    tunnel_init(t);
    PREPEND_STRUCT(IDLE_STRUCT_NAME(tunnel_t),t);
}
コード例 #2
0
ファイル: proxy-tcp-splice.c プロジェクト: jkasarherou/lbtk
static tunnel_t * tunnel_reserve (proxy_t *proxy)
{
    tunnel_t *t = ACQUIRE_STRUCT_CALL(tunnel_t);
    t->proxy = proxy;
    tunnel_init(t);
    return t;
}
コード例 #3
0
ファイル: main.c プロジェクト: zaius/smart
int main(int argc, char **argv) {
	// Seed the random number generator
	srandom(time(NULL));

	// Set up signal handlers
	signal(SIGINT, sigterm);

	serial_init();
	tunnel_init();

	// Start the main loop
	while (quit == FALSE) {
		int result = 0;

		result = poll(fds, 2, 2500);

		if (result < 0) {
			// error in poll, warn
			warn("Poll Error");
			continue;
		}

		// timed out, continue the loop
		if (result == 0) {
			printf("timeout\n");
			continue;
		}

		if (fds[SERIAL_INDEX].revents != 0) {
			serial_event();
		}

		if (fds[TUNNEL_INDEX].revents != 0) {
			tunnel_event();
		}
	}
	// We must have received a signal, tidy up and exit
	printf("Exiting...\n");
	close(serial);
	close(tunnel);

	return 0;
}
コード例 #4
0
ファイル: app.c プロジェクト: FoxVK/DFMT
inline void app_init()
{
    debug_uart_init();
    static char * run = "\n\rReseted\n\r";
    debug_uart_write(run);
    
    tuner_init();
    tuner_audio_init();
    tuner_control_pwr(true);

    config.event_callback = usb_event;
    config.ct_request_callback = &app_usb_ct_handler;
    usb_init(&config);

    static Usb_audio_iface uai;
    audio_if = &uai;
    usb_audio_init(audio_if, 1, NULL);
    Usb_audio_add_ep(audio_if, USB_EP01, USB_EP_IN, app_usb_audio_td0_handler);   
    
    tunnel_init();
    
    static char *initd = "init done\n\r";  
    debug_uart_write(initd);
}
コード例 #5
0
ファイル: client.c プロジェクト: basil00/reqrypt
/*
 * Main entry point:
 */
int MAIN(int argc, char **argv)
{
    // First print GPL information:
    printf("%s %s [%s] Copyright (C) 2017 basil\n", PROGRAM_NAME_LONG,
        PROGRAM_VERSION, PLATFORM);
    puts("License GPLv3+: GNU GPL version 3 or later "
        "<http://gnu.org/licenses/gpl.html>.");
    puts("This is free software: you are free to change and redistribute it.");
    puts("There is NO WARRANTY, to the extent permitted by law.");
    putchar('\n');

    // Process options:
    options_init(argc, argv);

    // Initialise various components (order is important!).
    log_init();
    trace("changing to home directory %s", PROGRAM_DIR);
    chdir_home();
    trace("installing files (if required)");
    install_files();
    trace("initialising user configuration");
    config_init();
    trace("initialising tunnel management");
    tunnel_init();

    // Initialise the sockets library (if required on this platform).
    trace("initialising sockets");
    init_sockets();

    // Get number of threads.
    int num_threads =
        (options_get()->seen_num_threads?  options_get()->val_num_threads:
            NUM_THREADS_DEFAULT);
    if (num_threads < 1 || num_threads > NUM_THREADS_MAX)
    {
        error("unable to spawn %d threads; expected a number within the "
            "range 1..%u", num_threads, NUM_THREADS_MAX);
    }

    // Create configuration server thread.
    trace("launching configuration server thread");
    if (thread_lock_init(&config_lock))
    {
        error("unable to initialise global configuration lock");
    }
    thread_t config_thread;
    if (!options_get()->seen_no_ui &&
        thread_create(&config_thread, configuration_thread, NULL) != 0)
    {
        error("unable to create configuration server thread");
    }

    // Open the packet capture/injection device driver.
    trace("initialising packet capture");
    if (!options_get()->seen_no_capture)
    {
        init_capture();
    }

    // Open the tunnels.
    trace("initialising tunnels");
    tunnel_file_read();
    tunnel_open();

    // Go to sleep if we are not capturing packets.
    while (options_get()->seen_no_capture)
    {
        sleeptime(UINT64_MAX);
    }

    // Start worker threads.
    for (int i = 1; i < num_threads; i++)
    {
        thread_t work_thread;
        if (thread_create(&work_thread, worker_thread, NULL) != 0)
        {
            error("unable to create worker thread");
        }
    }
    worker_thread((void *)0);

    return EXIT_SUCCESS;
}