Module eco.rtnl

RTNETLINK helpers.

This module provides small helpers to build and parse common rtnetlink message headers used with eco.nl.

Typical workflow:

  1. open a NETLINK_ROUTE socket via eco.nl.open
  2. build a netlink request using eco.nl.nlmsg
  3. append an rtnetlink header (e.g. rtnl.rtgenmsg, rtnl.ifinfomsg, rtnl.rtmsg)
  4. send and receive; parse replies using rtnl.parse_ifinfomsg, etc.

Many constants from Linux headers are also exported (RTM*, IFF*, IFLA*, IFA*, RTA*, RTNLGRP*, RTMGRP*, RTSCOPE*, RTN*, RTPROT_*).

Functions

rtgenmsg (t) Build a struct rtgenmsg.
ifinfomsg (t) Build a struct ifinfomsg.
ifaddrmsg (t) Build a struct ifaddrmsg.
rtmsg (t) Build a struct rtmsg.
parse_ifinfomsg (msg) Parse struct ifinfomsg from a netlink message.
parse_ifaddrmsg (msg) Parse struct ifaddrmsg from a netlink message.
parse_rtmsg (msg) Parse struct rtmsg from a netlink message.


Functions

rtgenmsg (t)
Build a struct rtgenmsg.

Returns a binary string containing the packed C structure.

Parameters:

Returns:

    string Packed struct rtgenmsg.
ifinfomsg (t)
Build a struct ifinfomsg.

Missing fields default to 0.

Parameters:

  • t table

    Table fields:

    • family (int)
    • type (int)
    • index (int)
    • flags (int)
    • change (int)

Returns:

    string Packed struct ifinfomsg.
ifaddrmsg (t)
Build a struct ifaddrmsg.

Missing fields default to 0.

Parameters:

  • t table

    Table fields:

    • family (int)
    • prefixlen (int)
    • flags (int)
    • scope (int)
    • index (int)

Returns:

    string Packed struct ifaddrmsg.
rtmsg (t)
Build a struct rtmsg.

Missing fields default to 0.

Parameters:

  • t table

    Table fields:

    • family (int)
    • dst_len (int)
    • src_len (int)
    • tos (int)
    • table (int)
    • protocol (int)
    • scope (int)
    • type (int)
    • flags (int)

Returns:

    string Packed struct rtmsg.
parse_ifinfomsg (msg)
Parse struct ifinfomsg from a netlink message.

The input message must currently point to an RTM_NEWLINK or RTM_DELLINK message (see next).

Parameters:

  • msg nlmsg_ker A kernel message parser from eco.nl.

Returns:

    table Table fields: family, type, index, flags, change.

Or

  1. nil On failure.
  2. string Error message.
parse_ifaddrmsg (msg)
Parse struct ifaddrmsg from a netlink message.

The input message must currently point to an RTM_NEWADDR message.

Parameters:

  • msg nlmsg_ker A kernel message parser from eco.nl.

Returns:

    table Table fields: family, prefixlen, flags, scope, index.

Or

  1. nil On failure.
  2. string Error message.
parse_rtmsg (msg)
Parse struct rtmsg from a netlink message.

The input message must currently point to an RTM_NEWROUTE or RTM_DELROUTE message.

Parameters:

  • msg nlmsg_ker A kernel message parser from eco.nl.

Returns:

    table Table fields: family, dst_len, src_len, tos, table, protocol, scope, type, flags.

Or

  1. nil On failure.
  2. string Error message.
generated by LDoc 1.5.0 Last updated 2026-04-09 14:48:22