This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
thread safe inet_ntoa
- From: Matt Jerdonek <maj1224 at yahoo dot com>
- To: Patches eCos <ecos-patches at sources dot redhat dot com>
- Date: Tue, 9 Dec 2003 11:14:32 -0800 (PST)
- Subject: thread safe inet_ntoa
Copied from FreeBSD ...
-- Matt
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
? inet_ntoa.pat
Index: bsd_tcpip/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/ChangeLog,v
retrieving revision 1.37
diff -u -r1.37 ChangeLog
--- bsd_tcpip/current/ChangeLog 22 Nov 2003 12:59:20 -0000 1.37
+++ bsd_tcpip/current/ChangeLog 9 Dec 2003 19:06:41 -0000
@@ -1,3 +1,6 @@
+2003-12-09 Matt Jerdonek <maj1224@yahoo.com>
+ * include/netinet/in.h: Added prototype for inet_ntoa_r
+
2003-11-22 Andrew Lunn <andrew.lunn@ascom.ch>
* include/net/if_gif.h include/net/if_sec.h include/net/zlib.h
Index: bsd_tcpip/current/include/netinet/in.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/include/netinet/in.h,v
retrieving revision 1.4
diff -u -r1.4 in.h
--- bsd_tcpip/current/include/netinet/in.h 24 Jul 2003 18:04:24 -0000 1.4
+++ bsd_tcpip/current/include/netinet/in.h 9 Dec 2003 19:06:53 -0000
@@ -517,6 +517,7 @@
u_short in_addword __P((u_short, u_short));
int in_localaddr __P((struct in_addr));
char *inet_ntoa __P((struct in_addr));
+char *inet_ntoa_r __P((struct in_addr ina, char *buf));
#endif
Index: common/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/ChangeLog,v
retrieving revision 1.53
diff -u -r1.53 ChangeLog
--- common/current/ChangeLog 27 Nov 2003 15:24:13 -0000 1.53
+++ common/current/ChangeLog 9 Dec 2003 19:07:56 -0000
@@ -1,3 +1,7 @@
+2003-12-09 Matt Jerdonek <maj1224@yahoo.com>
+ * src/inet_ntoa.c: Added thread-safe inet_ntoa_r, from FreeBSD
+ * include/arpa/inet.h and include/net/netdb: Add prototype
+
2003-11-25 Manu Sharma <manu.sharma@ascom.com>
* tests/bridge.c: Changes to enable Spanning Tree Protocol if the
Index: common/current/include/arpa/inet.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/include/arpa/inet.h,v
retrieving revision 1.1
diff -u -r1.1 inet.h
--- common/current/include/arpa/inet.h 20 May 2002 22:25:03 -0000 1.1
+++ common/current/include/arpa/inet.h 9 Dec 2003 19:07:57 -0000
@@ -67,6 +67,7 @@
extern unsigned long inet_netof __P((struct in_addr));
extern unsigned long inet_network __P((const char *));
extern char *inet_ntoa __P((struct in_addr));
+extern char *inet_ntoa_r __P((struct in_addr ina, char *buf));
__END_DECLS
#endif /* !_ARPA_INET_H_ */
Index: common/current/include/net/netdb.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/include/net/netdb.h,v
retrieving revision 1.4
diff -u -r1.4 netdb.h
--- common/current/include/net/netdb.h 15 Jul 2003 08:45:16 -0000 1.4
+++ common/current/include/net/netdb.h 9 Dec 2003 19:07:58 -0000
@@ -135,6 +135,7 @@
// Miscellaneous address manipulation functions
#include <netinet/in.h>
char *inet_ntoa(struct in_addr);
+char *inet_ntoa_r(struct in_addr, char *buf);
char *inet_ntop(int af, const char *src, char *dst, size_t len);
int inet_pton(int af, const char *src, char *dst);
char *_inet_ntop(struct sockaddr *sa, char *dst, size_t len);
Index: common/current/src/inet_ntoa.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/src/inet_ntoa.c,v
retrieving revision 1.1
diff -u -r1.1 inet_ntoa.c
--- common/current/src/inet_ntoa.c 20 May 2002 22:25:05 -0000 1.1
+++ common/current/src/inet_ntoa.c 9 Dec 2003 19:07:59 -0000
@@ -68,3 +68,17 @@
return buf;
}
+char *
+inet_ntoa_r(struct in_addr ina, char *buf)
+{
+ unsigned char *ucp = (unsigned char *)&ina;
+
+ sprintf(buf, "%d.%d.%d.%d",
+ ucp[0] & 0xff,
+ ucp[1] & 0xff,
+ ucp[2] & 0xff,
+ ucp[3] & 0xff);
+ return buf;
+}
+
+