# HG changeset patch # User gthomas # Date 1071058163 0 # Node ID a683fa782034e7c6c34aac0502b4618c44a97860 # Parent 40912f487083cbf1f90b6ae6a7f01c40ba5c5de6 Add inet_ntoa_r diff --git a/packages/net/bsd_tcpip/current/ChangeLog b/packages/net/bsd_tcpip/current/ChangeLog --- a/packages/net/bsd_tcpip/current/ChangeLog +++ b/packages/net/bsd_tcpip/current/ChangeLog @@ -1,3 +1,7 @@ +2003-12-10 Gary Thomas + + * include/netinet/in.h: Prototype for inet_ntoa_r() + 2003-11-22 Andrew Lunn * include/net/if_gif.h include/net/if_sec.h include/net/zlib.h diff --git a/packages/net/bsd_tcpip/current/include/netinet/in.h b/packages/net/bsd_tcpip/current/include/netinet/in.h --- a/packages/net/bsd_tcpip/current/include/netinet/in.h +++ b/packages/net/bsd_tcpip/current/include/netinet/in.h @@ -517,6 +517,7 @@ u_short in_pseudo __P((u_int32_t, u_int 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, char *)); #endif diff --git a/packages/net/common/current/ChangeLog b/packages/net/common/current/ChangeLog --- a/packages/net/common/current/ChangeLog +++ b/packages/net/common/current/ChangeLog @@ -1,3 +1,11 @@ +2003-12-10 Gary Thomas + + * src/inet_ntoa.c: Add thread safe inet_ntoa_r() and change + inet_ntoa() to use it. Inspired by Matt Jerdonek. + + * include/net/netdb.h: + * include/arpa/inet.h: Prototype for inet_ntoa_r() + 2003-11-25 Manu Sharma * tests/bridge.c: Changes to enable Spanning Tree Protocol if the diff --git a/packages/net/common/current/include/arpa/inet.h b/packages/net/common/current/include/arpa/inet.h --- a/packages/net/common/current/include/arpa/inet.h +++ b/packages/net/common/current/include/arpa/inet.h @@ -67,6 +67,7 @@ extern struct in_addr inet_makeaddr __P 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, char *)); __END_DECLS #endif /* !_ARPA_INET_H_ */ diff --git a/packages/net/common/current/include/net/netdb.h b/packages/net/common/current/include/net/netdb.h --- a/packages/net/common/current/include/net/netdb.h +++ b/packages/net/common/current/include/net/netdb.h @@ -135,6 +135,7 @@ int getnameinfo (const struct sockaddr * // Miscellaneous address manipulation functions #include char *inet_ntoa(struct in_addr); +char *inet_ntoa_r(struct in_addr, char *); 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); diff --git a/packages/net/common/current/src/inet_ntoa.c b/packages/net/common/current/src/inet_ntoa.c --- a/packages/net/common/current/src/inet_ntoa.c +++ b/packages/net/common/current/src/inet_ntoa.c @@ -55,16 +55,21 @@ #include char * +inet_ntoa_r(struct in_addr ina, char *buf) +{ + unsigned char *ucp = (unsigned char *)&ina; + diag_sprintf(buf, "%d.%d.%d.%d", + ucp[0] & 0xff, + ucp[1] & 0xff, + ucp[2] & 0xff, + ucp[3] & 0xff); + return buf; +} + +char * inet_ntoa(struct in_addr ina) { - static char buf[4*sizeof "123"]; - unsigned char *ucp = (unsigned char *)&ina; - - diag_sprintf(buf, "%d.%d.%d.%d", - ucp[0] & 0xff, - ucp[1] & 0xff, - ucp[2] & 0xff, - ucp[3] & 0xff); - return buf; + static char buf[sizeof "123.456.789.012"]; + return inet_ntoa_r(ina, buf); } diff --git a/packages/net/tcpip/current/ChangeLog b/packages/net/tcpip/current/ChangeLog --- a/packages/net/tcpip/current/ChangeLog +++ b/packages/net/tcpip/current/ChangeLog @@ -1,3 +1,7 @@ +2003-12-10 Gary Thomas + + * include/netinet/in.h: Prototype for inet_ntoa_r() + 2003-11-25 Manu Sharma * src/sys/net/bridgestp.c: Code for Spanning Tree Protocol (STP). diff --git a/packages/net/tcpip/current/include/netinet/in.h b/packages/net/tcpip/current/include/netinet/in.h --- a/packages/net/tcpip/current/include/netinet/in.h +++ b/packages/net/tcpip/current/include/netinet/in.h @@ -674,6 +674,7 @@ int in_cksum __P((struct mbuf *, int) int in_localaddr __P((struct in_addr)); void in_socktrim __P((struct sockaddr_in *)); char *inet_ntoa __P((struct in_addr)); +char *inet_ntoa_r __P((struct in_addr, char *)); #define satosin(sa) ((struct sockaddr_in *)(sa)) #define sintosa(sin) ((struct sockaddr *)(sin))