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

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

?? files.c

?? udhcpc code for busybox
?? C
字號:
/* * files.c -- DHCP server file manipulation * * Rewrite by Russ Dill <Russ.Dill@asu.edu> July 2001 */#include <sys/socket.h>#include <arpa/inet.h>#include <string.h>#include <stdlib.h>#include <time.h>#include <ctype.h>#include <netdb.h>#include <netinet/ether.h>#include "static_leases.h"#include "dhcpd.h"#include "options.h"#include "files.h"#include "common.h"/* * Domain names may have 254 chars, and string options can be 254 * chars long. However, 80 bytes will be enough for most, and won't * hog up memory. If you have a special application, change it */#define READ_CONFIG_BUF_SIZE 80/* on these functions, make sure you datatype matches */static int read_ip(const char *line, void *arg){	struct in_addr *addr = arg;	struct hostent *host;	int retval = 1;	if (!inet_aton(line, addr)) {		if ((host = gethostbyname(line)))			addr->s_addr = *((unsigned long *) host->h_addr_list[0]);		else retval = 0;	}	return retval;}static int read_mac(const char *line, void *arg){	uint8_t *mac_bytes = arg;	struct ether_addr *temp_ether_addr;	int retval = 1;	temp_ether_addr = ether_aton(line);	if(temp_ether_addr == NULL)		retval = 0;	else		memcpy(mac_bytes, temp_ether_addr, 6);	return retval;}static int read_str(const char *line, void *arg){	char **dest = arg;	free(*dest);	*dest = strdup(line);	return 1;}static int read_u32(const char *line, void *arg){	uint32_t *dest = arg;	char *endptr;	*dest = strtoul(line, &endptr, 0);	return endptr[0] == '\0';}static int read_yn(const char *line, void *arg){	char *dest = arg;	int retval = 1;	if (!strcasecmp("yes", line))		*dest = 1;	else if (!strcasecmp("no", line))		*dest = 0;	else retval = 0;	return retval;}/* find option 'code' in opt_list */struct option_set *find_option(struct option_set *opt_list, char code){	while (opt_list && opt_list->data[OPT_CODE] < code)		opt_list = opt_list->next;	if (opt_list && opt_list->data[OPT_CODE] == code) return opt_list;	else return NULL;}/* add an option to the opt_list */static void attach_option(struct option_set **opt_list, struct dhcp_option *option, char *buffer, int length){	struct option_set *existing, *new, **curr;	/* add it to an existing option */	if ((existing = find_option(*opt_list, option->code))) {		DEBUG(LOG_INFO, "Attaching option %s to existing member of list", option->name);		if (option->flags & OPTION_LIST) {			if (existing->data[OPT_LEN] + length <= 255) {				existing->data = realloc(existing->data,						existing->data[OPT_LEN] + length + 2);				memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length);				existing->data[OPT_LEN] += length;			} /* else, ignore the data, we could put this in a second option in the future */		} /* else, ignore the new data */	} else {		DEBUG(LOG_INFO, "Attaching option %s to list", option->name);		/* make a new option */		new = xmalloc(sizeof(struct option_set));		new->data = xmalloc(length + 2);		new->data[OPT_CODE] = option->code;		new->data[OPT_LEN] = length;		memcpy(new->data + 2, buffer, length);		curr = opt_list;		while (*curr && (*curr)->data[OPT_CODE] < option->code)			curr = &(*curr)->next;		new->next = *curr;		*curr = new;	}}/* read a dhcp option and add it to opt_list */static int read_opt(const char *const_line, void *arg){	struct option_set **opt_list = arg;	char *opt, *val, *endptr;	struct dhcp_option *option;	int retval = 0, length;	char buffer[8];	char *line;	uint16_t *result_u16 = (uint16_t *) buffer;	uint32_t *result_u32 = (uint32_t *) buffer;	/* Cheat, the only const line we'll actually get is "" */	line = (char *) const_line;	if (!(opt = strtok(line, " \t="))) return 0;	for (option = dhcp_options; option->code; option++)		if (!strcasecmp(option->name, opt))			break;	if (!option->code) return 0;	do {		if (!(val = strtok(NULL, ", \t"))) break;		length = option_lengths[option->flags & TYPE_MASK];		retval = 0;		opt = buffer; /* new meaning for variable opt */		switch (option->flags & TYPE_MASK) {		case OPTION_IP:			retval = read_ip(val, buffer);			break;		case OPTION_IP_PAIR:			retval = read_ip(val, buffer);			if (!(val = strtok(NULL, ", \t/-"))) retval = 0;			if (retval) retval = read_ip(val, buffer + 4);			break;		case OPTION_STRING:			length = strlen(val);			if (length > 0) {				if (length > 254) length = 254;				opt = val;				retval = 1;			}			break;		case OPTION_BOOLEAN:			retval = read_yn(val, buffer);			break;		case OPTION_U8:			buffer[0] = strtoul(val, &endptr, 0);			retval = (endptr[0] == '\0');			break;		case OPTION_U16:			*result_u16 = htons(strtoul(val, &endptr, 0));			retval = (endptr[0] == '\0');			break;		case OPTION_S16:			*result_u16 = htons(strtol(val, &endptr, 0));			retval = (endptr[0] == '\0');			break;		case OPTION_U32:			*result_u32 = htonl(strtoul(val, &endptr, 0));			retval = (endptr[0] == '\0');			break;		case OPTION_S32:			*result_u32 = htonl(strtol(val, &endptr, 0));			retval = (endptr[0] == '\0');			break;		default:			break;		}		if (retval)			attach_option(opt_list, option, opt, length);	} while (retval && option->flags & OPTION_LIST);	return retval;}static int read_staticlease(const char *const_line, void *arg){	char *line;	char *mac_string;	char *ip_string;	uint8_t *mac_bytes;	uint32_t *ip;	/* Allocate memory for addresses */	mac_bytes = xmalloc(sizeof(unsigned char) * 8);	ip = xmalloc(sizeof(uint32_t));	/* Read mac */	line = (char *) const_line;	mac_string = strtok(line, " \t");	read_mac(mac_string, mac_bytes);	/* Read ip */	ip_string = strtok(NULL, " \t");	read_ip(ip_string, ip);	addStaticLease(arg, mac_bytes, ip);	if (ENABLE_FEATURE_UDHCP_DEBUG) printStaticLeases(arg);	return 1;}static const struct config_keyword keywords[] = {	/* keyword	handler   variable address		default */	{"start",	read_ip,  &(server_config.start),	"192.168.0.20"},	{"end",		read_ip,  &(server_config.end),		"192.168.0.254"},	{"interface",	read_str, &(server_config.interface),	"eth0"},	{"option",	read_opt, &(server_config.options),	""},	{"opt",		read_opt, &(server_config.options),	""},	{"max_leases",	read_u32, &(server_config.max_leases),	"254"},	{"remaining",	read_yn,  &(server_config.remaining),	"yes"},	{"auto_time",	read_u32, &(server_config.auto_time),	"7200"},	{"decline_time",read_u32, &(server_config.decline_time),"3600"},	{"conflict_time",read_u32,&(server_config.conflict_time),"3600"},	{"offer_time",	read_u32, &(server_config.offer_time),	"60"},	{"min_lease",	read_u32, &(server_config.min_lease),	"60"},	{"lease_file",	read_str, &(server_config.lease_file),	LEASES_FILE},	{"pidfile",	read_str, &(server_config.pidfile),	"/var/run/udhcpd.pid"},	{"notify_file", read_str, &(server_config.notify_file),	""},	{"siaddr",	read_ip,  &(server_config.siaddr),	"0.0.0.0"},	{"sname",	read_str, &(server_config.sname),	""},	{"boot_file",	read_str, &(server_config.boot_file),	""},	{"static_lease",read_staticlease, &(server_config.static_leases),	""},	/*ADDME: static lease */	{"",		NULL,	  NULL,				""}};int read_config(const char *file){	FILE *in;	char buffer[READ_CONFIG_BUF_SIZE], *token, *line;	int i, lm = 0;	for (i = 0; keywords[i].keyword[0]; i++)		if (keywords[i].def[0])			keywords[i].handler(keywords[i].def, keywords[i].var);	if (!(in = fopen(file, "r"))) {		LOG(LOG_ERR, "unable to open config file: %s", file);		return 0;	}	while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) {		char debug_orig[READ_CONFIG_BUF_SIZE];		lm++;		if (strchr(buffer, '\n')) *(strchr(buffer, '\n')) = '\0';		if (ENABLE_FEATURE_UDHCP_DEBUG) strcpy(debug_orig, buffer);		if (strchr(buffer, '#')) *(strchr(buffer, '#')) = '\0';		if (!(token = strtok(buffer, " \t"))) continue;		if (!(line = strtok(NULL, ""))) continue;		/* eat leading whitespace */		line = line + strspn(line, " \t=");		/* eat trailing whitespace */		for (i = strlen(line); i > 0 && isspace(line[i - 1]); i--);		line[i] = '\0';		for (i = 0; keywords[i].keyword[0]; i++)			if (!strcasecmp(token, keywords[i].keyword))				if (!keywords[i].handler(line, keywords[i].var)) {					LOG(LOG_ERR, "Failure parsing line %d of %s", lm, file);					DEBUG(LOG_ERR, "unable to parse '%s'", debug_orig);					/* reset back to the default value */					keywords[i].handler(keywords[i].def, keywords[i].var);				}	}	fclose(in);	return 1;}void write_leases(void){	FILE *fp;	unsigned int i;	char buf[255];	time_t curr = time(0);	unsigned long tmp_time;	if (!(fp = fopen(server_config.lease_file, "w"))) {		LOG(LOG_ERR, "Unable to open %s for writing", server_config.lease_file);		return;	}	for (i = 0; i < server_config.max_leases; i++) {		if (leases[i].yiaddr != 0) {			/* screw with the time in the struct, for easier writing */			tmp_time = leases[i].expires;			if (server_config.remaining) {				if (lease_expired(&(leases[i])))					leases[i].expires = 0;				else leases[i].expires -= curr;			} /* else stick with the time we got */			leases[i].expires = htonl(leases[i].expires);			fwrite(&leases[i], sizeof(struct dhcpOfferedAddr), 1, fp);			/* Then restore it when done. */			leases[i].expires = tmp_time;		}	}	fclose(fp);	if (server_config.notify_file) {		sprintf(buf, "%s %s", server_config.notify_file, server_config.lease_file);		system(buf);	}}void read_leases(const char *file){	FILE *fp;	unsigned int i = 0;	struct dhcpOfferedAddr lease;	if (!(fp = fopen(file, "r"))) {		LOG(LOG_ERR, "Unable to open %s for reading", file);		return;	}	while (i < server_config.max_leases && (fread(&lease, sizeof lease, 1, fp) == 1)) {		/* ADDME: is it a static lease */		if (lease.yiaddr >= server_config.start && lease.yiaddr <= server_config.end) {			lease.expires = ntohl(lease.expires);			if (!server_config.remaining) lease.expires -= time(0);			if (!(add_lease(lease.chaddr, lease.yiaddr, lease.expires))) {				LOG(LOG_WARNING, "Too many leases while loading %s\n", file);				break;			}			i++;		}	}	DEBUG(LOG_INFO, "Read %d leases", i);	fclose(fp);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产69精品久久99不卡| 国产激情一区二区三区四区 | 久久久一区二区| 99国产麻豆精品| 国产99久久久精品| 极品少妇xxxx精品少妇偷拍 | 亚洲日本在线看| 中文字幕色av一区二区三区| 国产欧美综合在线观看第十页| 国产日韩精品一区二区三区在线| 在线观看日韩电影| 欧美艳星brazzers| 91香蕉视频污在线| 欧美视频三区在线播放| 91美女片黄在线观看91美女| 色悠悠亚洲一区二区| 成人亚洲一区二区一| 色94色欧美sute亚洲13| 色哟哟亚洲精品| 91麻豆精品91久久久久久清纯| 欧美人与禽zozo性伦| 欧美成人精品二区三区99精品| 2023国产精品| 久久欧美中文字幕| 欧美精品一区二区三区蜜桃| 国产精品拍天天在线| 五月天视频一区| 丁香婷婷综合网| 欧美人与z0zoxxxx视频| 337p日本欧洲亚洲大胆色噜噜| 一区二区三区产品免费精品久久75| 亚洲一区av在线| 99久久伊人网影院| 欧美日韩成人在线一区| 国产精品国产三级国产普通话99 | 亚洲欧美区自拍先锋| 麻豆国产欧美日韩综合精品二区| 91成人看片片| 亚洲另类在线视频| 大尺度一区二区| 欧美日韩在线一区二区| 亚洲欧美色一区| 激情综合色综合久久综合| 69精品人人人人| 国产精品电影一区二区三区| 国产一区在线不卡| 91精品一区二区三区久久久久久| 亚洲精品v日韩精品| 在线影视一区二区三区| 亚洲一本大道在线| 欧美一级精品在线| 全部av―极品视觉盛宴亚洲| 日韩视频在线观看一区二区| 香蕉久久一区二区不卡无毒影院 | 成人一区二区三区视频在线观看| 国产日产精品1区| 粉嫩13p一区二区三区| 国产校园另类小说区| 99国内精品久久| 日韩精品免费视频人成| 国产色综合一区| 91视频xxxx| 韩国成人精品a∨在线观看| 久久久久久99精品| 欧美综合一区二区| 日韩精品久久久久久| 精品区一区二区| 成人性生交大片免费看中文| 一区二区三区电影在线播| 色成年激情久久综合| 美女爽到高潮91| 国产欧美日韩三级| 欧美精品1区2区3区| 成人高清伦理免费影院在线观看| 国产午夜精品一区二区| 欧美日韩精品欧美日韩精品一 | 日韩av网站在线观看| 一区在线观看视频| 久久亚洲影视婷婷| 91精品啪在线观看国产60岁| 欧美伊人久久久久久久久影院 | 天天综合日日夜夜精品| 久久久蜜桃精品| 欧美成人高清电影在线| 91精品婷婷国产综合久久性色 | 久久日韩粉嫩一区二区三区| 91精品婷婷国产综合久久性色| 日本精品裸体写真集在线观看| 国产成人av电影在线观看| 国产在线精品不卡| 国产成人精品三级麻豆| 国产精品原创巨作av| 亚洲一区二区精品3399| 亚洲国产毛片aaaaa无费看| 国产网站一区二区| 国产精品女主播在线观看| 国产无一区二区| 亚洲人精品一区| 亚洲乱码国产乱码精品精小说| 久久久综合激的五月天| 国产精品污www在线观看| 一区免费观看视频| 亚洲风情在线资源站| 九九**精品视频免费播放| 国产剧情在线观看一区二区| 成人教育av在线| 91麻豆自制传媒国产之光| 欧美精品精品一区| 欧美美女直播网站| 国产亚洲短视频| 亚洲美女精品一区| 精品一区二区在线播放| 91在线观看成人| 精品卡一卡二卡三卡四在线| 国产精品毛片大码女人| 亚洲成a人片综合在线| 国产一区二区视频在线播放| 国产99一区视频免费| 在线电影欧美成精品| 国产精品久久久久久妇女6080| 亚洲香肠在线观看| 波多野结衣视频一区| 日韩视频在线永久播放| 亚洲国产视频在线| av亚洲精华国产精华| 久久精品一区八戒影视| 奇米精品一区二区三区在线观看一| 91丨九色丨尤物| 中文字幕乱码一区二区免费| 玉米视频成人免费看| 精品一区二区免费| 欧美日韩一区二区三区四区五区| 日本一区二区免费在线观看视频| 日本不卡中文字幕| 日韩欧美三级在线| 亚洲成人av资源| 色综合久久久网| 夜夜操天天操亚洲| 欧美亚洲一区三区| 免费在线视频一区| 欧美一区二区三区色| 亚洲欧美日韩国产手机在线| 粉嫩一区二区三区在线看| 久久久91精品国产一区二区精品 | 精品写真视频在线观看| 久久一留热品黄| 高清国产午夜精品久久久久久| 中文字幕不卡一区| 久久精品国产免费看久久精品| 欧美性大战久久久久久久| 亚洲成人免费在线| 日韩视频免费观看高清完整版在线观看| 青青草原综合久久大伊人精品优势 | 欧美国产精品专区| 粉嫩av一区二区三区| 婷婷亚洲久悠悠色悠在线播放 | 日韩欧美一二区| 美女视频网站久久| 久久久www成人免费毛片麻豆 | 欧美色视频在线观看| 免费观看久久久4p| 一个色在线综合| 日韩午夜在线影院| 欧美日韩国产综合视频在线观看| 另类中文字幕网| 亚洲午夜av在线| 亚洲精品成人精品456| 欧美日韩成人综合| 欧美亚一区二区| 国产白丝精品91爽爽久久| 一区二区三区在线免费| 国产肉丝袜一区二区| 精品电影一区二区| 91精品国产色综合久久不卡蜜臀| av在线不卡电影| 韩国精品久久久| 国内欧美视频一区二区| 午夜伊人狠狠久久| 亚洲综合色网站| 亚洲国产aⅴ天堂久久| 亚洲男人的天堂网| 最近日韩中文字幕| 精品久久久久久久人人人人传媒| 日韩欧美专区在线| 欧美一级日韩免费不卡| 日韩欧美一区中文| 欧美电影精品一区二区| 欧美精品v国产精品v日韩精品| 欧美日韩小视频| 日韩欧美一区二区久久婷婷| 欧美成人a视频| 26uuu欧美| 最新成人av在线| 免费成人在线视频观看| 成人网页在线观看| 91麻豆精品视频| 精品88久久久久88久久久| 欧美高清一级片在线| 2024国产精品| 婷婷久久综合九色国产成人|