示例#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
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;
}