summaryrefslogtreecommitdiff
path: root/src/util/network.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-10-26 22:13:01 +0000
committerChristian Grothoff <christian@grothoff.org>2012-10-26 22:13:01 +0000
commit64d3e46cfb99a711e500fa1f114e7c44bdf10040 (patch)
tree83093d92761d5c1b8b2fded713adaa19af29274c /src/util/network.c
parentef6f05f63769263a5201636c4b7f71eaa455cdf3 (diff)
downloadgnunet-64d3e46cfb99a711e500fa1f114e7c44bdf10040.tar.gz
gnunet-64d3e46cfb99a711e500fa1f114e7c44bdf10040.zip
-bugfixes, code cleanup
Diffstat (limited to 'src/util/network.c')
-rw-r--r--src/util/network.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/util/network.c b/src/util/network.c
index 491e4fffd..fd6687c0f 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -67,6 +67,34 @@ struct GNUNET_NETWORK_Handle
67 67
68 68
69/** 69/**
70 * Test if the given protocol family is supported by this system.
71 *
72 * @param pf protocol family to test (PF_INET, PF_INET6, PF_UNIX)
73 * @return GNUNET_OK if the PF is supported
74 */
75int
76GNUNET_NETWORK_test_pf (int pf)
77{
78 int s;
79
80 s = socket (pf, SOCK_STREAM, 0);
81 if (-1 == s)
82 {
83 if (EAFNOSUPPORT == errno)
84 return GNUNET_NO;
85 fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno));
86 return GNUNET_SYSERR;
87 }
88#if WINDOWS
89 closesocket (s);
90#else
91 close (s);
92#endif
93 return GNUNET_OK;
94}
95
96
97/**
70 * Given a unixpath that is too long (larger than UNIX_PATH_MAX), 98 * Given a unixpath that is too long (larger than UNIX_PATH_MAX),
71 * shorten it to an acceptable length while keeping it unique 99 * shorten it to an acceptable length while keeping it unique
72 * and making sure it remains a valid filename (if possible). 100 * and making sure it remains a valid filename (if possible).