OCT 1. 清除无效代码

This commit is contained in:
huangxin 2023-01-28 15:59:34 +08:00
parent a3e24c8ce4
commit 3cbbb839a6
1 changed files with 111 additions and 107 deletions

View File

@ -50,9 +50,9 @@ data2 cfig;
bool verbatim = false;
data9 dhcpr;
data9 token;
MYBYTE currentInd = 0;
MYBYTE newInd = 0;
data18 magin;
//MYBYTE currentInd = 0;
//MYBYTE newInd = 0;
//data18 magin;
bool kRunning = true;
dhcpMap dhcpCache;
char serviceName[] = "OpenDHCP";
@ -64,7 +64,7 @@ char exeFile[PATH_MAX] = "";
char iniFile[PATH_MAX] = "";
char leaFile[PATH_MAX] = "";
//char logFile[PATH_MAX] = "";
char tempFile[PATH_MAX] = "/tmp/opendhcp.tmp";
//char tempFile[PATH_MAX] = "/tmp/opendhcp.tmp";
char filePATH[PATH_MAX] = "";
char htmlTitle[PATH_MAX] = "";
char icoFile[PATH_MAX] = "";
@ -87,7 +87,7 @@ struct ifreq IfcBuf[MAX_SERVERS];
const char NBSP = 32;
const char RANGESET[] = "RANGE_SET";
const char GLOBALOPTIONS[] = "GLOBAL_OPTIONS";
const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
//const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
//const char send200[] = "HTTP/1.1 200 OK\r\nDate: %s\r\nLast-Modified: %s\r\nContent-Type: text/html\r\nConnection: Close\r\nTransfer-Encoding: chunked\r\n";
//const char send200[] = "HTTP/1.1 200 OK\r\nDate: %s\r\nLast-Modified: %s\r\nContent-Type: text/html\r\nConnection: Close\r\nContent-Length: \r\n\r\n";
//const char send200[] = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: Close\r\n\r\n";
@ -673,26 +673,26 @@ void on_system_exit(void *p) {
}
}
bool chkQu(char *query) {
if (strlen(query) >= UCHAR_MAX) {
return false;
}
while (true) {
char *dp = strchr(query, '.');
if (dp) {
MYWORD size = dp - query;
if (size >= 64) {
return false;
}
query += (size + 1);
} else if (strlen(query) >= 64) {
return false;
} else {
return true;
}
}
}
//bool chkQu(char *query) {
// if (strlen(query) >= UCHAR_MAX) {
// return false;
// }
//
// while (true) {
// char *dp = strchr(query, '.');
// if (dp) {
// MYWORD size = dp - query;
// if (size >= 64) {
// return false;
// }
// query += (size + 1);
// } else if (strlen(query) >= 64) {
// return false;
// } else {
// return true;
// }
// }
//}
MYWORD fUShort(void *raw) {
return ntohs(*((MYWORD *)raw));
@ -2239,23 +2239,23 @@ void lockIP(MYDWORD ip) {
}
}
void holdIP(MYDWORD ip) {
if (ip) {
MYDWORD iip = htonl(ip);
for (char rangeInd = 0; rangeInd < cfig.rangeCount; rangeInd++) {
if (iip >= cfig.dhcpRanges[rangeInd].rangeStart && iip <= cfig.dhcpRanges[rangeInd].rangeEnd) {
unsigned int ind = iip - cfig.dhcpRanges[rangeInd].rangeStart;
if (cfig.dhcpRanges[rangeInd].expiry[ind] == 0) {
cfig.dhcpRanges[rangeInd].expiry[ind] = 1;
}
break;
}
}
}
}
//void holdIP(MYDWORD ip) {
// if (ip) {
// MYDWORD iip = htonl(ip);
//
// for (char rangeInd = 0; rangeInd < cfig.rangeCount; rangeInd++) {
// if (iip >= cfig.dhcpRanges[rangeInd].rangeStart && iip <= cfig.dhcpRanges[rangeInd].rangeEnd) {
// unsigned int ind = iip - cfig.dhcpRanges[rangeInd].rangeStart;
//
// if (cfig.dhcpRanges[rangeInd].expiry[ind] == 0) {
// cfig.dhcpRanges[rangeInd].expiry[ind] = 1;
// }
//
// break;
// }
// }
// }
//}
void *sendToken(void *lpParam) {
sleep(10);
@ -3830,21 +3830,22 @@ void mySplit(char *name, char *value, const char *source, char splitChar) {
//printf("%s %s\n", name, value);
}
MYDWORD getClassNetwork(MYDWORD ip) {
data15 data {};
data.ip = ip;
data.octate[3] = 0;
if (data.octate[0] < 192) {
data.octate[2] = 0;
}
if (data.octate[0] < 128) {
data.octate[1] = 0;
}
return data.ip;
}
//
//MYDWORD getClassNetwork(MYDWORD ip) {
// data15 data {};
// data.ip = ip;
// data.octate[3] = 0;
//
// if (data.octate[0] < 192) {
// data.octate[2] = 0;
// }
//
// if (data.octate[0] < 128) {
// data.octate[1] = 0;
// }
//
// return data.ip;
//}
/*
char *IP2Auth(MYDWORD ip)
@ -4169,47 +4170,47 @@ char *IP62String(char *target, MYBYTE *source)
return target;
}
*/
char *IP62String(char *target, MYBYTE *source) {
char *dp = target;
bool zerostarted = false;
bool zeroended = false;
for (MYBYTE i = 0; i < 16; i += 2, source += 2) {
if (source[0]) {
if (zerostarted) {
zeroended = true;
}
if (zerostarted && zeroended) {
dp += sprintf(dp, "::");
zerostarted = false;
} else if (dp != target) {
dp += sprintf(dp, ":");
}
dp += sprintf(dp, "%x", source[0]);
dp += sprintf(dp, "%02x", source[1]);
} else if (source[1]) {
if (zerostarted) {
zeroended = true;
}
if (zerostarted && zeroended) {
dp += sprintf(dp, "::");
zerostarted = false;
} else if (dp != target) {
dp += sprintf(dp, ":");
}
dp += sprintf(dp, "%0x", source[1]);
} else if (!zeroended) {
zerostarted = true;
}
}
return target;
}
//
//char *IP62String(char *target, MYBYTE *source) {
// char *dp = target;
// bool zerostarted = false;
// bool zeroended = false;
//
// for (MYBYTE i = 0; i < 16; i += 2, source += 2) {
// if (source[0]) {
// if (zerostarted) {
// zeroended = true;
// }
//
// if (zerostarted && zeroended) {
// dp += sprintf(dp, "::");
// zerostarted = false;
// } else if (dp != target) {
// dp += sprintf(dp, ":");
// }
//
// dp += sprintf(dp, "%x", source[0]);
// dp += sprintf(dp, "%02x", source[1]);
// } else if (source[1]) {
// if (zerostarted) {
// zeroended = true;
// }
//
// if (zerostarted && zeroended) {
// dp += sprintf(dp, "::");
// zerostarted = false;
// } else if (dp != target) {
// dp += sprintf(dp, ":");
// }
//
// dp += sprintf(dp, "%0x", source[1]);
// } else if (!zeroended) {
// zerostarted = true;
// }
// }
//
// return target;
//}
char *getHexValue(MYBYTE *target, char *source, MYBYTE *size) {
if (*size) {
@ -4287,6 +4288,7 @@ char *myLower(char *string) {
return string;
}
#if 0
bool wildcmp(char *string, char *wild) {
// Written by Jack Handy - jakkhandy@hotmail.com
// slightly modified
@ -4357,6 +4359,7 @@ void listDhcpCache() {
p++;
}
}
#endif
void calcRangeLimits(MYDWORD ip, MYDWORD mask, MYDWORD *rangeStart, MYDWORD *rangeEnd) {
*rangeStart = htonl(ip & mask) + 1;
@ -4478,20 +4481,20 @@ void *init(void *lparam) {
if ((f = fopen(iniFile, "rt"))) {
fclose(f);
}
// else {
// sprintf(logBuff, "Warning: file %s not found, defaults will be used", iniFile);
// logDHCPMess(logBuff, 1);
// }
// else {
// sprintf(logBuff, "Warning: file %s not found, defaults will be used", iniFile);
// logDHCPMess(logBuff, 1);
// }
sleep(1);
if ((f = fopen(iniFile, "rt"))) {
fclose(f);
}
// else {
// sprintf(logBuff, "Warning: file %s not found, defaults will be used", iniFile);
// logDHCPMess(logBuff, 1);
// }
// else {
// sprintf(logBuff, "Warning: file %s not found, defaults will be used", iniFile);
// logDHCPMess(logBuff, 1);
// }
sprintf(logBuff, "Starting DHCP Service");
logDHCPMess(logBuff, 1);
@ -5251,6 +5254,8 @@ void *updateStateFile(void *lparam) {
pthread_exit(nullptr);
}
#if 0
void debug(const char *mess) {
char ts[254];
strcpy(ts, mess);
@ -5263,7 +5268,6 @@ void debug(int i) {
logDHCPMess(ts, 1);
}
#if 0
void *logThread(void *lpParam) {
pthread_mutex_lock(&mutLogFile);
char *mess = (char *)lpParam;