зеркало из https://github.com/github/ruby.git
* ext/socket/ancdata.c (ancillary_s_ip_pktinfo): make 3rd argument
optional. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
f23292afb4
Коммит
ff955766d4
|
@ -1,3 +1,8 @@
|
|||
Wed Feb 11 16:44:20 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/ancdata.c (ancillary_s_ip_pktinfo): make 3rd argument
|
||||
optional.
|
||||
|
||||
Wed Feb 11 15:47:10 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (ary_make_shared): returns shared root array itself, and
|
||||
|
|
|
@ -221,10 +221,13 @@ ancillary_int(VALUE self)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* Socket::AncillaryData.ip_pktinfo(addr, ifindex) => ancdata
|
||||
* Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dst) => ancdata
|
||||
*
|
||||
* Returns new ancillary data for IP_PKTINFO.
|
||||
*
|
||||
* If spec_dst is not given, addr is used.
|
||||
*
|
||||
* IP_PKTINFO is not standard.
|
||||
*
|
||||
* Supported platform: GNU/Linux
|
||||
|
@ -237,16 +240,22 @@ ancillary_int(VALUE self)
|
|||
*
|
||||
*/
|
||||
static VALUE
|
||||
ancillary_s_ip_pktinfo(VALUE self, VALUE v_addr, VALUE v_ifindex, VALUE v_spec_dst)
|
||||
ancillary_s_ip_pktinfo(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
#if defined(IPPROTO_IP) && defined(IP_PKTINFO) && defined(HAVE_TYPE_STRUCT_IN_PKTINFO) /* GNU/Linux */
|
||||
VALUE v_addr, v_ifindex, v_spec_dst;
|
||||
unsigned int ifindex;
|
||||
struct sockaddr_in sa;
|
||||
struct in_pktinfo pktinfo;
|
||||
|
||||
rb_scan_args(argc, argv, "21", &v_addr, &v_ifindex, &v_spec_dst);
|
||||
|
||||
SockAddrStringValue(v_addr);
|
||||
ifindex = NUM2UINT(v_ifindex);
|
||||
SockAddrStringValue(v_spec_dst);
|
||||
if (NIL_P(v_spec_dst))
|
||||
v_spec_dst = v_addr;
|
||||
else
|
||||
SockAddrStringValue(v_spec_dst);
|
||||
|
||||
memset(&pktinfo, 0, sizeof(pktinfo));
|
||||
|
||||
|
@ -1322,7 +1331,7 @@ Init_ancdata(void)
|
|||
rb_define_method(rb_cAncillaryData, "cmsg_is?", ancillary_cmsg_is_p, 2);
|
||||
rb_define_singleton_method(rb_cAncillaryData, "int", ancillary_s_int, 4);
|
||||
rb_define_method(rb_cAncillaryData, "int", ancillary_int, 0);
|
||||
rb_define_singleton_method(rb_cAncillaryData, "ip_pktinfo", ancillary_s_ip_pktinfo, 3);
|
||||
rb_define_singleton_method(rb_cAncillaryData, "ip_pktinfo", ancillary_s_ip_pktinfo, -1);
|
||||
rb_define_method(rb_cAncillaryData, "ip_pktinfo", ancillary_ip_pktinfo, 0);
|
||||
rb_define_singleton_method(rb_cAncillaryData, "ipv6_pktinfo", ancillary_s_ipv6_pktinfo, 2);
|
||||
rb_define_method(rb_cAncillaryData, "ipv6_pktinfo", ancillary_ipv6_pktinfo, 0);
|
||||
|
|
|
@ -29,6 +29,8 @@ class TestSocketAncData < Test::Unit::TestCase
|
|||
if defined? Socket::IPV6_PKTINFO
|
||||
assert(!ancdata.cmsg_is?(:IPV6, :PKTINFO))
|
||||
end
|
||||
ancdata2 = Socket::AncillaryData.ip_pktinfo(addr, ifindex)
|
||||
assert_equal(addr.ip_address, ancdata2.ip_pktinfo[2].ip_address)
|
||||
end
|
||||
|
||||
def test_ipv6_pktinfo
|
||||
|
|
Загрузка…
Ссылка в новой задаче