亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? readconf.c

?? AODV協議實現
?? C
字號:
/*	libdrcom - Library for communicating with DrCOM 2133 Broadband Access Server	Copyright (C) 2005 William Poetra Yoga Hadisoeseno <williampoetra@yahoo.com>	This program is free software; you can redistribute it and/or modify	it under the terms of the GNU General Public License as published by	the Free Software Foundation; either version 2 of the License, or	(at your option) any later version.	This program is distributed in the hope that it will be useful,	but WITHOUT ANY WARRANTY; without even the implied warranty of	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the	GNU General Public License for more details.	You should have received a copy of the GNU General Public License	along with this program; if not, write to the Free Software	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA	02111-1307	USA*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include "log.h"#include "private.h"#define __OPTLEN 256#define __istidy(x) \	((x >= 'a' && x <= 'z') \	|| (x >= 'A' && x <= 'Z') \	|| (x >= '0' && x <= '9') \	|| (x == '_' || x == '=' || x == '.' || x == ',' || x == ':'))/*	Some kind of checklist:	+ 0 means option was never encountered in the config file	+ 1 means option found, value specified and valid	+ 2 means option found, value specified and invalid	+ 3 means option found, but no value specified	+ 4 means option found more than once*/struct _opt_checklist{	u_int8_t username;	u_int8_t password;	u_int8_t mac;	u_int8_t nic[4];	u_int8_t dnsp;	u_int8_t dnss;	u_int8_t dhcp;	u_int8_t hostip;	u_int8_t servip;	u_int8_t hostport;	u_int8_t servport;	u_int8_t hostname;	u_int8_t winver;	u_int8_t winbuild;	u_int8_t servicepack;};int __stripcomments(char *);int __tidyup(char *);int __optname(char *, char *);int __optval(char *, char *);int __parseopt(struct drcom_conf *, char *, struct _opt_checklist *opts);int __fillopts(struct drcom_conf *, struct drcom_info *, struct drcom_host *, struct _opt_checklist *);/* _readconf	A routine for parsing the config file.*/int _readconf(struct drcom_conf *conf, struct drcom_info *info, struct drcom_host *host){	FILE *dotconf;	char buf[__OPTLEN], *s;	struct _opt_checklist opts = {0,0,0,{0,0,0,0},0,0,0,0,0,0,0,0,0,0,0};	int lineno = 0, r = 0;	dotconf = fopen(DRCOM_CONF, "r");	if (!dotconf)		return -1;	while (1)	{		s = fgets(buf, __OPTLEN, dotconf);		if (s == NULL)			break;		r = __parseopt(conf, buf, &opts);		++lineno;		switch(r) {		case 0:			dbg("Line %d parsed successfully\n", lineno);			break;		case 1: dbg("Line %d skipped.\n", lineno); break;		case 2: logerr("Error processing config file at line %d.\n", lineno);			break;		default: break;		}		if (r < 0 || r > 1)			break;	}	/* Even if there was an error, we should close the file first */	fclose(dotconf);	if (r < 0 || r > 1)		return -1;	r = __fillopts(conf, info, host, &opts);#ifdef DEBUG_CONF	dbg("username: %s\n", info->username);	dbg("password: %s\n", info->password);	dbg("mac: %02x:%02x:%02x:%02x:%02x:%02x\n", info->mac[0], info->mac[1],		 info->mac[2], info->mac[3], info->mac[4], info->mac[5]);	dbg("nic0: %s\n", inet_ntoa(*((struct in_addr *) &(info->nic[0]))));	dbg("nic1: %s\n", inet_ntoa(*((struct in_addr *) &(info->nic[1]))));	dbg("nic2: %s\n", inet_ntoa(*((struct in_addr *) &(info->nic[2]))));	dbg("nic3: %s\n", inet_ntoa(*((struct in_addr *) &(info->nic[3]))));	dbg("hostip: %s\n", inet_ntoa(*((struct in_addr *) &(info->hostip))));	dbg("servip: %s\n", inet_ntoa(*((struct in_addr *) &(info->servip))));	dbg("hostport: %d\n", info->hostport);	dbg("servport: %d\n", info->servport);	dbg("hostname: %s\n", host->hostname);	dbg("dnsp: %s\n", inet_ntoa(*((struct in_addr *) &(host->dnsp))));	dbg("dhcp: %s\n", inet_ntoa(*((struct in_addr *) &(host->dhcp))));	dbg("dnss: %s\n", inet_ntoa(*((struct in_addr *) &(host->dnss))));	dbg("winver_major: %d\n", host->winver_major);	dbg("winver_minor: %d\n", host->winver_minor);	dbg("winver_build: %d\n", host->winver_build);	dbg("servicepack: %s\n", host->servicepack);#endif	if (r)	{		logerr("Error digesting configuration!\n");		return -1;	}	return 0;}int __stripcomments(char *buf){	char *c;	c = strchr(buf, '#');	if (c != NULL)		*c = '\0';	return (c - buf + 1);}int __tidyup(char *buf){	int i, len, tidylen, inquote;	len = strlen(buf);	tidylen = 0;	inquote = 0;	for (i = 0; i < len; ++i)	{		if (__istidy(buf[i]) || (inquote && (buf[i] != '"')))		{			buf[tidylen] = buf[i];			++tidylen;		}		else if (buf[i] == '"')		{			inquote = (inquote) ? 0 : 1;		}	}	buf[tidylen] = '\0';	return tidylen;}int __optname(char *buf, char *optname){	char *t;	int len;	memset(optname, 0, 256);	t = strchr(buf, '=');	if (t != NULL)	{		len = t - buf;		strncpy(optname, buf, len);	}	else	{		len = -1;		optname[0] = '\0';	}	return len;}int __optval(char *buf, char *optval){	char *t;	int len;	memset(optval, 0, 256);	t = strchr(buf, '=');	if (t != NULL)	{		len = strlen(buf) - (t - buf + 1);		strncpy(optval, t + 1, len);	}	else	{		len = -1;		optval[0] = '\0';	}	return len;}int __parseopt(struct drcom_conf *conf, char *buf, struct _opt_checklist *opts){/* define them here because they are __parseopt()-specific */#define __optprefix(y, n) \	(strncmp(optname, y, n) == 0)#define __isopt(y, n) \	(strncmp(optname, y, n) == 0 && optname_len == n)	int len, optname_len, optval_len, r;	long int l;	unsigned int _mac[6];	char optname[256], optval[256];	struct in_addr ip = {0};	len = strlen(buf);	if (len > 256)	{		len = 256;		buf[len] = '\0';	}	len = __stripcomments(buf);	if (len == 0)		goto skip;	len = __tidyup(buf);	if (len == 0)		goto skip;	optname_len = __optname(buf, optname);	if (optname_len < 0)		goto err;	optval_len = __optval(buf, optval);	if (optval_len < 0)		goto err;	if (optname_len == 0)	{ goto err; }	else if (__isopt("username", 8))	{		if (opts->username != 0) { opts->username = 4; goto ok; }		if (optval_len == 0) { opts->username = 3; goto ok; }		memset(conf->username, 0, 36);		strncpy(conf->username, optval, 36);		opts->username = 1; goto ok;	}	else if (__isopt("password", 8))	{		if (opts->password != 0) { opts->password = 4; goto ok; }		if (optval_len == 0) { opts->password = 3; goto ok; }		memset(conf->password, 0, 16);		strncpy(conf->password, optval, 16);		opts->password = 1; goto ok;	}	else if (__isopt("mac", 3))	{		if (opts->mac != 0) { opts->mac = 4; goto ok; }		if (optval_len == 0) { opts->mac = 3; goto ok; }		else		{			r = sscanf(optval, "%02x:%02x:%02x:%02x:%02x:%02x",				 &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5]);			if (r < 6) { opts->mac = 2; goto err; }			conf->mac[0] = _mac[0]; conf->mac[1] = _mac[1]; conf->mac[2] = _mac[2];			conf->mac[3] = _mac[3]; conf->mac[4] = _mac[4]; conf->mac[5] = _mac[5];			opts->mac = 1; goto ok;		}	}	else if (__optprefix("nic", 3))	{		if (optname_len > 4) goto err;		l = optname[3] - '0';		if (l >= 0 && l <= 3)		{			if (opts->nic[l] != 0) { opts->nic[l] = 4; goto ok; }			if (optval_len == 0) { opts->nic[l] = 3; goto ok; }			r = inet_pton(AF_INET, optval, &ip);			if (r == 0) { opts->nic[l] = 2; goto err; }			conf->nic[l] = ip.s_addr;			opts->nic[l] = 1;		}		else goto err;	}	else if (__optprefix("dns", 3))	{		if (optname_len > 4) goto err;		switch (optname[3])		{			case 'p':				if (opts->dnsp != 0) { opts->dnsp = 4; goto ok; }				if (optval_len == 0) { opts->dnsp = 3; goto ok; }				r = inet_pton(AF_INET, optval, &ip);				if (r == 0) { opts->dnsp = 2; goto err; }				conf->dnsp = ip.s_addr;				opts->dnsp =	1; goto ok;				break;			case 's':				if (opts->dnss != 0) { opts->dnss = 4; goto ok; }				if (optval_len == 0) { opts->dnss = 3; goto ok; }				r = inet_pton(AF_INET, optval, &ip);				if (r == 0) { opts->dnss = 2; goto err; }				conf->dnss = ip.s_addr;				opts->dnss =	1; goto ok;				break;			default: goto err; break;		}	}	else if (__isopt("dhcp", 4))	{		if (opts->dhcp != 0) { opts->dhcp = 4; goto ok; }		if (optval_len == 0) { opts->dhcp = 3; goto ok; }		r = inet_pton(AF_INET, optval, &ip);		if (r == 0) { opts->dhcp = 2; goto err; }		conf->dhcp = ip.s_addr;		opts->dhcp = 1; goto ok;	}	else if (__isopt("hostip", 6))	{		if (opts->hostip != 0) { opts->hostip = 4; goto ok; }		if (optval_len == 0) { opts->hostip = 3; goto ok; }		r = inet_pton(AF_INET, optval, &ip);		if (r == 0)		{ opts->hostip = (_getaddr(optval, &conf->hostip) == 0) ? 1 : 2; goto ok; }		conf->hostip = ip.s_addr;		opts->hostip = 1;	}	else if (__isopt("servip", 6))	{		if (opts->servip != 0) { opts->servip = 4; goto ok; }		if (optval_len == 0) { opts->servip = 3; goto ok; }		r = inet_pton(AF_INET, optval, &ip);		if (r == 0) { opts->servip = 2; goto err; }		conf->servip = ip.s_addr;		opts->servip = 1;	}	else if (__isopt("hostport", 8))	{		if (opts->hostport != 0) { opts->hostport = 4; goto ok; }		if (optval_len == 0) { opts->hostport = 3; goto ok; }		l = strtol(optval, (char **) NULL, 0);		if ((l == LONG_MIN || l == LONG_MAX) || l > 0xffff)		{ opts->hostport = 2; goto err; }		conf->hostport = (u_int16_t) l;		opts->hostport = 1; goto ok;	}	else if (__isopt("servport", 8))	{		if (opts->servport != 0) { opts->servport = 4; goto ok; }		if (optval_len == 0) { opts->servport = 3; goto ok; }		l = strtol(optval, (char **) NULL, 0);		if ((l == LONG_MIN || l == LONG_MAX) || l > 0xffff)		{ opts->servport = 2; goto err; }		conf->servport = (u_int16_t) l;		opts->servport = 1; goto ok;	}	else if (__isopt("hostname", 8))	{		if (opts->hostname != 0) { opts->hostname = 4; goto ok; }		if (optval_len == 0) { opts->hostname = 3; goto ok; }		memset(conf->hostname, 0, 32);		strncpy(conf->hostname, optval, 32);		opts->hostname = 1; goto ok;	}	else if (__isopt("winver", 6))	{		if (opts->winver != 0) { opts->winver = 4; goto ok; }		if (optval_len == 0) { opts->winver = 3; goto ok; }		r = sscanf(optval, "%u.%u", &conf->winver_major, &conf->winver_minor);		if (r < 2) { opts->winver = 2; goto err; }		opts->winver = 1; goto ok;	}	else if (__isopt("winbuild", 8))	{		if (opts->winbuild != 0) { opts->winbuild = 4; goto ok; }		if (optval_len == 0) { opts->winbuild = 3; goto ok; }		r = sscanf(optval, "%u", &conf->winver_build);		if (r < 1) { opts->winbuild = 2; goto err; }		opts->winbuild = 1; goto ok;	}	else if (__isopt("servicepack", 11))	{		if (opts->servicepack != 0) { opts->servicepack = 4; goto ok; }		if (optval_len == 0) { opts->servicepack = 3; goto ok; }		memset(conf->servicepack, 0, 32);		strncpy(conf->servicepack, optval, 32);		opts->servicepack = 1; goto ok;	}	else { goto err; }ok:	return 0;skip:	return 1;err:	return 2;}int __fillopts(struct drcom_conf *conf, struct drcom_info *info, struct drcom_host *host, struct _opt_checklist *opts){	/* Check the options one by one */	if (opts->username == 1)		memcpy(info->username, conf->username, 36);	else		return -1;	if (opts->password == 1)		memcpy(info->password, conf->password, 16);	else		return -1;	if (opts->mac == 1)		memcpy(info->mac, conf->mac, 6);	else if (opts->mac == 0 || opts->mac == 3)		memset(info->mac, 0, 6);	else		return -1;	if (opts->nic[0] == 1)		info->nic[0] = conf->nic[0];	else		return -1;	if (opts->nic[1] == 1)		info->nic[1] = conf->nic[1];	else if (opts->nic[1] == 0 || opts->nic[1] == 3)		info->nic[1] = 0;	else		return -1;	if (opts->nic[2] == 1)		info->nic[2] = conf->nic[2];	else if (opts->nic[2] == 0 || opts->nic[2] == 3)		info->nic[2] = 0;	else		return -1;	if (opts->nic[3] == 1)		info->nic[3] = conf->nic[3];	else if (opts->nic[3] == 0 || opts->nic[3] == 3)		info->nic[3] = 0;	else		return -1;	if (opts->dnsp == 1)		host->dnsp = conf->dnsp;	else		return -1;	if (opts->dnss == 1)		host->dnss = conf->dnss;	else		return -1;	if (opts->dhcp == 1)		host->dhcp = conf->dhcp;	else if (opts->dhcp == 0 || opts->dhcp == 3)		host->dhcp = 0xffffffff;	/* Like Windows XP */	else		return -1;	/* No need to check for validity of conf->nic[0] here,		 since it's already checked */	if (opts->hostip == 1)		info->hostip = conf->hostip;	else if (opts->hostip == 0 || opts->hostip == 3)		info->hostip = conf->nic[0];	else		return -1;	if (opts->servip == 1)		info->servip = conf->servip;	else if (opts->servip == 0 || opts->servip == 3)		info->servip = 0x01010101; /* 1.1.1.1 */	else		return -1;	if (opts->hostport == 1)		info->hostport = conf->hostport;	else if (opts->hostport == 0 || opts->hostport == 3)		info->hostport = 0xf000; /* 61440 */	else		return -1;	if (opts->servport == 1)		info->servport = conf->servport;	else if (opts->servport == 0 || opts->servport == 3)		info->servport = 0xf000; /* 61440 */	else		return -1;	if (opts->hostname == 1)		memcpy(host->hostname, conf->hostname, 32);	else if (opts->hostname == 0 || opts->hostname == 3)	{		memset(host->hostname, 0, 32);		strncpy(host->hostname, "localhost", 32);	/* Does Windows XP use this? */	}	else		return -1;	if (opts->winver == 1)	{		host->winver_major = conf->winver_major;		host->winver_minor = conf->winver_minor;	}	else if (opts->winver == 0 || opts->winver == 3)	{		host->winver_major = 5;	/* Windows XP's version */		host->winver_minor = 1;	/* is NT 5.1 */	}	else		return -1;	if (opts->winbuild == 1)		host->winver_build = conf->winver_build;	else if (opts->winbuild == 0 || opts->winbuild == 3)		host->winver_build = 2600;	/* Windows XP is of build 2600 */	else		return -1;	if (opts->servicepack == 1)		memcpy(host->servicepack, conf->servicepack, 32);	else if (opts->servicepack == 0 || opts->servicepack == 3)	{		memset(host->servicepack, 0, 32);		strncpy(host->servicepack, "Service Pack 2", 32); /* The latest XP sp */	}	else		return -1;	/* Finally, the easy ones */	host->zero0[0] = 0;	host->zero0[1] = 0;	host->unknown0 = 148;	host->unknown1 = 2;	return 0;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品二十页| 色综合咪咪久久| 精品国精品自拍自在线| 蜜桃av一区二区| 久久亚洲精品小早川怜子| 国内精品久久久久影院一蜜桃| 久久麻豆一区二区| 国产精品白丝jk黑袜喷水| 欧美日韩高清在线| 国产女人18毛片水真多成人如厕 | 97国产精品videossex| 亚洲国产aⅴ成人精品无吗| 亚洲午夜久久久久久久久电影院| 亚洲不卡在线观看| 久久国产精品99久久久久久老狼 | 日韩精品福利网| 日韩亚洲欧美在线观看| 国产高清不卡二三区| 国产情人综合久久777777| 色偷偷一区二区三区| 视频一区二区欧美| 欧美高清一级片在线观看| 在线观看国产91| 美国精品在线观看| 亚洲欧美日韩一区| 91精品在线免费| 成人精品小蝌蚪| 午夜精品久久久久影视| 久久久久久一二三区| 欧美中文字幕亚洲一区二区va在线| 青青草97国产精品免费观看 | 亚洲午夜精品在线| 久久久久久久国产精品影院| 色婷婷综合五月| 国产在线精品一区二区夜色 | 欧美日韩精品高清| 国产69精品久久久久毛片| 亚洲国产精品久久久男人的天堂| 久久久久国产精品免费免费搜索| 色欧美88888久久久久久影院| 久久精品国产澳门| 一区二区久久久久久| 精品国产在天天线2019| 91国产成人在线| 国产毛片精品一区| 午夜激情久久久| 亚洲视频一二区| 久久久亚洲精品石原莉奈| 欧美美女视频在线观看| 91在线视频观看| 国产乱国产乱300精品| 日韩精品一级中文字幕精品视频免费观看 | 精品999久久久| 成人黄色电影在线| 国产婷婷精品av在线| 玖玖九九国产精品| 国产欧美1区2区3区| 久久国产尿小便嘘嘘| 欧美一区二区三区成人| 免费欧美日韩国产三级电影| 欧美一卡二卡三卡| 成人午夜视频网站| 国产在线精品一区在线观看麻豆| 一区二区三区高清| 亚洲视频精选在线| 久久久一区二区| 91精品国产色综合久久| 欧美三级午夜理伦三级中视频| 不卡一卡二卡三乱码免费网站| 欧美色视频在线观看| 日韩欧美一级二级| 国产精品婷婷午夜在线观看| 欧美人妖巨大在线| 欧美午夜精品理论片a级按摩| 91视频一区二区| av亚洲精华国产精华| 不卡的电影网站| 成人精品在线视频观看| 国产精品18久久久久久久久| 久久av中文字幕片| 激情综合色综合久久| 久久精品国产99国产| 捆绑调教美女网站视频一区| 日本不卡一区二区三区高清视频| 性欧美疯狂xxxxbbbb| 视频精品一区二区| 蜜桃传媒麻豆第一区在线观看| 久久国产三级精品| 国产成人99久久亚洲综合精品| 国产xxx精品视频大全| 成人免费高清视频| 色综合天天综合狠狠| 91成人看片片| 这里只有精品视频在线观看| 日韩视频一区在线观看| 精品电影一区二区| 国产精品免费看片| 亚洲欧美日本在线| 午夜精品一区二区三区三上悠亚 | 一区二区三区不卡视频在线观看| 亚洲综合久久av| 五月天欧美精品| 国产毛片一区二区| 91一区一区三区| 91精品国产综合久久久蜜臀图片| 亚洲精品一区二区三区福利| 中文av一区特黄| 亚洲伊人色欲综合网| 蜜桃av一区二区| 国产69精品久久777的优势| 欧美久久久久久蜜桃| 欧美日韩精品专区| 一区二区不卡在线视频 午夜欧美不卡在| 日本女人一区二区三区| 精品在线免费视频| 91精品欧美综合在线观看最新 | 51精品国自产在线| 欧美成人a在线| 国产精品国产自产拍在线| 中文字幕在线观看一区二区| 亚洲一区在线看| 国产精品伊人色| 亚洲国产精品自拍| 国精产品一区一区三区mba桃花 | 国产91丝袜在线播放| 色欧美88888久久久久久影院| 日韩精品专区在线影院观看| 国产精品网曝门| 久久国产免费看| 91国在线观看| 亚洲国产激情av| 免费人成在线不卡| 99re在线视频这里只有精品| 欧美岛国在线观看| 亚洲一区二区三区四区在线| 国产成a人亚洲精品| 欧美久久免费观看| 一级做a爱片久久| 国产91高潮流白浆在线麻豆| 8x8x8国产精品| 亚洲精品视频免费看| 国产·精品毛片| 精品精品国产高清a毛片牛牛| 亚洲国产视频直播| 91麻豆精品视频| 国产精品沙发午睡系列990531| 久久精品国产成人一区二区三区 | av激情亚洲男人天堂| 久久麻豆一区二区| 韩国av一区二区三区在线观看| 日韩一区二区在线观看视频播放| 一个色综合网站| 91九色最新地址| 亚洲精品乱码久久久久久黑人| 粉嫩aⅴ一区二区三区四区| 日韩精品一区二区三区四区| 视频一区二区三区中文字幕| 欧美亚洲综合久久| 一区二区三区不卡视频| 91麻豆高清视频| 亚洲少妇中出一区| proumb性欧美在线观看| 中文字幕+乱码+中文字幕一区| 国模无码大尺度一区二区三区| 欧美videossexotv100| 免费美女久久99| 日韩视频免费观看高清在线视频| 肉色丝袜一区二区| 欧美一级搡bbbb搡bbbb| 婷婷丁香久久五月婷婷| 在线不卡一区二区| 青青草国产精品97视觉盛宴| 欧美一级免费大片| 久久er99热精品一区二区| 欧美成人vps| 国产白丝精品91爽爽久久| 日本一区二区视频在线| 成人美女视频在线观看18| 国产精品天干天干在线综合| 成人激情小说乱人伦| 中文字幕日本不卡| 91黄色激情网站| 午夜电影网亚洲视频| 精品日本一线二线三线不卡| 欧美丰满一区二区免费视频| 99久久久国产精品| 欧美一卡二卡在线| 精品一区二区三区影院在线午夜| 亚洲欧美日韩综合aⅴ视频| 日韩一区欧美小说| 久久久精品黄色| 精品久久久久一区二区国产| 91精品在线观看入口| 欧美色图在线观看| 欧美色成人综合| 在线一区二区视频| 欧美亚洲自拍偷拍| 在线观看中文字幕不卡| 欧美不卡一区二区| 亚洲成人动漫精品|