summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-11 08:32:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-11 08:32:26 +0000
commitb323d7d54c1f9d22799f636014a438f9da951f3f (patch)
tree331a1771e3bee4d097d3ea2bbf658d08243e70c5 /ext/socket/socket.c
parentfade664f916d001d1e2d53cbccd132f6b039fb7d (diff)
downloadruby-b323d7d54c1f9d22799f636014a438f9da951f3f.tar.gz
* ext/socket: New method, Socket.getifaddrs, implemented.
[ruby-core:54777] [Feature #8368] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 8172ae4ddb..8c5ffed836 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1584,11 +1584,22 @@ sockaddr_len(struct sockaddr *addr)
return (socklen_t)sizeof(struct sockaddr_un);
#endif
+#ifdef AF_PACKET
+ case AF_PACKET:
+ return (socklen_t)(offsetof(struct sockaddr_ll, sll_addr) + ((struct sockaddr_ll *)addr)->sll_halen);
+#endif
+
default:
return (socklen_t)(offsetof(struct sockaddr, sa_family) + sizeof(addr->sa_family));
}
}
+socklen_t
+rsock_sockaddr_len(struct sockaddr *addr)
+{
+ return sockaddr_len(addr);
+}
+
static VALUE
sockaddr_obj(struct sockaddr *addr, socklen_t len)
{
@@ -1622,6 +1633,12 @@ sockaddr_obj(struct sockaddr *addr, socklen_t len)
return rsock_addrinfo_new(addr, len, addr->sa_family, 0, 0, Qnil, Qnil);
}
+VALUE
+rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len)
+{
+ return sockaddr_obj(addr, len);
+}
+
#endif
#if defined(HAVE_GETIFADDRS) || (defined(SIOCGLIFCONF) && defined(SIOCGLIFNUM) && !defined(__hpux)) || defined(SIOCGIFCONF) || defined(_WIN32)