Class: Nl::Linux::NlctrlResolver

Inherits:
Object
  • Object
show all
Defined in:
nl-linux/lib/nl/linux/nlctrl_resolver.rb

Overview

Resolves Generic Netlink family metadata through nlctrl.

Constant Summary collapse

FAMILY_INFO_CTRL =
Nl::Genl::FamilyInfo.new(
  id: Genl::GENL_ID_CTRL,
  multicast_groups: {}.freeze,
).freeze

Instance Method Summary collapse

Instance Method Details

#call(client, family_name) ⇒ Genl::FamilyInfo

Resolves a Generic Netlink family metadata through nlctrl.

Parameters:

Returns:



18
19
20
21
22
23
24
25
26
# File 'nl-linux/lib/nl/linux/nlctrl_resolver.rb', line 18

def call(client, family_name)
  return FAMILY_INFO_CTRL if family_name == Nlctrl::NAME

  reply = client.family(Nlctrl).do_getfamily(family_name:)
  groups = (reply.mcast_groups || []).to_h do |attributes|
    [attributes[:name].value, attributes[:id].value]
  end
  Genl::FamilyInfo.new(id: reply.family_id, multicast_groups: groups.freeze)
end