From 245a3831d7266913b0281bfa19058b59ac80818b Mon Sep 17 00:00:00 2001 From: spv420 Date: Sat, 23 Apr 2022 18:22:31 -0400 Subject: big b0i --- src/gen/ip_tools.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/gen/ip_tools.c (limited to 'src/gen/ip_tools.c') diff --git a/src/gen/ip_tools.c b/src/gen/ip_tools.c new file mode 100644 index 0000000..6e36b64 --- /dev/null +++ b/src/gen/ip_tools.c @@ -0,0 +1,24 @@ +/* + * ip_tools + */ + +#include +#include +#include + +#include "ip_tools.h" + +char* uint32_t_to_ip(uint32_t val) { + uint8_t byte1 = (val >> 0) & 0xff; + uint8_t byte2 = (val >> 8) & 0xff; + uint8_t byte3 = (val >> 16) & 0xff; + uint8_t byte4 = (val >> 24) & 0xff; + char* ret = NULL; + + asprintf(&ret, "%u.%u.%u.%u", + byte1, + byte2, + byte3, + byte4); + return ret; +} \ No newline at end of file -- cgit v1.2.3