Enhanced HTTP numeric IP check

This commit is contained in:
Luca Deri
2022-10-22 10:06:09 +02:00
parent c521595383
commit 24cc949f14
7 changed files with 130 additions and 87 deletions
+29
View File
@@ -2835,3 +2835,32 @@ int64_t ndpi_asn1_ber_decode_length(const unsigned char *payload, int payload_le
(*value_len) += 1;
return value;
}
/* ******************************************* */
char* ndpi_intoav4(unsigned int addr, char* buf, u_int16_t bufLen) {
char *cp;
int n;
cp = &buf[bufLen];
*--cp = '\0';
n = 4;
do {
u_int byte = addr & 0xff;
*--cp = byte % 10 + '0';
byte /= 10;
if(byte > 0) {
*--cp = byte % 10 + '0';
byte /= 10;
if(byte > 0)
*--cp = byte + '0';
}
if(n > 1)
*--cp = '.';
addr >>= 8;
} while (--n > 0);
return(cp);
}