Chinaunix首页 | 论坛 | 博客
  • 博客访问: 21779
  • 博文数量: 8
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 75
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-26 19:07
文章分类
文章存档

2010年(8)

我的朋友

分类: C/C++

2010-04-26 19:22:09

MAN PAGE OF LIBNETLINK
 
NAME
       libnetlink - A library for accessing the netlink service
 
       libnetlink provides a higher level interface to rtnetlink(7). The read functions return 0 on success and a negative errno on failure. The send functions return the amount of data sent, or -1 on error.
 
       libnetlink为renetlink(7)提供了一个高层接口.read()函数成功时返回0,失败返回负的错误代码。send()函数成功时返回发送的数据长度,失败时返回-1。

SYNOPSIS & DESCRIPTIONS

       #include
       #include
       #include
       #include

       int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
 
              Open a rtnetlink socket and save the state into the rth handle. This handle is passed to all subsequent calls. subscriptions is a bitmap of the rtnetlink multicast groups the socket will be a member of.
 
              打开一个rtnetlink套接口并将状态信息存放到rth中。rth句柄将被传给所有后续的调用。subscriptions是该socket所属rtnetlink多播组的bitmap。

       int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
 
              Request a full dump of the type database for family addresses. type is a rtnetlink message type.
 
              请求dump掉family指定的type数据库,type是一种netlink消息类型。

       int rtnl_send(struct rtnl_handle *rth, char *buf, int len)
 
              Send the rtnetlink message in buf of length len to handle rth.

       int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
 
              Request a full dump of the type data buffer into buf with maximum length of len. type is a rtnetlink message type.

       int rtnl_dump_filter(struct rtnl_handle *rth,
                      int (*filter)(struct sockaddr_nl *, struct nlmsghdr *n, void *),
                      void *arg1,
                      int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
                      void *arg2)
 
              Receive netlink data after a request and filter it. The filter callback checks if the received message is wanted. It gets the source address of the message, the message itself and arg1 as arguments. 0 as return means that the filter passed, a negative value is returned by rtnl_dump_filter in case of error. NULL for filter means to not use a filter. junk is used to filter messages not destined to the local socket. Only one message bundle is received. Unless there is no message pending, this function does not block.

       int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
                  unsigned groups, struct nlmsghdr *answer,
                  int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
                  void *jarg)

       int rtnl_listen(struct rtnl_handle *rtnl,
                  int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
                  void *jarg)
 
              Receive netlink data after a request and pass it to handler. handler is a callback that gets the message source address, the message itself, and the jarg cookie as arguments. It will get called for all received messages. Only one message bundle is received. Unless there is no message pending this function does not block.
 
              请求之后接收netlink数据,并将数据传递给rth句柄。handle是一个回调函数,其参数为消息源地址、消息头和jarg cookie。它将被所有收到的消息所调用,但只有一个message bundle被接收。该函数不阻塞,除非所有消息都被已处理。
 
       int rtnl_from_file(FILE *rtnl,
                  int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
                  void *jarg)
 
              Works like rtnl_listen, but reads a netlink message bundle from the file file and passes the messages to handler for parsing. The file contains raw data as received from a rtnetlink socket.

       int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data)
 
              Add a __u32 attribute of type type and with value data to netlink message n, which is part of a buffer of length maxlen.

       int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen)
 
              Add a variable length attribute of type type and with value data and alen length to netlink message n, which is part of a buffer of length maxlen. data is copied.

       int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data)
 
              Initialize the rtnetlink attribute rta with a __u32 data value.

       int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen)
 
              Initialize the rtnetlink attribute rta with a variable length data value.

BUGS

       The functions sometimes use fprintf and exit when a fatal error occurs. This library should be named librtnetlink.

AUTHORS

       netlink/rtnetlink was designed and writen by Alexey Kuznetsov. Andi Kleen wrote the man page.

SEE ALSO

       netlink(7), rtnetlink(7)
       /usr/include/linux/rtnetlink.h
阅读(1750) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:Linux操作系统下的时间设置方法介绍

给主人留下些什么吧!~~