Beispiel #1
0
/* nas task entry */
int
nas_init(int argc, char *argv[])
{
	nas_wksp_t *nwksp = NULL;

	/* alloc nas/wpa work space */
	if (!(nwksp = nas_wksp_alloc_workspace())) {
		NASMSG("Unable to allocate memory. Quitting...\n");
		goto exit0;
	}

	/* init nas/wpa work space */
	if (nas_wksp_parse_cmd_line(argc, argv, nwksp)) {
		NASMSG("Command line parsing error. Quitting...\n");
		goto exit1;
	}
	if (!nwksp->nwcbs) {
		NASMSG("No interface specified. Quitting...\n");
		goto exit1;
	}

	/* init nas */
	if (nas_wksp_init(nwksp)) {
		NASMSG("Unable to initialize NAS. Quitting...\n");
		goto exit1;
	}
	goto exit0;

	/* error handling */
exit1:
	nas_wksp_free_workspace(nwksp);
exit0:
	return 0;
}
Beispiel #2
0
/* service main entry */
int
main(int argc, char *argv[])
{
	/* display usage if nothing is specified */
	if (argc == 2 &&
	    (!strncmp(argv[1], "-h", 2) ||
	     !strncmp(argv[1], "-H", 2))) {
		nas_wksp_display_usage();
		return 0;
	}

	/* alloc nas/wpa work space */
	if (!(nas_nwksp = nas_wksp_alloc_workspace())) {
		NASMSG("Unable to allocate work space memory. Quitting...\n");
		return 0;
	}

	if (argc > 1 && nas_wksp_parse_cmd(argc, argv, nas_nwksp)) {
		NASMSG("Command line parsing error. Quitting...\n");
		nas_wksp_free_workspace(nas_nwksp);
		return 0;
	}
	else {
#ifdef BCMDBG
		/* verbose - 0:no | others:yes */
		/* for workspace */
		char debug[8];
		if (nas_safe_get_conf(debug, sizeof(debug), "nas_dbg") == 0)
			debug_nwksp = (int)atoi(debug);
#endif
	}

	/* establish a handler to handle SIGTERM. */
	signal(SIGTERM, hup_hdlr);

	/* run main loop to dispatch messages */
	nas_wksp_main_loop(nas_nwksp);

	return 0;
}