Exemplo n.º 1
0
int stop_auth(const char *prefix, int wan_down)
{
	char tmp[100];
	const char *wan_proto = prefix ? nvram_safe_get(strcat_r(prefix, "proto", tmp)) : NULL;
	const char *wan_auth = prefix ? nvram_safe_get(strcat_r(prefix, "auth_x", tmp)) : NULL;

	if (wan_proto == NULL ||
	    strcmp(wan_proto, "static") == 0 ||
	    strcmp(wan_proto, "dhcp") == 0)
	{
#ifdef __CONFIG_EAPOL__
		if ((!wan_auth || strcmp(wan_auth, "eap-md5") == 0) && !wan_down)
			stop_wpa_supplicant(0);
#endif
#ifdef __CONFIG_TELENET__
		if ((!wan_auth || strcmp(wan_auth, "telenet") == 0) && wan_down)
			stop_lanauth(0);
#endif
#ifdef __CONFIG_CONVEX__
		if ((!wan_auth || strcmp(wan_auth, "convex") == 0) && wan_down)
			stop_authcli(0);
#endif
	}
/* TODO: ugly, remake bigpond as auth, not wan proto */
	if (wan_proto == NULL ||
	    strcmp(wan_proto, "bigpond") == 0)
	{
		if (wan_down)
			stop_bpalogin();
	}

	return 0;
}
Exemplo n.º 2
0
static int start_wpa_supplicant(const char *prefix, int restart)
{
	FILE *fp;
	char tmp[100];
	const char *options = "/etc/wpa_supplicant.conf";
	char *wpa_argv[] = {"/usr/sbin/wpa_supplicant",
		"-B", "-W",
		"-D", "roboswitch",
		"-i", nvram_safe_get(strcat_r(prefix, "ifname", tmp)),
		"-c", (char *)options,
		NULL
	};
	char *cli_argv[] = {"/usr/sbin/wpa_cli",
		"-B",
		"-a", "/tmp/wpa_cli.script",
		NULL
	};
	int ret;

	if (restart)
		stop_wpa_supplicant(1);

	/* Select supplicant drivers here */
	if (router_model == MDL_RTN16 ||
	    router_model == MDL_RTN15U ||
	    router_model == MDL_WL500W)
		wpa_argv[4] = "wired";

	/* Generate options file */
	if ((fp = fopen(options, "w")) == NULL) {
		perror(options);
		return -1;
	}
	fprintf(fp,
		"ctrl_interface=/var/run/wpa_supplicant\n"
		"ap_scan=0\n"
		"fast_reauth=1\n"
		"network={\n"
		"	key_mgmt=IEEE8021X\n"
		"	eap=MD5\n"
		"	identity=\"%s\"\n"
		"	password=\"%s\"\n"
		"	eapol_flags=0\n"
		"}\n",
		nvram_safe_get(strcat_r(prefix, "auth_username", tmp)),
		nvram_safe_get(strcat_r(prefix, "auth_passwd", tmp)));
	fclose(fp);

	/* Start wpa_supplicant */
	ret = _eval(wpa_argv, NULL, 0, NULL);
	if (ret == 0)
		_eval(cli_argv, NULL, 0, NULL);

	return ret;
}
Exemplo n.º 3
0
int
stop_auth(int unit, int wan_down)
{
	char tmp[100];
	char prefix[] = "wanXXXXXXXXXX_";
	char *wan_proto;
	int ret = -1;

	snprintf(prefix, sizeof(prefix), "wan%d_", unit);

	wan_proto = nvram_safe_get(strcat_r(prefix, "proto", tmp));
	if (strcmp(wan_proto, "static") != 0 &&
	    strcmp(wan_proto, "dhcp") != 0)
		return -1;

#ifdef RTCONFIG_EAPOL
	if (!wan_down)
		ret = stop_wpa_supplicant(unit);
#endif

	_dprintf("%s:: done\n", __func__);
	return ret;
}