summaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2014-04-28 23:20:58 +0300
committerNick Mathewson <nickm@torproject.org>2014-12-29 09:59:47 -0500
commit28217b969eec213e7eb01bc8382fb1236eb4bbdd (patch)
tree6ee75f692cbf0c3c2e74adf6815387a39408d10b /src/common/compat.c
parenta56511e594b14e8c97605c8e12084a91028d3747 (diff)
downloadtor-28217b969eec213e7eb01bc8382fb1236eb4bbdd.tar.gz
tor-28217b969eec213e7eb01bc8382fb1236eb4bbdd.zip
Adding comprehensive test cases for resolve_my_address.
Also, improve comments on resolve_my_address to explain what it actually does.
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 470e860f52..9b040f1877 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -2061,9 +2061,20 @@ get_environment(void)
#endif
}
+/** Get name of current host and write it to <b>name</b> array, whose
+ * length is specified by <b>namelen</b> argument. Return 0 upon
+ * successfull completion; otherwise return return -1. (Currently,
+ * this function is merely a mockable wrapper for POSIX gethostname().)
+ */
+MOCK_IMPL(int,
+tor_gethostname,(char *name, size_t namelen))
+{
+ return gethostname(name,namelen);
+}
+
/** Set *addr to the IP address (in dotted-quad notation) stored in *str.
- * Return 1 on success, 0 if *str is badly formatted. (Like inet_aton(str,addr),
- * but works on Windows and Solaris.)
+ * Return 1 on success, 0 if *str is badly formatted.
+ * (Like inet_aton(str,addr), but works on Windows and Solaris.)
*/
int
tor_inet_aton(const char *str, struct in_addr* addr)
@@ -2281,8 +2292,9 @@ tor_inet_pton(int af, const char *src, void *dst)
* (This function exists because standard windows gethostbyname
* doesn't treat raw IP addresses properly.)
*/
-int
-tor_lookup_hostname(const char *name, uint32_t *addr)
+
+MOCK_IMPL(int,
+tor_lookup_hostname,(const char *name, uint32_t *addr))
{
tor_addr_t myaddr;
int ret;