1Socket::Netlink::GeneriUcs(e3r)Contributed Perl DocumentSaotcikoent::Netlink::Generic(3)
2
3
4

NAME

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

SYNOPSIS

10        use Socket;
11        use Socket::Netlink qw( :DEFAULT
12           pack_nlmsghdr unpack_nlmsghdr pack_nlattrs unpack_nlattrs );
13        use Socket::Netlink::Generic qw( :DEFAULT pack_genlmsghdr unpack_genlmsghdr );
14
15        socket( my $sock, PF_NETLINK, SOCK_RAW, NETLINK_GENERIC ) or die "socket: $!";
16
17        send( $sock, pack_nlmsghdr( NETLINK_GENERIC, NLM_F_REQUEST, 0, 0,
18                        pack_genlmsghdr( CTRL_CMD_GETFAMILY, 0,
19                           pack_nlattrs( CTRL_ATTR_FAMILY_NAME, "TASKSTATS\0" )
20                        ),
21                     ),
22           0 ) or die "send: $!";
23
24        recv( $sock, my $buffer, 65536, 0 ) or die "recv: $!";
25
26        my %attrs = unpack_nlattrs(
27                      (unpack_genlmsghdr( (unpack_nlmsghdr $buffer )[4] ) )[2]
28                    );
29
30        printf "TASKSTATS family ID is %d\n",
31           unpack( "S", $attrs{CTRL_ATTR_FAMILY_ID()} );
32

DESCRIPTION

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

CONSTANTS

40       The following sets of constants are exported:
41
42       The netlink protocol constant:
43
44        NETLINK_GENERIC
45
46       Control commands:
47
48        CTRL_CMD_NEWFAMILY    CTRL_CMD_DELFAMILY    CTRL_CMD_GETFAMILY
49        CTRL_CMD_NEWOPS       CTRL_CMD_DELOPS       CTRL_CMD_GETOPS
50        CTRL_CMD_NEWMCAST_GRP CTRL_CMD_DELMCAST_GRP CTRL_CMD_GETMCAST_GRP
51
52       Attribute IDs:
53
54        CTRL_ATTR_FAMILY_ID    CTRL_ATTR_FAMILY_NAME CTRL_ATTR_VERSION
55        CTRL_ATTR_HDRSIZE      CTRL_ATTR_MAXATTR     CTRL_ATTR_OPS
56        CTRL_ATTR_MCAST_GROUPS
57
58       Nested attribute IDs:
59
60        CTRL_ATTR_OP_ID CTRL_ATTR_OP_FLAGS
61        CTRL_ATTR_MCAST_GRP_NAME CTRL_ATTR_MCAST_GRP_ID
62
63       Note that if the kernel headers are particularly old, not all of these
64       constants may be available. If they are unavailable at compile time, no
65       constant functions will be generated.
66

STRUCTURE FUNCTIONS

68   pack_genlmsghdr
69          $buffer = pack_genlmsghdr( $cmd, $version, $body )
70
71   unpack_genlmsghdr
72          ( $cmd, $version, $body ) = unpack_genlmsghdr( $buffer )
73
74       Pack or unpack a "struct genlmsghdr" and its payload body.
75

SEE ALSO

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

AUTHOR

83       Paul Evans <leonerd@leonerd.org.uk>
84
85
86
87perl v5.36.0                      2023-01-20       Socket::Netlink::Generic(3)
Impressum