aboutsummaryrefslogtreecommitdiff
path: root/src/formatip.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/formatip.c')
-rw-r--r--src/formatip.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/formatip.c b/src/formatip.c
new file mode 100644
index 0000000..f1a2fd1
--- /dev/null
+++ b/src/formatip.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include "uip.h"
+
+/* easier to copy/paste this tiny function from uip.c
+ than it would be to rebuild all of uIP for use in
+ this program! Also don't want to bloat fujiconf by
+ linking uip.a, even if it would link without a
+ recompile. */
+/*
+u16_t local_htons(u16_t val) {
+ return HTONS(val);
+}
+*/
+
+/* this version's half the size */
+static u16_t local_htons(u16_t val) {
+ __AX__ = val;
+ asm("sta tmp1");
+ asm("txa");
+ asm("ldx tmp1");
+}
+
+static char ipbuf[20];
+
+char *format_ip(uip_ipaddr_t *ip) {
+ u16_t *ipaddr = (u16_t *)ip;
+ sprintf(ipbuf, "%d.%d.%d.%d",
+ local_htons(ipaddr[0]) >> 8,
+ local_htons(ipaddr[0]) & 0xff,
+ local_htons(ipaddr[1]) >> 8,
+ local_htons(ipaddr[1]) & 0xff);
+
+ return ipbuf;
+}