Пример #1
0
static int do_client(CLI *c) {
    int result;

    if(init_local(c))
        return -1;
    if(!options.option.client && !c->opt->protocol) {
        /* Server mode and no protocol negotiation needed */
        if(init_ssl(c))
            return -1;
        if(init_remote(c))
            return -1;
    } else {
        if(init_remote(c))
            return -1;
        if(negotiate(c)<0) {
            s_log(LOG_ERR, "Protocol negotiations failed");
            return -1;
        }
        if(init_ssl(c))
            return -1;
    }
    result=transfer(c);
    s_log(LOG_NOTICE,
        "Connection %s: %d bytes sent to SSL, %d bytes sent to socket",
         result ? "reset" : "closed", c->ssl_bytes, c->sock_bytes);
    return result;
}
Пример #2
0
static void client_try(CLI * c)
{
	init_local(c);
	if (!c->opt->option.client) {
		init_ssl(c);
		init_remote(c);
	} else {
		init_remote(c);
		init_ssl(c);
	}
	transfer(c);
}
Пример #3
0
static void do_client(CLI *c) {
    init_local(c);
    if(!c->opt->option.client && !c->opt->protocol) {
        /* server mode and no protocol negotiation needed */
        init_ssl(c);
        init_remote(c);
    } else {
        init_remote(c);
        negotiate(c);
        init_ssl(c);
    }
    transfer(c);
}
Пример #4
0
static void client_try(CLI *c) {
    init_local(c);
    if(!c->opt->option.client && c->opt->protocol<0) {
        /* server mode and no protocol negotiation needed */
        init_ssl(c);
        init_remote(c);
    } else {
        protocol(c, PROTOCOL_PRE_CONNECT);
        init_remote(c);
        protocol(c, PROTOCOL_PRE_SSL);
        init_ssl(c);
        protocol(c, PROTOCOL_POST_SSL);
    }
    transfer(c);
}
Пример #5
0
int main(int argc, char **argv)
{
  open_log();

  char *d = xmalloc(100);
  time_t t = time(NULL);
  struct tm *tmp = localtime(&t);
  strftime(d, 99, "%c", tmp);

  log_msg("BEGIN LOG rs-mount %s", d);

  free(d);
  
  struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
  memset(&RS_CONFIG, 0, sizeof(struct rs_config));
  fuse_opt_parse(&args, &RS_CONFIG, rs_opts, NULL);

  REQUIRE_OPTION(base_url);
  REQUIRE_OPTION(token);

  RS_CONFIG.base_url_len = strlen(RS_CONFIG.base_url);
  RS_CONFIG.auth_header = xmalloc(strlen(RS_CONFIG.token) + 23);
  sprintf(RS_CONFIG.auth_header, "Authorization: Bearer %s", RS_CONFIG.token);

  curl_global_init(CURL_GLOBAL_ALL);
  init_remote();

  atexit(cleanup);

  return fuse_main(args.argc, args.argv, &rs_ops, NULL);
}
Пример #6
0
NOEXPORT void client_try(CLI *c) {
    init_local(c);
    if(!c->opt->option.client && c->opt->protocol<0
#ifndef OPENSSL_NO_TLSEXT
            && !c->opt->servername_list_head
#endif
            ) {
        /* server mode and no protocol negotiation needed */
        init_ssl(c);
        init_remote(c);
    } else { /* client mode or protocol negotiation enabled */
        protocol(c, PROTOCOL_PRE_CONNECT);
        init_remote(c);
        protocol(c, PROTOCOL_PRE_SSL);
        init_ssl(c);
        protocol(c, PROTOCOL_POST_SSL);
    }
    transfer(c);
}
Пример #7
0
/*
========================================================================
main:	This is the main entry point for the VirtualT application.
========================================================================
*/
int main(int argc, char **argv)
{
	if (process_args(argc, argv))	/* Parse command line args */
		return 1;

	setup_working_path(argv);	/* Create a working dir path */
	setup_unix_signals();		/* Setup Unix signal handling */

	// Added by JV for prefs
	init_pref();				/* load user Menu preferences */
	check_installation();		/* Test if install needs to be performed */
	load_setup_preferences();	/* Load user Peripheral setup preferences */
	load_memory_preferences();	/* Load user Memory setup preferences */
	load_remote_preferences();  /* Load user Remote Socket preferences */
	
	/* Perform initialization */
	init_mem();					/* Initialize Memory */
	init_io();					/* Initialize I/O structures */
	init_sound();				/* Initialize Sound system */
	init_display();				/* Initialize the Display */
	init_cpu();					/* Initialize the CPU */
	init_throttle_timer();		/* Initialize the throttle timer */
	init_remote();				/* Initialize the remote control */
	init_lpt();					/* Initialize the printer subsystem */
	init_other_windows();		/* Initialize other windows that were opened (memedit, regs, etc. */
	get_model_time();			/* Load the emulated time for current model */

	/* Perform Emulation */
	emulate();					/* Main emulation loop */

	/* Save RAM contents after emulation */
	save_ram();
	save_model_time();			/* Save the emulated time */

	/* Cleanup */
	deinit_io();				/* Deinitialize I/O */
	deinit_sound();				/* Deinitialize sound */
	deinit_lpt();				/* Deinitialize the printer */
	deinit_throttle_timer();	/* Deinitialize the throttle timer */
	deinit_display();			/* Deinitialze and free the main window */
	free_mem();					/* Free memory used by ReMem and/or Rampac */

	return 0;
}
Пример #8
0
Файл: main.c Проект: Raphy/zappy
int		main(int argc, char **argv)
{
  t_zc		zc;
  t_remote	remote;

  kikoo_header();
  if (argc != 3)
    exit(printf("Usage: %s [host] [port]\n", argv[0]));
  if (init_zappy(&zc, argv[1], atoi(argv[2])) == RET_FAILURE ||
      init_remote(&remote, &zc) == RET_FAILURE)
    {
      remote_dtor(&remote);
      zc_dtor(&zc);
      return (EXIT_FAILURE);
    }
  zc_main(&zc);
  zc_dtor(&zc);
  remote_dtor(&remote);
  return (EXIT_SUCCESS);
}
bool
SCI_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
{
  SocketOutputStream s_output(sockfd);
  SocketInputStream s_input(sockfd);
  char buf[256];
  DBUG_ENTER("SCI_Transporter::connect_server_impl");

  if (!init_local()) {
    NDB_CLOSE_SOCKET(sockfd);
    DBUG_RETURN(false);
  }
  // Send ok to client
  s_output.println("sci server 1 ok");

  // Wait for ok from client
  if (s_input.gets(buf, 256) == 0) {
    DBUG_PRINT("error", ("No response from client in SCI"));
    NDB_CLOSE_SOCKET(sockfd);
    DBUG_RETURN(false);
  }

  if (!init_remote()) {
    NDB_CLOSE_SOCKET(sockfd);
    DBUG_RETURN(false);
  }
  // Send ok to client
  s_output.println("sci server 2 ok");
  // Wait for ok from client
  if (s_input.gets(buf, 256) == 0) {
    DBUG_PRINT("error", ("No second response from client in SCI"));
    NDB_CLOSE_SOCKET(sockfd);
    DBUG_RETURN(false);
  }

  NDB_CLOSE_SOCKET(sockfd);
  DBUG_PRINT("info", ("Successfully connected server to node %d",
              remoteNodeId));
  DBUG_RETURN(true);
}
Пример #10
0
void
hastd_secondary(struct hast_resource *res, struct nv *nvin)
{
	sigset_t mask;
	pthread_t td;
	pid_t pid;
	int error, mode, debuglevel;

	/*
	 * Create communication channel between parent and child.
	 */
	if (proto_client(NULL, "socketpair://", &res->hr_ctrl) < 0) {
		KEEP_ERRNO((void)pidfile_remove(pfh));
		pjdlog_exit(EX_OSERR,
		    "Unable to create control sockets between parent and child");
	}
	/*
	 * Create communication channel between child and parent.
	 */
	if (proto_client(NULL, "socketpair://", &res->hr_event) < 0) {
		KEEP_ERRNO((void)pidfile_remove(pfh));
		pjdlog_exit(EX_OSERR,
		    "Unable to create event sockets between child and parent");
	}

	pid = fork();
	if (pid < 0) {
		KEEP_ERRNO((void)pidfile_remove(pfh));
		pjdlog_exit(EX_OSERR, "Unable to fork");
	}

	if (pid > 0) {
		/* This is parent. */
		proto_close(res->hr_remotein);
		res->hr_remotein = NULL;
		proto_close(res->hr_remoteout);
		res->hr_remoteout = NULL;
		/* Declare that we are receiver. */
		proto_recv(res->hr_event, NULL, 0);
		/* Declare that we are sender. */
		proto_send(res->hr_ctrl, NULL, 0);
		res->hr_workerpid = pid;
		return;
	}

	gres = res;
	mode = pjdlog_mode_get();
	debuglevel = pjdlog_debug_get();

	/* Declare that we are sender. */
	proto_send(res->hr_event, NULL, 0);
	/* Declare that we are receiver. */
	proto_recv(res->hr_ctrl, NULL, 0);
	descriptors_cleanup(res);

	descriptors_assert(res, mode);

	pjdlog_init(mode);
	pjdlog_debug_set(debuglevel);
	pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
	setproctitle("%s (%s)", res->hr_name, role2str(res->hr_role));

	PJDLOG_VERIFY(sigemptyset(&mask) == 0);
	PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);

	/* Error in setting timeout is not critical, but why should it fail? */
	if (proto_timeout(res->hr_remotein, 2 * HAST_KEEPALIVE) < 0)
		pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");
	if (proto_timeout(res->hr_remoteout, res->hr_timeout) < 0)
		pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");

	init_local(res);
	init_environment();

	if (drop_privs(res) != 0)
		exit(EX_CONFIG);
	pjdlog_info("Privileges successfully dropped.");

	/*
	 * Create the control thread before sending any event to the parent,
	 * as we can deadlock when parent sends control request to worker,
	 * but worker has no control thread started yet, so parent waits.
	 * In the meantime worker sends an event to the parent, but parent
	 * is unable to handle the event, because it waits for control
	 * request response.
	 */
	error = pthread_create(&td, NULL, ctrl_thread, res);
	PJDLOG_ASSERT(error == 0);

	init_remote(res, nvin);
	event_send(res, EVENT_CONNECT);

	error = pthread_create(&td, NULL, recv_thread, res);
	PJDLOG_ASSERT(error == 0);
	error = pthread_create(&td, NULL, disk_thread, res);
	PJDLOG_ASSERT(error == 0);
	(void)send_thread(res);
}
Пример #11
0
static unsigned int detect_key(unsigned int suspend_from)
{
	int exit_reason = 0;
	unsigned int time_out = readl(AO_DEBUG_REG2);
	unsigned time_out_ms = time_out*100;
	unsigned *irq = (unsigned *)SECURE_TASK_SHARE_IRQ;
	/* unsigned *wakeup_en = (unsigned *)SECURE_TASK_RESPONSE_WAKEUP_EN; */

	/* setup wakeup resources*/
	/*auto suspend: timerA 10ms resolution*/
	if (time_out_ms != 0)
		wakeup_timer_setup();

	init_remote();
#ifdef CONFIG_CEC_WAKEUP
	if (hdmi_cec_func_config & 0x1) {
		remote_cec_hw_reset();
		cec_node_init();
	}
#endif

	/* *wakeup_en = 1;*/
	do {
		switch (*irq) {
#ifdef CONFIG_CEC_WAKEUP
		case IRQ_AO_CEC_NUM:
			if (suspend_from == SYS_POWEROFF)
				break;
			if (cec_msg.log_addr) {
				if (hdmi_cec_func_config & 0x1) {
					cec_handler();
					if (cec_msg.cec_power == 0x1) {
						/*cec power key*/
						exit_reason = CEC_WAKEUP;
						break;
					}
				}
			} else if (hdmi_cec_func_config & 0x1)
				cec_node_init();
		break;
#endif
		case IRQ_TIMERA_NUM:
			if (time_out_ms != 0)
				time_out_ms--;
			if (time_out_ms == 0) {
				wakeup_timer_clear();
				exit_reason = AUTO_WAKEUP;
			}
			break;

		case IRQ_AO_IR_DEC_NUM:
			if (remote_detect_key())
				exit_reason = REMOTE_WAKEUP;
			break;

		default:
			break;
		}
		*irq = 0xffffffff;
		if (exit_reason)
			break;
		else
			asm volatile("wfi");
	} while (1);

	return exit_reason;
}
Пример #12
0
/*
============================================================================
This routine applies the current settings in the dialog box and calls the
remote API functions to setup and teardown the socket interface.  It is
called by the OK button also.
============================================================================
*/
static void cb_sockdlg_apply(Fl_Widget* w, void*)
{
	int		port_num = 0, listen_port;
	int		telnet;
	int		enabled;

	// ==============================================
	// Get Port Number & telnet flag
	// ==============================================
	if (sockdlg_ctrl.pPortNumber->value() != NULL)
		port_num = atoi(sockdlg_ctrl.pPortNumber->value());
	telnet = sockdlg_ctrl.pTelnet->value();
	enabled = sockdlg_ctrl.pEnable->value();

	// Test if the socket is enabled but the port is invalid
	if (enabled && ((port_num <= 0) || (port_num >= 65536)))
	{
		fl_alert("Please provide a port number between 1 and 65535");
		return;
	}

	// Get the remote socket status
	listen_port = get_remote_listen_port();

	// Test if the socket is enabled and the user want's it disabled
	if (!enabled)
	{
		// Check if the socket is currently active and shutdown if it is
		if (listen_port != 0)
			deinit_remote();
	}

	// Test if we are enabling the socket for a different port number
	if (enabled && listen_port && (listen_port != port_num))
		deinit_remote();

	// Set the new port parameters
	set_remote_telnet(telnet);
	if (enabled)
		set_remote_port(port_num);
	else
		set_remote_port(0);
	enable_remote(enabled);

	// Update preferences
	virtualt_prefs.set("SocketPort", port_num);
	virtualt_prefs.set("SocketTelnetMode", telnet);
	virtualt_prefs.set("SocketEnabled", enabled);

	// Now enable the socket if the socket number is different
	if (enabled && (listen_port != port_num))
	{
		init_remote();
	}
	
	// If the apply button was pressed, then wait a bit for the port
	// status to change in the remote thread, then update the 
	// port status
	if (w == sockdlg_ctrl.pApply)
	{
		SLEEP(500);
		update_port_status();
	}
}
Пример #13
0
static unsigned int detect_key(unsigned int suspend_from)
{
	int exit_reason = 0;
	unsigned int time_out = readl(AO_DEBUG_REG2);
	unsigned time_out_ms = time_out*100;
	unsigned char adc_key_cnt = 0;
	unsigned *irq = (unsigned *)WAKEUP_SRC_IRQ_ADDR_BASE;
	/* unsigned *wakeup_en = (unsigned *)SECURE_TASK_RESPONSE_WAKEUP_EN; */

	/* start timer and enable adc*/
	reset_ao_timera();
	saradc_enable();
	/* setup wakeup resources*/
	/*auto suspend: timerA 10ms resolution*/
	if (time_out_ms != 0)
		wakeup_timer_setup();
	saradc_enable();
	reset_ao_timera();
	init_remote();
#ifdef CONFIG_CEC_WAKEUP
	if (hdmi_cec_func_config & 0x1) {
		remote_cec_hw_reset();
		cec_node_init();
	}
#endif

	/* *wakeup_en = 1;*/
	do {
#ifdef CONFIG_CEC_WAKEUP
		if (irq[IRQ_AO_CEC] == IRQ_AO_CEC_NUM) {
			irq[IRQ_AO_CEC] = 0xFFFFFFFF;
//			if (suspend_from == SYS_POWEROFF)
//				continue;
			if (cec_msg.log_addr) {
				if (hdmi_cec_func_config & 0x1) {
					cec_handler();
					if (cec_msg.cec_power == 0x1) {
						/*cec power key*/
						exit_reason = CEC_WAKEUP;
						break;
					}
				}
			} else if (hdmi_cec_func_config & 0x1)
				cec_node_init();
		}
#endif
		if (irq[IRQ_TIMERA] == IRQ_TIMERA_NUM) {
			irq[IRQ_TIMERA] = 0xFFFFFFFF;
			/*uart_puts("timera ...\n");*/
			if (time_out_ms != 0)
				time_out_ms--;
			if (time_out_ms == 0) {
				wakeup_timer_clear();
				exit_reason = AUTO_WAKEUP;
			}
		}
		if (irq[IRQ_AO_TIMERA] == IRQ_AO_TIMERA_NUM) {
			irq[IRQ_AO_TIMERA] = 0xFFFFFFFF;
			if (check_adc_key_resume()) {
				adc_key_cnt++;
				/*using variable 'adc_key_cnt' to eliminate the dithering of the key*/
				if (2 == adc_key_cnt)
					exit_reason = POWER_KEY_WAKEUP;
			} else {
				adc_key_cnt = 0;
			}
		}
		if (irq[IRQ_AO_IR_DEC] == IRQ_AO_IR_DEC_NUM) {
			irq[IRQ_AO_IR_DEC] = 0xFFFFFFFF;
				if (remote_detect_key())
					exit_reason = REMOTE_WAKEUP;
		}
		if (irq[IRQ_ETH_PHY] == IRQ_ETH_PHY_NUM) {
			irq[IRQ_ETH_PHY] = 0xFFFFFFFF;
			exit_reason = ETH_PHY_WAKEUP;
		}
		if (exit_reason)
			break;
		else
			asm volatile("wfi");
	} while (1);
	restore_ao_timer();
	saradc_disable();
	return exit_reason;
}