]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
ip_ntop() and ip_ntox() for IPv4.
authorMartin Mares <mj@ucw.cz>
Wed, 17 Jun 1998 14:28:46 +0000 (14:28 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 17 Jun 1998 14:28:46 +0000 (14:28 +0000)
lib/ipv4.c

index cc673733c034739e47f67bdaaee3191457f9970b..9aa79c26a708af227eefae9d381c9affb68e398f 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "nest/bird.h"
 #include "lib/ip.h"
+#include "lib/string.h"
 
 int
 ipv4_classify(u32 a)
@@ -30,4 +31,23 @@ ipv4_classify(u32 a)
   return IADDR_INVALID;
 }
 
+char *
+ip_ntop(ip_addr a, char *b)
+{
+  u32 x = _I(a);
+
+  return b + bsprintf(b, "%d.%d.%d.%d",
+                     ((x >> 24) & 0xff),
+                     ((x >> 16) & 0xff),
+                     ((x >> 8) & 0xff),
+                     (x & 0xff));
+}
+
+
+char *
+ip_ntox(ip_addr a, char *b)
+{
+  return b + bsprintf(b, "%08x", _I(a));
+}
+
 #endif