BOOL PrivateIP(const char *ip) { if (ip) { if (strcmp(ip, "") != 0) { char *token, ipbuf[32]; strncpy(ipbuf, ip, sizeof(ipbuf)); if ((token=strtok(ipbuf, ".")) != NULL) { int ip1 = atoi(token); if ((token=strtok(NULL, ".")) != NULL) { int ip2 = atoi(token); if ((ip1 == 10) // Class A Private Network || (ip1 == 172 && ip2 > 15 && ip2 < 32) // Class B Private Network || (ip1 == 192 && ip2 == 168)) // Class C Private Network return TRUE; } } } } return FALSE; }