diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-02-22 08:18:36 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-02-22 08:18:36 +0000 |
commit | 6e6d95b3db091d4ae107c8d4f03354ccadd20757 (patch) | |
tree | 1c5799dcfb490b15934adffa42a564d9a47f8a91 /src/common | |
parent | e8da6b26b62475114937077e88905be921937554 (diff) | |
download | tor-6e6d95b3db091d4ae107c8d4f03354ccadd20757.tar tor-6e6d95b3db091d4ae107c8d4f03354ccadd20757.tar.gz |
Change from inet_ntoa to a threadproof tor_inet_ntoa.
svn:r3656
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 11 | ||||
-rw-r--r-- | src/common/util.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 4b17454e8..339572e44 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1255,6 +1255,17 @@ parse_addr_and_port_range(const char *s, uint32_t *addr_out, 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 * ===== */ diff --git a/src/common/util.h b/src/common/util.h index 2f139515a..fde2557f5 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -126,6 +126,8 @@ int parse_addr_port(const char *addrport, char **address, uint32_t *addr, 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); |