Mercurial > nand-ecoscentric
changeset 1438:a683fa782034
Add inet_ntoa_r
| author | gthomas |
|---|---|
| date | Wed, 10 Dec 2003 12:09:23 +0000 |
| parents | 40912f487083 |
| children | 0c10dc3ed9d1 |
| files | packages/net/bsd_tcpip/current/ChangeLog packages/net/bsd_tcpip/current/include/netinet/in.h packages/net/common/current/ChangeLog packages/net/common/current/include/arpa/inet.h packages/net/common/current/include/net/netdb.h packages/net/common/current/src/inet_ntoa.c packages/net/tcpip/current/ChangeLog packages/net/tcpip/current/include/netinet/in.h |
| diffstat | 8 files changed, 34 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/net/bsd_tcpip/current/ChangeLog +++ b/packages/net/bsd_tcpip/current/ChangeLog @@ -1,3 +1,7 @@ +2003-12-10 Gary Thomas <gary@mlbassoc.com> + + * include/netinet/in.h: 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
--- 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
--- a/packages/net/common/current/ChangeLog +++ b/packages/net/common/current/ChangeLog @@ -1,3 +1,11 @@ +2003-12-10 Gary Thomas <gary@mlbassoc.com> + + * 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 <manu.sharma@ascom.com> * tests/bridge.c: Changes to enable Spanning Tree Protocol if the
--- 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_ */
--- 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 <netinet/in.h> 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);
--- a/packages/net/common/current/src/inet_ntoa.c +++ b/packages/net/common/current/src/inet_ntoa.c @@ -55,16 +55,21 @@ #include <netinet/in.h> 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); }
--- a/packages/net/tcpip/current/ChangeLog +++ b/packages/net/tcpip/current/ChangeLog @@ -1,3 +1,7 @@ +2003-12-10 Gary Thomas <gary@mlbassoc.com> + + * include/netinet/in.h: Prototype for inet_ntoa_r() + 2003-11-25 Manu Sharma <manu.sharma@ascom.com> * src/sys/net/bridgestp.c: Code for Spanning Tree Protocol (STP).
--- 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))
