diff --git a/srcs/include/pppoe_info.h b/srcs/include/pppoe_info.h index d755ae2..9ec3f96 100644 --- a/srcs/include/pppoe_info.h +++ b/srcs/include/pppoe_info.h @@ -100,4 +100,4 @@ struct netif *get_rawsocket_if(void); #ifdef __cplusplus } #endif -#endif//VCPE_PROJECT_PPPOE_INFO_H +#endif //VCPE_PROJECT_PPPOE_INFO_H diff --git a/srcs/include/pppoe_session.h b/srcs/include/pppoe_session.h index 11e9ff6..4c8f7c6 100644 --- a/srcs/include/pppoe_session.h +++ b/srcs/include/pppoe_session.h @@ -13,10 +13,7 @@ extern "C" { #include "user_info.h" - - - #ifdef __cplusplus } #endif -#endif//VCPE_PROJECT_PPPOE_SESSION_H +#endif //VCPE_PROJECT_PPPOE_SESSION_H diff --git a/srcs/include/user_info.h b/srcs/include/user_info.h index 86c73c5..3dbac8d 100644 --- a/srcs/include/user_info.h +++ b/srcs/include/user_info.h @@ -24,4 +24,4 @@ struct netif *get_user_nic_by_mac(const unsigned char mac[6]); #ifdef __cplusplus } #endif -#endif//VCPE_PROJECT_USER_INFO_H +#endif //VCPE_PROJECT_USER_INFO_H diff --git a/srcs/open_dhcp/CMakeLists.txt b/srcs/open_dhcp/CMakeLists.txt index f7f5f90..c64c740 100644 --- a/srcs/open_dhcp/CMakeLists.txt +++ b/srcs/open_dhcp/CMakeLists.txt @@ -2,7 +2,7 @@ SET(DHCPD_PROJECT_TARGET opendhcpd) PROJECT(${DHCPD_PROJECT_TARGET} CXX) -add_definitions(-Wno-write-strings) +ADD_DEFINITIONS(-Wno-write-strings) INCLUDE_DIRECTORIES(../libs/include ./ ../httpserver/include) diff --git a/srcs/open_dhcp/dhcpd.h b/srcs/open_dhcp/dhcpd.h index 160f6fb..fe4c00f 100644 --- a/srcs/open_dhcp/dhcpd.h +++ b/srcs/open_dhcp/dhcpd.h @@ -15,4 +15,4 @@ API_EXPORT int dhcpd_main(int daemon, const char *pInifile, const char *pStatusF #ifdef __cplusplus } #endif -#endif//VCPE_PROJECT_DHCPD_H +#endif //VCPE_PROJECT_DHCPD_H diff --git a/srcs/open_dhcp/opendhcpd.cpp b/srcs/open_dhcp/opendhcpd.cpp index 2362969..4965f48 100644 --- a/srcs/open_dhcp/opendhcpd.cpp +++ b/srcs/open_dhcp/opendhcpd.cpp @@ -97,123 +97,123 @@ const char bodyStart[] = //const char bodyStart[] = "
%s
http://dhcpserver.sourceforge.net
"; //const char bodyStart[] = "
%s
%s
"; const data4 opData[] = { - {"SubnetMask", 1, 3, true}, - {"TimeOffset", 2, 4, true}, - {"Router", 3, 3, true}, - {"TimeServer", 4, 3, true}, - {"NameServer", 5, 3, true}, - {"DomainServer", 6, 3, true}, - {"LogServer", 7, 3, true}, - {"QuotesServer", 8, 3, true}, - {"LPRServer", 9, 3, true}, - {"ImpressServer", 10, 3, true}, - {"RLPServer", 11, 3, true}, - {"Hostname", 12, 1, true}, - {"BootFileSize", 13, 5, true}, - {"MeritDumpFile", 14, 1, true}, - {"DomainName", 15, 1, true}, - {"SwapServer", 16, 3, true}, - {"RootPath", 17, 1, true}, - {"ExtensionFile", 18, 1, true}, - {"ForwardOn/Off", 19, 7, true}, - {"SrcRteOn/Off", 20, 7, true}, - {"PolicyFilter", 21, 8, true}, - {"MaxDGAssembly", 22, 5, true}, - {"DefaultIPTTL", 23, 6, true}, - {"MTUTimeout", 24, 4, true}, - {"MTUPlateau", 25, 2, true}, - {"MTUInterface", 26, 5, true}, - {"MTUSubnet", 27, 7, true}, - {"BroadcastAddress", 28, 3, true}, - {"MaskDiscovery", 29, 7, true}, - {"MaskSupplier", 30, 7, true}, - {"RouterDiscovery", 31, 7, true}, - {"RouterRequest", 32, 3, true}, - {"StaticRoute", 33, 8, true}, - {"Trailers", 34, 7, true}, - {"ARPTimeout", 35, 4, true}, - {"Ethernet", 36, 7, true}, - {"DefaultTCPTTL", 37, 6, true}, - {"KeepaliveTime", 38, 4, true}, - {"KeepaliveData", 39, 7, true}, - {"NISDomain", 40, 1, true}, - {"NISServers", 41, 3, true}, - {"NTPServers", 42, 3, true}, - {"VendorSpecificInf", 43, 2, false}, - {"NETBIOSNameSrv", 44, 3, true}, - {"NETBIOSDistSrv", 45, 3, true}, - {"NETBIOSNodeType", 46, 6, true}, - {"NETBIOSScope", 47, 1, true}, - {"XWindowFont", 48, 1, true}, - {"XWindowManager", 49, 3, true}, - {"AddressRequest", 50, 3, false}, - {"AddressTime", 51, 4, true}, - {"OverLoad", 52, 7, false}, - {"DHCPMsgType", 53, 6, false}, - {"DHCPServerId", 54, 3, false}, - {"ParameterList", 55, 2, false}, - {"DHCPMessage", 56, 1, false}, - {"DHCPMaxMsgSize", 57, 5, false}, - {"RenewalTime", 58, 4, true}, - {"RebindingTime", 59, 4, true}, - {"ClassId", 60, 1, false}, - {"ClientId", 61, 2, false}, - {"NetWareIPDomain", 62, 1, true}, - {"NetWareIPOption", 63, 2, true}, - {"NISDomainName", 64, 1, true}, - {"NISServerAddr", 65, 3, true}, - {"TFTPServerName", 66, 1, true}, - {"BootFileOption", 67, 1, true}, - {"HomeAgentAddrs", 68, 3, true}, - {"SMTPServer", 69, 3, true}, - {"POP3Server", 70, 3, true}, - {"NNTPServer", 71, 3, true}, - {"WWWServer", 72, 3, true}, - {"FingerServer", 73, 3, true}, - {"IRCServer", 74, 3, true}, - {"StreetTalkServer", 75, 3, true}, - {"STDAServer", 76, 3, true}, - {"UserClass", 77, 1, false}, - {"DirectoryAgent", 78, 1, true}, - {"ServiceScope", 79, 1, true}, - {"RapidCommit", 80, 2, false}, - {"ClientFQDN", 81, 2, false}, - {"RelayAgentInformation", 82, 2, false}, - {"iSNS", 83, 1, true}, - {"NDSServers", 85, 3, true}, - {"NDSTreeName", 86, 1, true}, - {"NDSContext", 87, 1, true}, - {"LDAP", 95, 1, true}, - {"PCode", 100, 1, true}, - {"TCode", 101, 1, true}, - {"NetInfoAddress", 112, 3, true}, - {"NetInfoTag", 113, 1, true}, - {"URL", 114, 1, true}, - {"AutoConfig", 116, 7, true}, - {"NameServiceSearch", 117, 2, true}, - {"SubnetSelectionOption", 118, 3, true}, - {"DomainSearch", 119, 1, true}, - {"SIPServersDHCPOption", 120, 1, true}, - // { "121", 121, 2 , true}, - {"CCC", 122, 1, true}, - {"TFTPServerIPaddress", 128, 3, true}, - {"CallServerIPaddress", 129, 3, true}, - {"DiscriminationString", 130, 1, true}, - {"RemoteStatisticsServerIPAddress", 131, 3, true}, - {"HTTPProxyPhone", 135, 3, true}, - {"OPTION_CAPWAP_AC_V4", 138, 1, true}, - {"OPTIONIPv4_AddressMoS", 139, 1, true}, - {"OPTIONIPv4_FQDNMoS", 140, 1, true}, - {"SIPUAServiceDomains", 141, 1, true}, - {"OPTIONIPv4_AddressANDSF", 142, 1, true}, - {"IPTelephone", 176, 1, true}, - {"ConfigurationFile", 209, 1, true}, - {"PathPrefix", 210, 1, true}, - {"RebootTime", 211, 4, true}, - {"OPTION_6RD", 212, 1, true}, - {"OPTION_V4_ACCESS_DOMAIN", 213, 1, true}, - {"BootFileName", 253, 1, true}, - {"NextServer", 254, 3, true}, + {"SubnetMask", 1, 3, true }, + {"TimeOffset", 2, 4, true }, + {"Router", 3, 3, true }, + {"TimeServer", 4, 3, true }, + {"NameServer", 5, 3, true }, + {"DomainServer", 6, 3, true }, + {"LogServer", 7, 3, true }, + {"QuotesServer", 8, 3, true }, + {"LPRServer", 9, 3, true }, + {"ImpressServer", 10, 3, true }, + {"RLPServer", 11, 3, true }, + {"Hostname", 12, 1, true }, + {"BootFileSize", 13, 5, true }, + {"MeritDumpFile", 14, 1, true }, + {"DomainName", 15, 1, true }, + {"SwapServer", 16, 3, true }, + {"RootPath", 17, 1, true }, + {"ExtensionFile", 18, 1, true }, + {"ForwardOn/Off", 19, 7, true }, + {"SrcRteOn/Off", 20, 7, true }, + {"PolicyFilter", 21, 8, true }, + {"MaxDGAssembly", 22, 5, true }, + {"DefaultIPTTL", 23, 6, true }, + {"MTUTimeout", 24, 4, true }, + {"MTUPlateau", 25, 2, true }, + {"MTUInterface", 26, 5, true }, + {"MTUSubnet", 27, 7, true }, + {"BroadcastAddress", 28, 3, true }, + {"MaskDiscovery", 29, 7, true }, + {"MaskSupplier", 30, 7, true }, + {"RouterDiscovery", 31, 7, true }, + {"RouterRequest", 32, 3, true }, + {"StaticRoute", 33, 8, true }, + {"Trailers", 34, 7, true }, + {"ARPTimeout", 35, 4, true }, + {"Ethernet", 36, 7, true }, + {"DefaultTCPTTL", 37, 6, true }, + {"KeepaliveTime", 38, 4, true }, + {"KeepaliveData", 39, 7, true }, + {"NISDomain", 40, 1, true }, + {"NISServers", 41, 3, true }, + {"NTPServers", 42, 3, true }, + {"VendorSpecificInf", 43, 2, false}, + {"NETBIOSNameSrv", 44, 3, true }, + {"NETBIOSDistSrv", 45, 3, true }, + {"NETBIOSNodeType", 46, 6, true }, + {"NETBIOSScope", 47, 1, true }, + {"XWindowFont", 48, 1, true }, + {"XWindowManager", 49, 3, true }, + {"AddressRequest", 50, 3, false}, + {"AddressTime", 51, 4, true }, + {"OverLoad", 52, 7, false}, + {"DHCPMsgType", 53, 6, false}, + {"DHCPServerId", 54, 3, false}, + {"ParameterList", 55, 2, false}, + {"DHCPMessage", 56, 1, false}, + {"DHCPMaxMsgSize", 57, 5, false}, + {"RenewalTime", 58, 4, true }, + {"RebindingTime", 59, 4, true }, + {"ClassId", 60, 1, false}, + {"ClientId", 61, 2, false}, + {"NetWareIPDomain", 62, 1, true }, + {"NetWareIPOption", 63, 2, true }, + {"NISDomainName", 64, 1, true }, + {"NISServerAddr", 65, 3, true }, + {"TFTPServerName", 66, 1, true }, + {"BootFileOption", 67, 1, true }, + {"HomeAgentAddrs", 68, 3, true }, + {"SMTPServer", 69, 3, true }, + {"POP3Server", 70, 3, true }, + {"NNTPServer", 71, 3, true }, + {"WWWServer", 72, 3, true }, + {"FingerServer", 73, 3, true }, + {"IRCServer", 74, 3, true }, + {"StreetTalkServer", 75, 3, true }, + {"STDAServer", 76, 3, true }, + {"UserClass", 77, 1, false}, + {"DirectoryAgent", 78, 1, true }, + {"ServiceScope", 79, 1, true }, + {"RapidCommit", 80, 2, false}, + {"ClientFQDN", 81, 2, false}, + {"RelayAgentInformation", 82, 2, false}, + {"iSNS", 83, 1, true }, + {"NDSServers", 85, 3, true }, + {"NDSTreeName", 86, 1, true }, + {"NDSContext", 87, 1, true }, + {"LDAP", 95, 1, true }, + {"PCode", 100, 1, true }, + {"TCode", 101, 1, true }, + {"NetInfoAddress", 112, 3, true }, + {"NetInfoTag", 113, 1, true }, + {"URL", 114, 1, true }, + {"AutoConfig", 116, 7, true }, + {"NameServiceSearch", 117, 2, true }, + {"SubnetSelectionOption", 118, 3, true }, + {"DomainSearch", 119, 1, true }, + {"SIPServersDHCPOption", 120, 1, true }, + // { "121", 121, 2 , true}, + {"CCC", 122, 1, true }, + {"TFTPServerIPaddress", 128, 3, true }, + {"CallServerIPaddress", 129, 3, true }, + {"DiscriminationString", 130, 1, true }, + {"RemoteStatisticsServerIPAddress", 131, 3, true }, + {"HTTPProxyPhone", 135, 3, true }, + {"OPTION_CAPWAP_AC_V4", 138, 1, true }, + {"OPTIONIPv4_AddressMoS", 139, 1, true }, + {"OPTIONIPv4_FQDNMoS", 140, 1, true }, + {"SIPUAServiceDomains", 141, 1, true }, + {"OPTIONIPv4_AddressANDSF", 142, 1, true }, + {"IPTelephone", 176, 1, true }, + {"ConfigurationFile", 209, 1, true }, + {"PathPrefix", 210, 1, true }, + {"RebootTime", 211, 4, true }, + {"OPTION_6RD", 212, 1, true }, + {"OPTION_V4_ACCESS_DOMAIN", 213, 1, true }, + {"BootFileName", 253, 1, true }, + {"NextServer", 254, 3, true }, }; int dhcpd_main(int daemon, const char *pInifile, const char *pStatusFile, const char *pIfName) { @@ -530,14 +530,14 @@ int dhcpd_main(int daemon, const char *pInifile, const char *pStatusFile, const } for (int i = 0; i < MAX_SERVERS && network.dhcpConn[i].ready; i++) { - if (FD_ISSET(network.dhcpConn[i].sock, &readfds) && gdmess(&dhcpr_local, i) - && sdmess(&dhcpr_local)) { + if (FD_ISSET(network.dhcpConn[i].sock, &readfds) && gdmess(&dhcpr_local, i) && + sdmess(&dhcpr_local)) { alad(&dhcpr_local); } } - if (FD_ISSET(network.dhcpListener.sock, &readfds) && gdmess(&dhcpr_local, 255) - && sdmess(&dhcpr_local)) { + if (FD_ISSET(network.dhcpListener.sock, &readfds) && gdmess(&dhcpr_local, 255) && + sdmess(&dhcpr_local)) { alad(&dhcpr_local); } @@ -803,14 +803,15 @@ void prepareUserHtmlRespStatus(data19 *req) { } else { fp += sprintf(fp, "Active Leases\n"); fp += sprintf( - fp, "Mac AddressIPLease ExpiryHostname (first 20 chars)\n"); + fp, + "Mac AddressIPLease ExpiryHostname (first 20 chars)\n"); } for (p = dhcpCache.begin(); kRunning && p != dhcpCache.end() && fp < maxData; p++) { //if ((dhcpEntry = p->second) && dhcpEntry->display) if ((dhcpEntry = p->second) && dhcpEntry->display && dhcpEntry->expiry >= t) { fp += sprintf(fp, ""); - fp += sprintf(fp, td200, dhcpEntry->mapname);// mapname is MAC address + fp += sprintf(fp, td200, dhcpEntry->mapname); // mapname is MAC address fp += sprintf(fp, td200, IP2String(tempbuff, dhcpEntry->ip)); if (dhcpEntry->expiry >= MY_MAX_TIME) { @@ -1170,12 +1171,12 @@ bool checkRange(data17 *rangeData, char rangeInd) { //printf("checkRange entered, macFound=%i vendFound=%i userFound=%i\n", macFound, vendFound, userFound); if ((!rangeData->macFound && !rangeSet->macSize[0]) || (rangeData->macFound && rangeData->macArray[rangeSetInd])) { - if ((!rangeData->vendFound && !rangeSet->vendClassSize[0]) - || (rangeData->vendFound && rangeData->vendArray[rangeSetInd])) { - if ((!rangeData->userFound && !rangeSet->userClassSize[0]) - || (rangeData->userFound && rangeData->userArray[rangeSetInd])) { - if ((!rangeData->subnetFound && !rangeSet->subnetIP[0]) - || (rangeData->subnetFound && rangeData->subnetArray[rangeSetInd])) { + if ((!rangeData->vendFound && !rangeSet->vendClassSize[0]) || + (rangeData->vendFound && rangeData->vendArray[rangeSetInd])) { + if ((!rangeData->userFound && !rangeSet->userClassSize[0]) || + (rangeData->userFound && rangeData->userArray[rangeSetInd])) { + if ((!rangeData->subnetFound && !rangeSet->subnetIP[0]) || + (rangeData->subnetFound && rangeData->subnetArray[rangeSetInd])) { return true; } } @@ -1263,8 +1264,10 @@ MYDWORD resad(data9 *req) { return req->dhcpEntry->ip; } else { if (verbatim || cfig.dhcpLogLevel) { - sprintf( - logBuff, "Static DHCP Host %s (%s) has No IP, DHCPDISCOVER ignored", req->chaddr, req->hostname); + sprintf(logBuff, + "Static DHCP Host %s (%s) has No IP, DHCPDISCOVER ignored", + req->chaddr, + req->hostname); logDHCPMess(logBuff, 1); } return 0; @@ -1287,8 +1290,8 @@ MYDWORD resad(data9 *req) { //printf("%s\n", hex2String(tempbuff, rangeSet->macStart[i], rangeSet->macSize[i])); //printf("%s\n", hex2String(tempbuff, rangeSet->macEnd[i], rangeSet->macSize[i])); - if (memcmp(req->dhcpp.header.bp_chaddr, rangeSet->macStart[i], rangeSet->macSize[i]) >= 0 - && memcmp(req->dhcpp.header.bp_chaddr, rangeSet->macEnd[i], rangeSet->macSize[i]) <= 0) { + if (memcmp(req->dhcpp.header.bp_chaddr, rangeSet->macStart[i], rangeSet->macSize[i]) >= 0 && + memcmp(req->dhcpp.header.bp_chaddr, rangeSet->macEnd[i], rangeSet->macSize[i]) <= 0) { rangeData.macArray[rangeSetInd] = 1; rangeData.macFound = true; //printf("mac Found, rangeSetInd=%i\n", rangeSetInd); @@ -1297,8 +1300,8 @@ MYDWORD resad(data9 *req) { } for (MYBYTE i = 0; i < MAX_RANGE_FILTERS && req->vendClass.size && rangeSet->vendClassSize[i]; i++) { - if (rangeSet->vendClassSize[i] == req->vendClass.size - && !memcmp(req->vendClass.value, rangeSet->vendClass[i], rangeSet->vendClassSize[i])) { + if (rangeSet->vendClassSize[i] == req->vendClass.size && + !memcmp(req->vendClass.value, rangeSet->vendClass[i], rangeSet->vendClassSize[i])) { rangeData.vendArray[rangeSetInd] = 1; rangeData.vendFound = true; //printf("vend Found, rangeSetInd=%i\n", rangeSetInd); @@ -1307,8 +1310,8 @@ MYDWORD resad(data9 *req) { } for (MYBYTE i = 0; i < MAX_RANGE_FILTERS && req->userClass.size && rangeSet->userClassSize[i]; i++) { - if (rangeSet->userClassSize[i] == req->userClass.size - && !memcmp(req->userClass.value, rangeSet->userClass[i], rangeSet->userClassSize[i])) { + if (rangeSet->userClassSize[i] == req->userClass.size && + !memcmp(req->userClass.value, rangeSet->userClass[i], rangeSet->userClassSize[i])) { rangeData.userArray[rangeSetInd] = 1; rangeData.userFound = true; //printf("user Found, rangeSetInd=%i\n", rangeSetInd); @@ -1501,8 +1504,8 @@ MYDWORD chkaddr(data9 *req) { //printf("%s\n", hex2String(tempbuff, rangeSet->macStart[i], rangeSet->macSize[i])); //printf("%s\n", hex2String(tempbuff, rangeSet->macEnd[i], rangeSet->macSize[i])); - if (memcmp(req->dhcpp.header.bp_chaddr, rangeSet->macStart[i], rangeSet->macSize[i]) >= 0 - && memcmp(req->dhcpp.header.bp_chaddr, rangeSet->macEnd[i], rangeSet->macSize[i]) <= 0) { + if (memcmp(req->dhcpp.header.bp_chaddr, rangeSet->macStart[i], rangeSet->macSize[i]) >= 0 && + memcmp(req->dhcpp.header.bp_chaddr, rangeSet->macEnd[i], rangeSet->macSize[i]) <= 0) { rangeData.macArray[rangeSetInd] = 1; rangeData.macFound = true; //printf("mac Found, rangeSetInd=%i\n", rangeSetInd); @@ -1511,8 +1514,8 @@ MYDWORD chkaddr(data9 *req) { } for (MYBYTE i = 0; i < MAX_RANGE_FILTERS && req->vendClass.size && rangeSet->vendClassSize[i]; i++) { - if (rangeSet->vendClassSize[i] == req->vendClass.size - && !memcmp(req->vendClass.value, rangeSet->vendClass[i], rangeSet->vendClassSize[i])) { + if (rangeSet->vendClassSize[i] == req->vendClass.size && + !memcmp(req->vendClass.value, rangeSet->vendClass[i], rangeSet->vendClassSize[i])) { rangeData.vendArray[rangeSetInd] = 1; rangeData.vendFound = true; //printf("vend Found, rangeSetInd=%i\n", rangeSetInd); @@ -1521,8 +1524,8 @@ MYDWORD chkaddr(data9 *req) { } for (MYBYTE i = 0; i < MAX_RANGE_FILTERS && req->userClass.size && rangeSet->userClassSize[i]; i++) { - if (rangeSet->userClassSize[i] == req->userClass.size - && !memcmp(req->userClass.value, rangeSet->userClass[i], rangeSet->userClassSize[i])) { + if (rangeSet->userClassSize[i] == req->userClass.size && + !memcmp(req->userClass.value, rangeSet->userClass[i], rangeSet->userClassSize[i])) { rangeData.userArray[rangeSetInd] = 1; rangeData.userFound = true; //printf("user Found, rangeSetInd=%i\n", rangeSetInd); @@ -1544,12 +1547,12 @@ MYDWORD chkaddr(data9 *req) { data14 *rangeSet = &cfig.rangeSet[rangeSetInd]; rangeOK = false; - if ((!rangeData.macFound && !rangeSet->macSize[0]) - || (rangeData.macFound && rangeData.macArray[rangeSetInd])) { - if ((!rangeData.vendFound && !rangeSet->vendClassSize[0]) - || (rangeData.vendFound && rangeData.vendArray[rangeSetInd])) { - if ((!rangeData.userFound && !rangeSet->userClassSize[0]) - || (rangeData.userFound && rangeData.userArray[rangeSetInd])) { + if ((!rangeData.macFound && !rangeSet->macSize[0]) || + (rangeData.macFound && rangeData.macArray[rangeSetInd])) { + if ((!rangeData.vendFound && !rangeSet->vendClassSize[0]) || + (rangeData.vendFound && rangeData.vendArray[rangeSetInd])) { + if ((!rangeData.userFound && !rangeSet->userClassSize[0]) || + (rangeData.userFound && rangeData.userArray[rangeSetInd])) { rangeOK = true; } } @@ -1668,8 +1671,8 @@ MYDWORD sdmess(data9 *req) { //printf("repl1=%s\n", IP2String(tempbuff, cfig.zoneServers[1])); //printf("IP=%s bytes=%u replication=%i\n", IP2String(tempbuff, req->remote.sin_addr.s_addr), req->bytes, cfig.replication); - if ((cfig.replication == 1 && req->remote.sin_addr.s_addr == cfig.zoneServers[1]) - || (cfig.replication == 2 && req->remote.sin_addr.s_addr == cfig.zoneServers[0])) { + if ((cfig.replication == 1 && req->remote.sin_addr.s_addr == cfig.zoneServers[1]) || + (cfig.replication == 2 && req->remote.sin_addr.s_addr == cfig.zoneServers[0])) { recvRepl(req); } @@ -1692,8 +1695,8 @@ MYDWORD sdmess(data9 *req) { if (req->reqIP && req->reqIP == chkaddr(req) && req->dhcpEntry->expiry > t) { req->resp_type = DHCP_MESS_ACK; req->dhcpp.header.bp_yiaddr = req->reqIP; - } else if (req->dhcpp.header.bp_ciaddr && req->dhcpp.header.bp_ciaddr == chkaddr(req) - && req->dhcpEntry->expiry > t) { + } else if (req->dhcpp.header.bp_ciaddr && req->dhcpp.header.bp_ciaddr == chkaddr(req) && + req->dhcpEntry->expiry > t) { req->resp_type = DHCP_MESS_ACK; req->dhcpp.header.bp_yiaddr = req->dhcpp.header.bp_ciaddr; req->dhcpp.header.bp_ciaddr = 0; @@ -1712,8 +1715,8 @@ MYDWORD sdmess(data9 *req) { } else { return 0; } - } else if (req->dhcpp.header.bp_ciaddr && req->dhcpp.header.bp_ciaddr == chkaddr(req) - && req->dhcpEntry->expiry > t) { + } else if (req->dhcpp.header.bp_ciaddr && req->dhcpp.header.bp_ciaddr == chkaddr(req) && + req->dhcpEntry->expiry > t) { req->resp_type = DHCP_MESS_ACK; req->dhcpp.header.bp_yiaddr = req->dhcpp.header.bp_ciaddr; req->dhcpp.header.bp_ciaddr = 0; @@ -1772,8 +1775,12 @@ MYDWORD sdmess(data9 *req) { (sockaddr *)&cliAddr, sizeof(req->remote)); } else { - req->bytes = (int)sendto( - network.dhcpConn[req->sockInd].sock, req->raw, packSize, 0, (sockaddr *)&cliAddr, sizeof(req->remote)); + req->bytes = (int)sendto(network.dhcpConn[req->sockInd].sock, + req->raw, + packSize, + 0, + (sockaddr *)&cliAddr, + sizeof(req->remote)); } if (errno || req->bytes <= 0) { @@ -2173,8 +2180,8 @@ MYDWORD sendRepl(data9 *req) { req->dhcpp.header.bp_op = BOOTP_REQUEST; errno = 0; - req->bytes = (int)sendto( - cfig.dhcpReplConn.sock, req->raw, req->bytes, 0, (sockaddr *)&token.remote, sizeof(token.remote)); + req->bytes = (int) + sendto(cfig.dhcpReplConn.sock, req->raw, req->bytes, 0, (sockaddr *)&token.remote, sizeof(token.remote)); //errno = WSAGetLastError(); @@ -2278,8 +2285,10 @@ void recvRepl(data9 *req) { req->chaddr, IP2String(ipbuff, ip)); } else { - sprintf( - logBuff, "DHCP Update ignored for %s (%s) from Primary Server", req->chaddr, IP2String(ipbuff, ip)); + sprintf(logBuff, + "DHCP Update ignored for %s (%s) from Primary Server", + req->chaddr, + IP2String(ipbuff, ip)); } logDHCPMess(logBuff, 1); @@ -2367,8 +2376,10 @@ void recvRepl(data9 *req) { } } else { if (cfig.replication == 1) { - sprintf( - logBuff, "DHCP Update ignored for %s (%s) from Secondary Server", req->chaddr, IP2String(ipbuff, ip)); + sprintf(logBuff, + "DHCP Update ignored for %s (%s) from Secondary Server", + req->chaddr, + IP2String(ipbuff, ip)); } else { sprintf(logBuff, "DHCP Update ignored for %s (%s) from Primary Server", req->chaddr, IP2String(ipbuff, ip)); } @@ -2735,8 +2746,10 @@ void loadOptions(FILE *f, const char *sectionName, data20 *optionData) { dp += valSize; buffsize -= (valSize + 2); } else { - sprintf( - logBuff, "Warning: section [%s] option %s, no more space for options", sectionName, raw); + sprintf(logBuff, + "Warning: section [%s] option %s, no more space for options", + sectionName, + raw); logDHCPMess(logBuff, 1); } } else { @@ -2877,11 +2890,11 @@ void loadOptions(FILE *f, const char *sectionName, data20 *optionData) { if (valType == 2 && valSize == 1 && *value < 2) { j = *value; - } else if (valType == 1 - && (!strcasecmp(value, "yes") || !strcasecmp(value, "on") || !strcasecmp(value, "true"))) { + } else if (valType == 1 && + (!strcasecmp(value, "yes") || !strcasecmp(value, "on") || !strcasecmp(value, "true"))) { j = 1; - } else if (valType == 1 - && (!strcasecmp(value, "no") || !strcasecmp(value, "off") || !strcasecmp(value, "false"))) { + } else if (valType == 1 && + (!strcasecmp(value, "no") || !strcasecmp(value, "off") || !strcasecmp(value, "false"))) { j = 0; } else if (valType == 6 && STR2INT(value) < 2) { j = STR2INT(value); @@ -2967,8 +2980,8 @@ void lockOptions(FILE *f) { MYBYTE n = sizeof(opData) / sizeof(data4); for (op_index = 0; op_index < n; op_index++) { - if (!strcasecmp(name, opData[op_index].opName) - || (opData[op_index].opTag && STR2INT(name) == opData[op_index].opTag)) { + if (!strcasecmp(name, opData[op_index].opName) || + (opData[op_index].opTag && STR2INT(name) == opData[op_index].opTag)) { break; } } @@ -3032,10 +3045,10 @@ void addDHCPRange(char *dp) { for (; m < MAX_DHCP_RANGES && cfig.dhcpRanges[m].rangeStart; m++) { range = &cfig.dhcpRanges[m]; - if ((rs >= range->rangeStart && rs <= range->rangeEnd) - || (re >= range->rangeStart && re <= range->rangeEnd) - || (range->rangeStart >= rs && range->rangeStart <= re) - || (range->rangeEnd >= rs && range->rangeEnd <= re)) { + if ((rs >= range->rangeStart && rs <= range->rangeEnd) || + (re >= range->rangeStart && re <= range->rangeEnd) || + (range->rangeStart >= rs && range->rangeStart <= re) || + (range->rangeEnd >= rs && range->rangeEnd <= re)) { sprintf(logBuff, "Warning: DHCP Range %s overlaps with another range, ignored", dp); logDHCPMess(logBuff, 1); return; @@ -3254,8 +3267,8 @@ void loadDHCP() { for (MYDWORD iip = cfig.dhcpRanges[rangeInd].rangeStart; iip <= cfig.dhcpRanges[rangeInd].rangeEnd; iip++) { MYDWORD ip = htonl(iip); - if ((cfig.dhcpRanges[rangeInd].mask | (~ip)) == UINT_MAX - || (cfig.dhcpRanges[rangeInd].mask | ip) == UINT_MAX) { + if ((cfig.dhcpRanges[rangeInd].mask | (~ip)) == UINT_MAX || + (cfig.dhcpRanges[rangeInd].mask | ip) == UINT_MAX) { cfig.dhcpRanges[rangeInd].expiry[iip - cfig.dhcpRanges[rangeInd].rangeStart] = MY_MAX_TIME; } } @@ -3380,8 +3393,8 @@ void loadDHCP() { //sprintf(logBuff, "Loading %s=%s", dhcpData.hostname, IP2String(ipbuff, dhcpData.ip)); //logDHCPMess(logBuff, 1); - if (dhcpData.expiry > (t - 31 * 24 * 3600) && dhcpData.bp_hlen <= 16 - && !findServer(network.allServers, MAX_SERVERS, dhcpData.ip)) { + if (dhcpData.expiry > (t - 31 * 24 * 3600) && dhcpData.bp_hlen <= 16 && + !findServer(network.allServers, MAX_SERVERS, dhcpData.ip)) { hex2String(mapname, dhcpData.bp_chaddr, dhcpData.bp_hlen); auto p = dhcpCache.begin(); @@ -3394,8 +3407,8 @@ void loadDHCP() { } } - if ((p != dhcpCache.end()) - && (strcasecmp(mapname, dhcpEntry->mapname) != 0 || dhcpEntry->ip != dhcpData.ip)) { + if ((p != dhcpCache.end()) && + (strcasecmp(mapname, dhcpEntry->mapname) != 0 || dhcpEntry->ip != dhcpData.ip)) { continue; } @@ -3573,8 +3586,8 @@ char *readSection(char *buff, FILE *f) { break; } - if ((*buff) >= '0' && (*buff) <= '9' || (*buff) >= 'A' && (*buff) <= 'Z' || (*buff) >= 'a' && (*buff) <= 'z' - || ((*buff) && strchr("/\\?*", (*buff)))) { + if ((*buff) >= '0' && (*buff) <= '9' || (*buff) >= 'A' && (*buff) <= 'Z' || (*buff) >= 'a' && (*buff) <= 'z' || + ((*buff) && strchr("/\\?*", (*buff)))) { return buff; } } @@ -4462,8 +4475,8 @@ void *init(void *lparam) { sprintf(logBuff, "Section [REPLICATION_SERVERS] Missing Secondary Server"); logDHCPMess(logBuff, 1); } else if (cfig.zoneServers[0] && cfig.zoneServers[1]) { - if (findServer(newNetwork.allServers, MAX_SERVERS, cfig.zoneServers[0]) - && findServer(newNetwork.allServers, MAX_SERVERS, cfig.zoneServers[1])) { + if (findServer(newNetwork.allServers, MAX_SERVERS, cfig.zoneServers[0]) && + findServer(newNetwork.allServers, MAX_SERVERS, cfig.zoneServers[1])) { sprintf(logBuff, "Section [REPLICATION_SERVERS] Primary & Secondary should be Different Boxes"); logDHCPMess(logBuff, 1); } else if (findServer(newNetwork.allServers, MAX_SERVERS, cfig.zoneServers[0])) { @@ -4684,8 +4697,9 @@ void *init(void *lparam) { SO_BROADCAST, (char *)&newNetwork.dhcpConn[i].broadCastVal, newNetwork.dhcpConn[i].broadCastSize); - int nRet = bind( - newNetwork.dhcpConn[i].sock, (sockaddr *)&newNetwork.dhcpConn[i].addr, sizeof(struct sockaddr_in)); + int nRet = bind(newNetwork.dhcpConn[i].sock, + (sockaddr *)&newNetwork.dhcpConn[i].addr, + sizeof(struct sockaddr_in)); if (nRet == SOCKET_ERROR) { close(newNetwork.dhcpConn[i].sock); @@ -4796,8 +4810,8 @@ void *init(void *lparam) { } } - if (newNetwork.httpConn.server != inet_addr("127.0.0.1") - && !findServer(newNetwork.allServers, MAX_SERVERS, newNetwork.httpConn.server)) { + if (newNetwork.httpConn.server != inet_addr("127.0.0.1") && + !findServer(newNetwork.allServers, MAX_SERVERS, newNetwork.httpConn.server)) { bindfailed = true; newNetwork.httpConn.loaded = false; sprintf(logBuff, "Warning: Section [HTTP_INTERFACE], %s not available, ignored", raw); @@ -4846,8 +4860,9 @@ void *init(void *lparam) { newNetwork.httpConn.addr.sin_addr.s_addr = newNetwork.httpConn.server; newNetwork.httpConn.addr.sin_port = htons(newNetwork.httpConn.port); - int nRet = bind( - newNetwork.httpConn.sock, (sockaddr *)&newNetwork.httpConn.addr, sizeof(struct sockaddr_in)); + int nRet = bind(newNetwork.httpConn.sock, + (sockaddr *)&newNetwork.httpConn.addr, + sizeof(struct sockaddr_in)); if (nRet == SOCKET_ERROR) { bindfailed = true; @@ -5001,8 +5016,8 @@ void getInterfaces(data1 *pNetwork) { flags = 0; } - if (addr && mask && (flags & IFF_RUNNING) && (flags & IFF_UP) && !(flags & IFF_LOOPBACK) - && !(flags & IFF_POINTOPOINT)) { + if (addr && mask && (flags & IFF_RUNNING) && (flags & IFF_UP) && !(flags & IFF_LOOPBACK) && + !(flags & IFF_POINTOPOINT)) { MYBYTE k = addServer(pNetwork->allServers, MAX_SERVERS, addr); if (k != MAX_SERVERS) { @@ -5098,8 +5113,12 @@ MYWORD gdmess(data9 *req, MYBYTE sockInd) { req->sockInd = sockInd; req->sockLen = sizeof(req->remote); errno = 0; - req->bytes = (int)recvfrom( - network.dhcpConn[sockInd].sock, req->raw, sizeof(dhcp_packet), 0, (sockaddr *)&req->remote, &req->sockLen); + req->bytes = (int)recvfrom(network.dhcpConn[sockInd].sock, + req->raw, + sizeof(dhcp_packet), + 0, + (sockaddr *)&req->remote, + &req->sockLen); if (errno || req->bytes <= 0) { return 0; diff --git a/srcs/open_dhcp/opendhcpd.h b/srcs/open_dhcp/opendhcpd.h index 815d2e3..13dd46e 100644 --- a/srcs/open_dhcp/opendhcpd.h +++ b/srcs/open_dhcp/opendhcpd.h @@ -72,7 +72,7 @@ typedef struct in_pktinfo IN_PKTINFO; #define STR2INT(val) ((int)strtol((val), nullptr, 10)) -struct data7//cache +struct data7 //cache { char *mapname; time_t expiry; @@ -109,7 +109,7 @@ struct data7//cache MYBYTE data; }; -struct data71//Lump +struct data71 //Lump { char *mapname; MYBYTE *response; @@ -294,10 +294,10 @@ struct data4 { bool permitted; }; -#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) \ - || defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) +#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || \ + defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) #define MY_MAX_TIME UINT_MAX -struct data8//client +struct data8 //client { union { MYDWORD filler; @@ -317,7 +317,7 @@ struct data8//client }; #else #define MY_MAX_TIME INT_MAX -struct data8//client +struct data8 //client { union { MYDWORD filler; @@ -369,7 +369,7 @@ struct dhcp_packet { MYBYTE vend_data[1024 - sizeof(dhcp_header)]; }; -struct data13//dhcp range +struct data13 //dhcp range { MYBYTE rangeSetInd; MYDWORD rangeStart; @@ -380,7 +380,7 @@ struct data13//dhcp range data7 **dhcpEntry; }; -struct data14//rangeSet +struct data14 //rangeSet { MYBYTE active; MYBYTE *macStart[MAX_RANGE_FILTERS]; @@ -431,7 +431,7 @@ struct data20 { MYBYTE rangeSetInd; }; -struct data9//dhcpRequst +struct data9 //dhcpRequst { MYDWORD lease; union { diff --git a/srcs/open_dhcp/query.cpp b/srcs/open_dhcp/query.cpp index 8da3e3f..aa9ef26 100644 --- a/srcs/open_dhcp/query.cpp +++ b/srcs/open_dhcp/query.cpp @@ -458,10 +458,7 @@ static void response_complete(void *user_data) { } } -static void proto_response_error(hw_http_response *response, - int httpCode, - const char *httpCodeStr, - int errCode) { +static void proto_response_error(hw_http_response *response, int httpCode, const char *httpCodeStr, int errCode) { cJSON *pRspMsg = cJSON_CreateObject(); cJSON_AddNumberToObject(pRspMsg, "status", errCode); @@ -473,9 +470,7 @@ static void proto_response_error(hw_http_response *response, free((void *)pStrPro); } -static void opendhcp_http_info(http_request *request, - hw_http_response *response, - void *UNUSED(user_data)) { +static void opendhcp_http_info(http_request *request, hw_http_response *response, void *UNUSED(user_data)) { hw_string status_code; hw_string content_type_name; hw_string content_type_value; @@ -518,9 +513,7 @@ static void opendhcp_http_info(http_request *request, hw_http_response_send(response, req, response_complete); } -static void opendhcp_http_get_userinfo(http_request *request, - hw_http_response *response, - void *UNUSED(user_data)) { +static void opendhcp_http_get_userinfo(http_request *request, hw_http_response *response, void *UNUSED(user_data)) { hw_string status_code; hw_string content_type_name; hw_string content_type_value; @@ -568,9 +561,7 @@ static void opendhcp_http_get_userinfo(http_request *request, hw_http_response_send(response, req, response_complete); } -static void opendhcp_http_get_alluser(http_request *request, - hw_http_response *response, - void *UNUSED(user_data)) { +static void opendhcp_http_get_alluser(http_request *request, hw_http_response *response, void *UNUSED(user_data)) { hw_string status_code; hw_string content_type_name; hw_string content_type_value; @@ -618,9 +609,7 @@ static void opendhcp_http_get_alluser(http_request *request, hw_http_response_send(response, req, response_complete); } -static void opendhcp_http_expand_rangeset(http_request *request, - hw_http_response *response, - void *UNUSED(user_data)) { +static void opendhcp_http_expand_rangeset(http_request *request, hw_http_response *response, void *UNUSED(user_data)) { hw_string status_code; hw_string content_type_name; hw_string content_type_value; diff --git a/srcs/pppoe/vcpe_pppoe.c b/srcs/pppoe/vcpe_pppoe.c index 56f1930..80add88 100644 --- a/srcs/pppoe/vcpe_pppoe.c +++ b/srcs/pppoe/vcpe_pppoe.c @@ -30,19 +30,19 @@ struct PPPOE_ERR_INFO_ { int errid; const char *errmsg; } g_pppoeErr[] = { - {PPPERR_NONE, "No error"}, - {PPPERR_PARAM, "Invalid parameter"}, - {PPPERR_OPEN, "Unable to open PPP session"}, - {PPPERR_DEVICE, "Invalid I/O device for PPP"}, - {PPPERR_ALLOC, "Unable to allocate resources"}, - {PPPERR_USER, "User interrupt"}, - {PPPERR_CONNECT, "Connection lost"}, - {PPPERR_AUTHFAIL, "Failed authentication challenge"}, - {PPPERR_PROTOCOL, "Failed to meet protocol"}, - {PPPERR_PEERDEAD, "Connection timeout"}, - {PPPERR_IDLETIMEOUT, "Idle Timeout"}, + {PPPERR_NONE, "No error" }, + {PPPERR_PARAM, "Invalid parameter" }, + {PPPERR_OPEN, "Unable to open PPP session" }, + {PPPERR_DEVICE, "Invalid I/O device for PPP" }, + {PPPERR_ALLOC, "Unable to allocate resources" }, + {PPPERR_USER, "User interrupt" }, + {PPPERR_CONNECT, "Connection lost" }, + {PPPERR_AUTHFAIL, "Failed authentication challenge"}, + {PPPERR_PROTOCOL, "Failed to meet protocol" }, + {PPPERR_PEERDEAD, "Connection timeout" }, + {PPPERR_IDLETIMEOUT, "Idle Timeout" }, {PPPERR_CONNECTTIME, "Max connect time reach max time"}, - {PPPERR_LOOPBACK, "Loopback detect"}, + {PPPERR_LOOPBACK, "Loopback detect" }, }; static struct netif *g_rawSocketIf = NULL; diff --git a/srcs/user/user_info.c b/srcs/user/user_info.c index 7b7e52d..f79b833 100644 --- a/srcs/user/user_info.c +++ b/srcs/user/user_info.c @@ -12,10 +12,10 @@ static PUSER_INFO_CONTEXT g_pUserByMacList = NULL; static uv_rwlock_t g_userLock; static USER_PARAMS g_userInfo[] = { - {0, 400, 24, 371, {0x00, 0x0C, 0x01, 0x02, 0x00, 0x03}, "user1", "password1"}, - {1, 300, 16, 12, {0x00, 0x0C, 0x01, 0x02, 0x00, 0x02}, "user2", "password1"}, - {2, 300, 14, 15, {0x00, 0x0C, 0x01, 0x02, 0x00, 0x04}, "user3", "password1"}, - {3, 400, 24, 17, {0x00, 0x0C, 0x01, 0x02, 0x00, 0x04}, "xajhuang", "aaaHuang1"}, + {0, 400, 24, 371, {0x00, 0x0C, 0x01, 0x02, 0x00, 0x03}, "user1", "password1"}, + {1, 300, 16, 12, {0x00, 0x0C, 0x01, 0x02, 0x00, 0x02}, "user2", "password1"}, + {2, 300, 14, 15, {0x00, 0x0C, 0x01, 0x02, 0x00, 0x04}, "user3", "password1"}, + {3, 400, 24, 17, {0x00, 0x0C, 0x01, 0x02, 0x00, 0x04}, "xajhuang", "aaaHuang1"}, }; void user_info_init() {