예제 #1
0
파일: athctrl.c 프로젝트: ebichu/dd-wrt
int
athctrl_init(int argc, char *argv[])
{

#else

int
main(int argc, char *argv[])
{

#endif
	char device[IFNAMSIZ + 1];
	int distance = -1;
	int c;

	strncpy(device, "wifi0", sizeof (device));

	for (;;) {
        	c = getopt(argc, argv, "d:i:h");
        	if (c < 0)
			break;
        	switch (c) {
        	case 'h':
			usage();
			break;
        	case 'd':
			distance = atoi(optarg);
			break;
        	case 'i':
			strncpy(device, optarg, sizeof (device));
			break;
        	default:
			usage();
			break;
        	}
	}

	if (distance >= 0) {
        	int slottime = 9 + (distance / 300) + ((distance % 300) ? 1 : 0);
		int acktimeout = slottime * 2 + 3;
		int ctstimeout = slottime * 2 + 3;
		
		printf("Setting distance on interface %s to %i meters\n",
			device, distance);
		setsysctrl(device, "slottime", slottime);
		setsysctrl(device, "acktimeout", acktimeout);
		setsysctrl(device, "ctstimeout", ctstimeout);
	} else
		usage();
	return 0;
}
예제 #2
0
파일: athctrl.c 프로젝트: HWL-RobAt/madwifi
int
main(int argc, char *argv[])
{
	char device[IFNAMSIZ + 1];
	int distance = -1;
	int c;

	strncpy(device, "wifi0", sizeof (device));

	for (;;) {
	    	c = getopt(argc, argv, "d:i:h");
	    	if (c < 0)
			break;
	    	switch (c) {
	    	case 'h':
			usage();
			break;
	    	case 'd':
			distance = atoi(optarg);
			break;
	    	case 'i':
			strncpy(device, optarg, sizeof (device));
			break;
	    	default:
			usage();
			break;
	    	}
	}

	if (distance >= 0) {
		printf("Setting distance on interface %s to %i meters\n",
			device, distance);
		setsysctrl(device, "distance", distance);
	} else
		usage();
	return 0;
}