Logo Search packages:      
Sourcecode: libnl version File versions  Download package

struct nl_msg* flnl_lookup_build_request ( struct flnl_request *  req,
int  flags 
) [read]

Builds a netlink request message to do a lookup

  • req Requested match.
  • flags additional netlink message flags
Builds a new netlink message requesting a change of link attributes. The netlink message header isn't fully equipped with all relevant fields and must be sent out via nl_send_auto_complete() or supplemented as needed. old must point to a link currently configured in the kernel and tmpl must contain the attributes to be changed set via rtnl_link_set_* functions.

New netlink message
Not all attributes can be changed, see Changeable Attributes for more details.

Definition at line 221 of file lookup.c.

References flnl_request_get_addr(), flnl_request_get_fwmark(), flnl_request_get_scope(), flnl_request_get_table(), flnl_request_get_tos(), nl_addr_get_binary_addr(), nlmsg_append(), and nlmsg_free().

Referenced by flnl_lookup().

      struct nl_msg *msg;
      struct nl_addr *addr;
      uint64_t fwmark;
      int tos, scope, table;
      struct fib_result_nl fr = {0};

      fwmark = flnl_request_get_fwmark(req);
      tos = flnl_request_get_tos(req);
      scope = flnl_request_get_scope(req);
      table = flnl_request_get_table(req);

      fr.fl_fwmark = fwmark != UINT_LEAST64_MAX ? fwmark : 0;
      fr.fl_tos = tos >= 0 ? tos : 0;
      fr.fl_scope = scope >= 0 ? scope : RT_SCOPE_UNIVERSE;
      fr.tb_id_in = table >= 0 ? table : RT_TABLE_UNSPEC;

      addr = flnl_request_get_addr(req);
      if (!addr) {
            nl_error(EINVAL, "Request must specify the address");
            return NULL;

      fr.fl_addr = *(uint32_t *) nl_addr_get_binary_addr(addr);

      msg = nlmsg_build_simple(0, flags);
      if (!msg)
            goto errout;

      if (nlmsg_append(msg, &fr, sizeof(fr), 1) < 0)
            goto errout;

      return msg;

      return NULL;

Generated by  Doxygen 1.6.0   Back to index