Lely core libraries 2.3.4
rtnl.h
Go to the documentation of this file.
1
21#ifndef LELY_IO_INTERN_RTNL_H_
22#define LELY_IO_INTERN_RTNL_H_
23
24#include "io.h"
25
26#ifdef HAVE_LINUX_RTNETLINK_H
27
28#include <linux/rtnetlink.h>
29
35#define RTA_TAIL(rta) \
36 (struct rtattr *)((char *)(rta) + RTA_ALIGN((rta)->rta_len))
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
54typedef int io_rtnl_newlink_func_t(struct ifinfomsg *ifi, struct rtattr *rta,
55 unsigned short rtalen, void *data);
56
70int io_rtnl_socket(__u32 pid, __u32 groups);
71
87int io_rtnl_newlink(int fd, __u32 seq, __u32 pid, int ifi_index,
88 unsigned int ifi_flags, struct rtattr *rta,
89 unsigned short rtalen);
90
106int io_rtnl_getlink(int fd, __u32 seq, __u32 pid, io_rtnl_newlink_func_t *func,
107 void *data);
108
130int io_rtnl_getattr(int fd, __u32 seq, __u32 pid, int ifi_index,
131 unsigned int *pifi_flags, unsigned short type, void *data,
132 unsigned short payload);
133
152int io_rtnl_setattr(int fd, __u32 seq, __u32 pid, int ifi_index,
153 unsigned int ifi_flags, unsigned short type, const void *data,
154 unsigned short payload);
155
165static inline struct rtattr *io_rta_find(
166 struct rtattr *rta, unsigned short len, unsigned short type);
167
168static inline struct rtattr *
169io_rta_find(struct rtattr *rta, unsigned short len, unsigned short type)
170{
171 for (; RTA_OK(rta, len); rta = RTA_NEXT(rta, len)) {
172 if (rta->rta_type == type)
173 return rta;
174 }
175 return NULL;
176}
177
178#ifdef __cplusplus
179}
180#endif
181
182#endif // HAVE_LINUX_RTNETLINK_H
183
184#endif // !LELY_IO_INTERN_RTNL_H_
int io_rtnl_getattr(int fd, __u32 seq, __u32 pid, int ifi_index, unsigned int *pifi_flags, unsigned short type, void *data, unsigned short payload)
Invokes io_rtnl_getlink() and retrieves a single attribute of the specified network interface.
Definition rtnl.c:106
static struct rtattr * io_rta_find(struct rtattr *rta, unsigned short len, unsigned short type)
Finds an attribute in a list of attributes.
Definition rtnl.h:169
int io_rtnl_socket(__u32 pid, __u32 groups)
Opens an rtnetlink socket.
Definition rtnl.c:55
int io_rtnl_getlink(int fd, __u32 seq, __u32 pid, io_rtnl_newlink_func_t *func, void *data)
Sends an RTM_GETLINK request and invokes the specified callback function for each received network in...
Definition rtnl.c:97
int io_rtnl_newlink_func_t(struct ifinfomsg *ifi, struct rtattr *rta, unsigned short rtalen, void *data)
The type of a callback function invoked when an RTM_NEWLINK response is received.
Definition rtnl.h:54
int io_rtnl_newlink(int fd, __u32 seq, __u32 pid, int ifi_index, unsigned int ifi_flags, struct rtattr *rta, unsigned short rtalen)
Sends an RTM_NEWLINK request and waits until the acknowledgment is received.
Definition rtnl.c:84
int io_rtnl_setattr(int fd, __u32 seq, __u32 pid, int ifi_index, unsigned int ifi_flags, unsigned short type, const void *data, unsigned short payload)
Invokes io_rtnl_newlink() to set at most one attribute of the specified network interface.
Definition rtnl.c:179
This is the internal header file of the Windows-specific I/O declarations.