• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ustp/libnetlink.h

  1 #ifndef __LIBNETLINK_H__
  2 #define __LIBNETLINK_H__
  3 
  4 #include <stdio.h>
  5 #include <asm/types.h>
  6 #include <linux/netlink.h>
  7 #include <linux/rtnetlink.h>
  8 #include <sys/types.h>
  9 
 10 struct rtnl_handle
 11 {
 12     int fd;
 13     struct sockaddr_nl local;
 14     struct sockaddr_nl peer;
 15     __u32 seq;
 16     __u32 dump;
 17 };
 18 
 19 int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions);
 20 int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,
 21                       int protocol);
 22 void rtnl_close(struct rtnl_handle *rth);
 23 int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type);
 24 int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len);
 25 
 26 typedef int (*rtnl_filter_t)(const struct sockaddr_nl *, struct nlmsghdr *n,
 27                              void *);
 28 int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter,
 29                      void *arg1, rtnl_filter_t junk, void *arg2);
 30 int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
 31               unsigned groups, struct nlmsghdr *answer, rtnl_filter_t junk,
 32               void *jarg);
 33 int rtnl_send(struct rtnl_handle *rth, const char *buf, int);
 34 
 35 int addattr8(struct nlmsghdr *n, int maxlen, int type, __u8 data);
 36 int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data);
 37 int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
 38               int alen);
 39 int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len);
 40 int rta_addattr8(struct rtattr *rta, int maxlen, int type, __u8 data);
 41 int rta_addattr16(struct rtattr *rta, int maxlen, int type, __u16 data);
 42 int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data);
 43 int rta_addattr64(struct rtattr *rta, int maxlen, int type, __u64 data);
 44 int rta_addattr_l(struct rtattr *rta, int maxlen, int type,
 45                          const void *data, int alen);
 46 
 47 int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
 48 int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta,
 49                          int len);
 50 
 51 struct rtattr *rta_nest(struct rtattr *rta, int maxlen, int type);
 52 int rta_nest_end(struct rtattr *rta, struct rtattr *nest);
 53 
 54 #define RTA_TAIL(rta) \
 55                 ((struct rtattr *) (((void *) (rta)) + \
 56                                     RTA_ALIGN((rta)->rta_len)))
 57 
 58 #define parse_rtattr_nested(tb, max, rta) \
 59     (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta)))
 60 
 61 int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler, void *jarg);
 62 int rtnl_from_file(FILE *, rtnl_filter_t handler, void *jarg);
 63 
 64 #define NLMSG_TAIL(nmsg) \
 65     ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
 66 
 67 #endif /* __LIBNETLINK_H__ */
 68 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt