iproute2/tipc/msg.c
<<
>>
Prefs
   1/*
   2 * msg.c        Messaging (netlink) helper functions.
   3 *
   4 *              This program is free software; you can redistribute it and/or
   5 *              modify it under the terms of the GNU General Public License
   6 *              as published by the Free Software Foundation; either version
   7 *              2 of the License, or (at your option) any later version.
   8 *
   9 * Authors:     Richard Alpe <richard.alpe@ericsson.com>
  10 */
  11
  12#include <stdio.h>
  13#include <time.h>
  14#include <errno.h>
  15
  16#include <libmnl/libmnl.h>
  17
  18#include "mnl_utils.h"
  19#include "msg.h"
  20
  21extern struct mnlu_gen_socket tipc_nlg;
  22
  23int parse_attrs(const struct nlattr *attr, void *data)
  24{
  25        const struct nlattr **tb = data;
  26        int type = mnl_attr_get_type(attr);
  27
  28        tb[type] = attr;
  29
  30        return MNL_CB_OK;
  31}
  32
  33int msg_doit(struct nlmsghdr *nlh, mnl_cb_t callback, void *data)
  34{
  35        nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
  36        return mnlu_gen_socket_sndrcv(&tipc_nlg, nlh, callback, data);
  37}
  38
  39int msg_dumpit(struct nlmsghdr *nlh, mnl_cb_t callback, void *data)
  40{
  41        nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
  42        return mnlu_gen_socket_sndrcv(&tipc_nlg, nlh, callback, data);
  43}
  44
  45struct nlmsghdr *msg_init(int cmd)
  46{
  47        struct nlmsghdr *nlh;
  48
  49        nlh = mnlu_gen_socket_cmd_prepare(&tipc_nlg, cmd, 0);
  50
  51        return nlh;
  52}
  53