summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-06-17 14:28:46 +0000
committerMartin Mares <mj@ucw.cz>1998-06-17 14:28:46 +0000
commit97d858c590998786d4d8a16b5c1f657800d74736 (patch)
tree0845ad4bbd15810c2e409c0d1a91a626795a9c6a
parent6b5e06abb57528a091fd171dff379634fa7c4dad (diff)
ip_ntop() and ip_ntox() for IPv4.
-rw-r--r--lib/ipv4.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/ipv4.c b/lib/ipv4.c
index cc673733..9aa79c26 100644
--- a/lib/ipv4.c
+++ b/lib/ipv4.c
@@ -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