.\" -*- coding: UTF-8 -*- .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH libnetlink 3 .SH НАИМЕНОВАНИЕ libnetlink \- библиотека для доступа к сервису netlink .SH ОБЗОР .nf #include .br #include .br #include .br #include .sp int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) .sp int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) .sp int rtnl_send(struct rtnl_handle *rth, char *buf, int len) .sp int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) .sp 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) .sp int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, unsigned groups, struct nlmsghdr *answer, .br int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *), .br void *jarg) .sp int rtnl_listen(struct rtnl_handle *rtnl, int (*handler)(struct sockaddr_nl *, struct rtnl_ctrl_data *, struct nlmsghdr *n, void *), void *jarg) .sp int rtnl_from_file(FILE *rtnl, int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *jarg) .sp int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data) .sp int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen) .sp int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data) .sp int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen) .SH ОПИСАНИЕ libnetlink предоставляет интерфейс более высокого уровня к \fBrtnetlink\fP(7). Функции чтения возвращают 0 при успешном завершении, и отрицательный код errno в случае ошибки. Функции отправки возвращают объем отправленной информации, или \-1 в случае ошибки. .TP rtnl_open Open a rtnetlink socket and save the state into the \fBrth\fP handle. This handle is passed to all subsequent calls. \fBsubscriptions\fP is a bitmap of the rtnetlink multicast groups the socket will be a member of. .TP rtnl_wilddump_request .\" XXX Request a full dump of the \fBtype\fP database for \fBfamily\fP addresses. \fBtype\fP is a rtnetlink message type. .TP rtnl_dump_request Request a full dump of the \fBtype\fP data buffer into \fBbuf\fP with maximum length of \fBlen.\fP \fBtype\fP is a rtnetlink message type. .TP rtnl_dump_filter Receive netlink data after a request and filter it. The \fBfilter\fP callback checks if the received message is wanted. It gets the source address of the message, the message itself and \fBarg1\fP as arguments. 0 as return means that the filter passed, a negative value is returned by \fIrtnl_dump_filter\fP in case of error. NULL for \fIfilter\fP means to not use a filter. \fBjunk\fP is used to filter messages not destined to the local socket. Only one message bundle is received. If there is a message pending, this function does not block. .TP rtnl_listen Receive netlink data after a request and pass it to \fIhandler.\fP \fBhandler\fP is a callback that gets the message source address, anscillary data, the message itself, and the \fBjarg\fP cookie as arguments. It will get called for all received messages. Only one message bundle is received. If there is a message pending this function does not block. .TP rtnl_from_file Работает как \fIrtnl_listen\fP, но считывает набор (bundle) сообщений netlink из файла \fBfile\fP и передает сообщения обработчику \fBhandler\fP для обработки. Файл содержит "сырые" данные в том виде, в каком они были получены из сокета rtnetlink. .PP The following functions are useful to construct custom rtnetlink messages. For simple database dumping with filtering it is better to use the higher level functions above. See \fBrtnetlink\fP(3) and \fBnetlink\fP(3) on how to generate a rtnetlink message. The following utility functions require a continuous buffer that already contains a netlink message header and a rtnetlink request. .TP rtnl_send Send the rtnetlink message in \fBbuf\fP of length \fBlen\fP to handle \fBrth.\fP .TP addattr32 Добавить __u32\-атрибут типа \fBtype\fP со значением \fBdata\fP к netlink\-сообщению \fBn\fP, которое является частью буфера длиной \fBmaxlen\fP. .TP addattr_l Добавить атрибут переменной длины типа \fBtype\fP со значением \fBdata\fP и длиной \fBalen\fP к netlink\-сообщению \fBn\fP, которое являются частью буфера длиной \fBmaxlen\fP. Содержимое \fBdata\fP копируется. .TP rta_addattr32 Инициализировать rtnetlink\-атрибут \fBrta\fP __u32\-значением. .TP rta_addattr32 Инициализировать rtnetlink\-атрибут \fBrta\fP значением переменной длины. .SH ОШИБКИ This library is meant for internal use, use libmnl for new programs. Функции иногда используют fprintf и завершаются при возникновении фатальной ошибки. Эта библиотека должна быть названа librtnetlink. .SH АВТОРЫ netlink/rtnetlink был спроектирован и написан Алексеем Кузнецовым. Энди Клеен (Andi Kleen) написал страницу руководства. .SH "СМОТРИТЕ ТАКЖЕ" \fBnetlink\fP(7), \fBrtnetlink\fP(7) .br /usr/include/linux/rtnetlink.h .PP .SH ПЕРЕВОД Русский перевод этой страницы руководства разработал(и) Виктор Ерёмин . .PP Этот перевод является свободной программной документацией; он распространяется на условиях общедоступной лицензии GNU (GNU General Public License - GPL, .UR https://www.gnu.org/licenses/gpl-3.0.html .UE версии 3 или более поздней) в отношении авторского права, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ. .PP Если вы обнаружите какие-либо ошибки в переводе этой страницы руководства, пожалуйста, сообщите об этом разработчику(ам) по его(их) адресу(ам) электронной почты или по адресу .MT списка рассылки русских переводчиков .ME .