Subject: | RFE: Support for RTA_CACHEINFO (rta_cacheinfo structure) - Patch attached |
Good morning.
Please see attached a proposed patch in order to add support for following structure:
struct rta_cacheinfo {
__u32 rta_clntref;
__u32 rta_lastuse;
__s32 rta_expires;
__u32 rta_error;
__u32 rta_used;
#define RTNETLINK_HAVE_PEERINFO 1
__u32 rta_id;
__u32 rta_ts;
__u32 rta_tsage;
};
Data to be used as $msg->nlattrs->{'cacheinfo'}->{'rta_expires'} for example.
Use case: IPv6 routes have parameters like an expiration counter which applications may want to retrieve.
Subject: | diff.txt |
diff -cr Socket-Netlink-Route-0.05.orig/lib/IO/Socket/Netlink/Route.pm Socket-Netlink-Route-0.05/lib/IO/Socket/Netlink/Route.pm
*** Socket-Netlink-Route-0.05.orig/lib/IO/Socket/Netlink/Route.pm 2012-03-25 19:57:49.000000000 +0200
--- Socket-Netlink-Route-0.05/lib/IO/Socket/Netlink/Route.pm 2015-03-14 09:43:10.596152053 +0100
***************
*** 366,372 ****
use base qw( IO::Socket::Netlink::Route::_Message );
use Carp;
! use Socket::Netlink::Route qw( :DEFAULT pack_rtmsg unpack_rtmsg );
=head2 RtMsg
--- 366,375 ----
use base qw( IO::Socket::Netlink::Route::_Message );
use Carp;
! use Socket::Netlink::Route qw( :DEFAULT
! pack_rtmsg unpack_rtmsg
! pack_rta_cacheinfo unpack_rta_cacheinfo
! );
=head2 RtMsg
***************
*** 455,473 ****
=item * metrics => INT
=back
=cut
__PACKAGE__->has_nlattrs(
"rtm",
! dst => [ RTA_DST, "protaddr" ],
! src => [ RTA_SRC, "protaddr" ],
! iif => [ RTA_IIF, "u32" ],
! oif => [ RTA_OIF, "u32" ],
! gateway => [ RTA_GATEWAY, "protaddr" ],
! priority => [ RTA_PRIORITY, "u32" ],
! metrics => [ RTA_METRICS, "u32" ],
);
=head3 $message->src
--- 458,479 ----
=item * metrics => INT
+ =item * cacheinfo => struct rta_cacheinfo
+
=back
=cut
__PACKAGE__->has_nlattrs(
"rtm",
! dst => [ RTA_DST, "protaddr" ],
! src => [ RTA_SRC, "protaddr" ],
! iif => [ RTA_IIF, "u32" ],
! oif => [ RTA_OIF, "u32" ],
! gateway => [ RTA_GATEWAY, "protaddr" ],
! priority => [ RTA_PRIORITY, "u32" ],
! metrics => [ RTA_METRICS, "u32" ],
! cacheinfo => [ RTA_CACHEINFO, "cacheinfo" ],
);
=head3 $message->src
***************
*** 518,523 ****
--- 524,532 ----
sub src { shift->_srcdst('src',@_) }
sub dst { shift->_srcdst('dst',@_) }
+ sub pack_nlattr_cacheinfo { pack_rta_cacheinfo $_[1] }
+ sub unpack_nlattr_cacheinfo { unpack_rta_cacheinfo $_[1] }
+
package IO::Socket::Netlink::Route::_NdMsg;
use base qw( IO::Socket::Netlink::Route::_Message );
diff -cr Socket-Netlink-Route-0.05.orig/lib/Socket/Netlink/Route_const.pm.PL Socket-Netlink-Route-0.05/lib/Socket/Netlink/Route_const.pm.PL
*** Socket-Netlink-Route-0.05.orig/lib/Socket/Netlink/Route_const.pm.PL 2012-03-25 19:57:49.000000000 +0200
--- Socket-Netlink-Route-0.05/lib/Socket/Netlink/Route_const.pm.PL 2015-03-14 09:37:51.694590181 +0100
***************
*** 138,143 ****
--- 138,149 ----
ndm_type => member_numeric,
];
+ structure "struct rta_cacheinfo",
+ arg_style => "hashref",
+ members => [
+ map { $_ => member_numeric } qw( rta_clntref rta_lastuse rta_expires rta_error rta_used rta_id rta_ts rta_tsage ),
+ ];
+
constant "NUD_$_" for qw( INCOMPLETE REACHABLE STALE DELAY PROBE FAILED NOARP
PERMANENT );