[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Change from inet_ntoa to a threadproof tor_inet_ntoa.



Update of /home/or/cvsroot/tor/src/common
In directory moria.mit.edu:/tmp/cvs-serv20997/src/common

Modified Files:
	util.c util.h 
Log Message:
Change from inet_ntoa to a threadproof tor_inet_ntoa.

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.202
retrieving revision 1.203
diff -u -d -r1.202 -r1.203
--- util.c	22 Feb 2005 07:18:46 -0000	1.202
+++ util.c	22 Feb 2005 08:18:34 -0000	1.203
@@ -1255,6 +1255,17 @@
   return -1;
 }
 
+int
+tor_inet_ntoa(struct in_addr *in, char *buf, size_t buf_len)
+{
+  uint32_t a = ntohl(in->s_addr);
+  return tor_snprintf(buf, buf_len, "%d.%d.%d.%d",
+                      (int)(uint8_t)((a>>24)&0xff),
+                      (int)(uint8_t)((a>>16)&0xff),
+                      (int)(uint8_t)((a>>8 )&0xff),
+                      (int)(uint8_t)((a    )&0xff));
+}
+
 /* =====
  * Process helpers
  * ===== */

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.h,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -d -r1.128 -r1.129
--- util.h	3 Feb 2005 07:25:10 -0000	1.128
+++ util.h	22 Feb 2005 08:18:34 -0000	1.129
@@ -126,6 +126,8 @@
 int parse_addr_and_port_range(const char *s, uint32_t *addr_out,
                               uint32_t *mask_out, uint16_t *port_min_out,
                               uint16_t *port_max_out);
+#define INET_NTOA_BUF_LEN 16
+int tor_inet_ntoa(struct in_addr *in, char *buf, size_t buf_len);
 
 /* Process helpers */
 void start_daemon(const char *desired_cwd);