コード例 #1
0
int main(int argc,char *argv[])
{
	printf("Starting razer blackwidow chroma daemon\n");
	#ifndef USE_DEBUGGING
		daemonize();
	#endif

	struct razer_daemon *daemon=NULL;
	if(!(daemon=daemon_open()))
	{
		printf("razer_bcd: error initializing daemon\n");
		return(1);
	}
	daemon_run(daemon);
    daemon_close(daemon);
}
コード例 #2
0
ファイル: hadm_main.c プロジェクト: forthewatch/xdm
int main(int argc, char **argv)
{
	struct daemon *daemon;
	struct config *cfg;
	int ret;

	/*
	   if(!check_root()) {
	   fprintf(stderr, "permission denied, root only\n");
	   exit(EXIT_FAILURE);
	   }
	 */
	if(argc < 3) {
		daemonize();
	}
	signal(SIGPIPE, SIG_IGN);

	ret = log_init(HADM_LOG_CONF, HADM_SERVER_LOG_CAT);
	if(ret < 0) {
		exit(EXIT_FAILURE);
	}

	cfg = load_config(CONFIG_FILE);
	if(cfg == NULL) {
		log_error("load config file failed, please check config file!");
		exit(EXIT_FAILURE);
	}

	daemon = create_daemon(cfg);
	if(daemon == NULL) {
		exit(EXIT_FAILURE);
	}

	if(init_daemon(daemon) < 0) {
		exit(EXIT_FAILURE);
	}

	daemon_run(daemon);

	return 0;
}
コード例 #3
0
ファイル: bforce.c プロジェクト: askovpen/binkleyforce
static int bforce_daemon(const s_bforce_opts *opts)
{
	int forkrc = fork();

	if( forkrc == -1 )
        {
		logerr("cannot run daemon: failed fork() call");
		return BFERR_FATALERROR;
	}
	else if( forkrc > 0 )
	{
		return BFERR_NOERROR;
	}

	/*
	 * We are inside a child process.
	 * Create new session and run daemon
	 */
	setsid();
	
	return daemon_run(opts->confname, opts->incname, opts->quit);
}
コード例 #4
0
int main(int argc,char *argv[])
{
	struct daemon_options options = parse_args(argc, argv);

	if(options.daemonize)
	{
		printf("Starting razer blackwidow chroma daemon as a daemon\n");
		daemonize(options.pid_file);
	} else {
		printf("Starting razer blackwidow chroma daemon in the foreground\n");
		if(options.pid_file != NULL)
		{
			write_pid_file(options.pid_file, getpid());
		}
	}

	struct razer_daemon *daemon=NULL;
	if(!(daemon=daemon_open()))
	{
		printf("razer_bcd: error initializing daemon\n");
		return(1);
	}
	if(options.mouse_input_file)
		daemon->chroma->sys_mouse_event_path = options.mouse_input_file;
	if(options.keyboard_input_file)
		daemon->chroma->sys_keyboard_event_path = options.keyboard_input_file;

	daemon_run(daemon);
	daemon_close(daemon);

	// Remove the PID file if we exit normally
	if(options.pid_file != NULL)
	{
		remove(options.pid_file);
		free(options.pid_file);
	}
}
コード例 #5
0
ファイル: core.c プロジェクト: TrainingProject/FINS-Framework
int main() {
	//###################################################################### //TODO get this from config file eventually
	//host interface
	my_host_mac_addr = 0x080027445566ull;
	my_host_ip_addr = IP4_ADR_P2H(192,168,1,20);
	my_host_mask = IP4_ADR_P2H(255,255,255,0);

	//loopback interface
	loopback_ip_addr = IP4_ADR_P2H(127,0,0,1);
	loopback_mask = IP4_ADR_P2H(255,0,0,0);

	//any
	any_ip_addr = IP4_ADR_P2H(0,0,0,0);
	//######################################################################

	sem_init(&control_serial_sem, 0, 1); //TODO remove after gen_control_serial_num() converted to RNG

	signal(SIGINT, termination_handler); //register termination handler

	// Start the driving thread of each module
	PRINT_DEBUG("Initialize Modules");
	switch_init(); //should always be first
	daemon_init(); //TODO improve how sets mac/ip
	interface_init();

	arp_init();
	arp_register_interface(my_host_mac_addr, my_host_ip_addr);

	ipv4_init();
	set_interface(my_host_ip_addr, my_host_mask);
	set_loopback(loopback_ip_addr, loopback_mask);

	icmp_init();
	tcp_init();
	udp_init();
	//rtm_init(); //TODO when updated/fully implemented

	pthread_attr_t fins_pthread_attr;
	pthread_attr_init(&fins_pthread_attr);

	PRINT_DEBUG("Run/start Modules");
	switch_run(&fins_pthread_attr);
	daemon_run(&fins_pthread_attr);
	interface_run(&fins_pthread_attr);
	arp_run(&fins_pthread_attr);
	ipv4_run(&fins_pthread_attr);
	icmp_run(&fins_pthread_attr);
	tcp_run(&fins_pthread_attr);
	udp_run(&fins_pthread_attr);
	//rtm_run(&fins_pthread_attr);

	//############################# //TODO custom test, remove later
	/*
	 if (0) {
	 char recv_data[4000];

	 while (1) {
	 gets(recv_data);

	 PRINT_DEBUG("Sending ARP req");

	 metadata *params_req = (metadata *) malloc(sizeof(metadata));
	 if (params_req == NULL) {
	 PRINT_ERROR("metadata alloc fail");
	 exit(-1);
	 }
	 metadata_create(params_req);

	 uint32_t dst_ip = IP4_ADR_P2H(192, 168, 1, 11);
	 //uint32_t dst_ip = IP4_ADR_P2H(172, 31, 50, 152);
	 uint32_t src_ip = IP4_ADR_P2H(192, 168, 1, 20);
	 //uint32_t src_ip = IP4_ADR_P2H(172, 31, 50, 160);

	 metadata_writeToElement(params_req, "dst_ip", &dst_ip, META_TYPE_INT32);
	 metadata_writeToElement(params_req, "src_ip", &src_ip, META_TYPE_INT32);

	 struct finsFrame *ff_req = (struct finsFrame*) malloc(sizeof(struct finsFrame));
	 if (ff_req == NULL) {
	 PRINT_ERROR("todo error");
	 //metadata_destroy(params_req);
	 exit(-1);
	 }

	 ff_req->dataOrCtrl = CONTROL;
	 ff_req->destinationID.id = ARP_ID;
	 ff_req->destinationID.next = NULL;
	 ff_req->metaData = params_req;

	 ff_req->ctrlFrame.senderID = IP_ID;
	 ff_req->ctrlFrame.serial_num = gen_control_serial_num();
	 ff_req->ctrlFrame.opcode = CTRL_EXEC;
	 ff_req->ctrlFrame.param_id = EXEC_ARP_GET_ADDR;

	 ff_req->ctrlFrame.data_len = 0;
	 ff_req->ctrlFrame.data = NULL;

	 arp_to_switch(ff_req); //doesn't matter which queue
	 }
	 }
	 //#############################
	 */

	while (1)
		;

	return (1);
}