GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Socket::Netlink::Generic(3) User Contributed Perl Documentation Socket::Netlink::Generic(3)

"Socket::Netlink::Generic" - interface to Linux's "NETLINK_GENERIC" netlink socket protocol

 use Socket;
 use Socket::Netlink qw( :DEFAULT
    pack_nlmsghdr unpack_nlmsghdr pack_nlattrs unpack_nlattrs );
 use Socket::Netlink::Generic qw( :DEFAULT pack_genlmsghdr unpack_genlmsghdr );
 socket( my $sock, PF_NETLINK, SOCK_RAW, NETLINK_GENERIC ) or die "socket: $!";
 send( $sock, pack_nlmsghdr( NETLINK_GENERIC, NLM_F_REQUEST, 0, 0,
                 pack_genlmsghdr( CTRL_CMD_GETFAMILY, 0,
                    pack_nlattrs( CTRL_ATTR_FAMILY_NAME, "TASKSTATS\0" )
                 ),
              ),
    0 ) or die "send: $!";
 recv( $sock, my $buffer, 65536, 0 ) or die "recv: $!";
 my %attrs = unpack_nlattrs( 
               (unpack_genlmsghdr( (unpack_nlmsghdr $buffer )[4] ) )[2]
             );
 printf "TASKSTATS family ID is %d\n",
    unpack( "S", $attrs{CTRL_ATTR_FAMILY_ID()} );

This module contains the low-level constants and structure handling functions required to use the "NETLINK_GENERIC" protocol of Linux's "PF_NETLINK" socket family. It is suggested to use the high-level object interface to this instead; see IO::Socket::Netlink::Generic.

The following sets of constants are exported:

The netlink protocol constant:

 NETLINK_GENERIC

Control commands:

 CTRL_CMD_NEWFAMILY    CTRL_CMD_DELFAMILY    CTRL_CMD_GETFAMILY
 CTRL_CMD_NEWOPS       CTRL_CMD_DELOPS       CTRL_CMD_GETOPS
 CTRL_CMD_NEWMCAST_GRP CTRL_CMD_DELMCAST_GRP CTRL_CMD_GETMCAST_GRP

Attribute IDs:

 CTRL_ATTR_FAMILY_ID    CTRL_ATTR_FAMILY_NAME CTRL_ATTR_VERSION
 CTRL_ATTR_HDRSIZE      CTRL_ATTR_MAXATTR     CTRL_ATTR_OPS
 CTRL_ATTR_MCAST_GROUPS

Nested attribute IDs:

 CTRL_ATTR_OP_ID CTRL_ATTR_OP_FLAGS
 CTRL_ATTR_MCAST_GRP_NAME CTRL_ATTR_MCAST_GRP_ID

Note that if the kernel headers are particularly old, not all of these constants may be available. If they are unavailable at compile time, no constant functions will be generated.

   $buffer = pack_genlmsghdr( $cmd, $version, $body )

   ( $cmd, $version, $body ) = unpack_genlmsghdr( $buffer )

Pack or unpack a "struct genlmsghdr" and its payload body.

  • Socket::Netlink - interface to Linux's "PF_NETLINK" socket family
  • IO::Socket::Netlink::Generic - Object interface to "NETLINK_GENERIC" netlink protocol sockets

Paul Evans <leonerd@leonerd.org.uk>

2025-07-03 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.