diff --git a/gst/udp/gstudpnetutils.c b/gst/udp/gstudpnetutils.c
index a1588ca..b1f864e 100644
--- a/gst/udp/gstudpnetutils.c
+++ b/gst/udp/gstudpnetutils.c
@@ -115,12 +115,17 @@ beach:
 int
 gst_udp_set_loop_ttl (int sockfd, gboolean loop, int ttl)
 {
+  socklen_t socklen;
+  struct sockaddr_storage addr;
   int ret = -1;
-
-#if 0
   int l = (loop == FALSE) ? 0 : 1;
 
-  switch (addr->ss_family) {
+  socklen = sizeof (addr);
+  if ((ret = getsockname (sockfd, (struct sockaddr *) &addr, &socklen)) < 0) {
+    return ret;
+  }
+
+  switch (addr.ss_family) {
     case AF_INET:
     {
       if ((ret =
@@ -151,7 +156,6 @@ gst_udp_set_loop_ttl (int sockfd, gboolean loop, int ttl)
     default:
       errno = EAFNOSUPPORT;
   }
-#endif
   return ret;
 }
 
