aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_utils.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2022-10-22 10:06:09 +0200
committerLuca Deri <deri@ntop.org>2022-10-22 10:06:09 +0200
commit24cc949f1405b0d9e0be26848168fd3df52bf6d3 (patch)
treefe212253c9cb2c66449c0228be0099595dd20449 /src/lib/ndpi_utils.c
parentc5215953831355caae06485497ee6f8e9a34c91f (diff)
Enhanced HTTP numeric IP check
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r--src/lib/ndpi_utils.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c
index ef212cc5f..255a1fa8e 100644
--- a/src/lib/ndpi_utils.c
+++ b/src/lib/ndpi_utils.c
@@ -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);
+}