2 * netlink-local.h Local Netlink Interface
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
12 #ifndef NETLINK_LOCAL_H_
13 #define NETLINK_LOCAL_H_
26 #include <sys/types.h>
27 #include <sys/socket.h>
32 #include <arpa/inet.h>
36 #define SOL_NETLINK 270
39 #include <linux/types.h>
41 /* local header copies */
43 #include <linux/if_arp.h>
44 #include <linux/if_ether.h>
45 #include <linux/pkt_sched.h>
46 #include <linux/pkt_cls.h>
47 #include <linux/gen_stats.h>
49 #include <netlink/netlink.h>
50 #include <netlink/handlers.h>
51 #include <netlink/cache.h>
52 #include <netlink/object-api.h>
53 #include <netlink/cache-api.h>
54 #include <netlink-types.h>
61 #define __ADD(id, name) { .i = id, .a = #name },
66 struct nl_list_head list
;
71 #define NL_DBG(LVL,FMT,ARG...) \
76 fprintf(stderr, "BUG: %s:%d\n", \
77 __FILE__, __LINE__); \
81 extern int __nl_read_num_str_file(const char *path
,
82 int (*cb
)(long, const char *));
84 extern int __trans_list_add(int, const char *, struct nl_list_head
*);
85 extern void __trans_list_clear(struct nl_list_head
*);
87 extern char *__type2str(int, char *, size_t, struct trans_tbl
*, size_t);
88 extern int __str2type(const char *, struct trans_tbl
*, size_t);
90 extern char *__list_type2str(int, char *, size_t, struct nl_list_head
*);
91 extern int __list_str2type(const char *, struct nl_list_head
*);
93 extern char *__flags2str(int, char *, size_t, struct trans_tbl
*, size_t);
94 extern int __str2flags(const char *, struct trans_tbl
*, size_t);
96 extern void dump_from_ops(struct nl_object
*, struct nl_dump_params
*);
98 static inline struct nl_cache
*dp_cache(struct nl_object
*obj
)
100 if (obj
->ce_cache
== NULL
)
101 return nl_cache_mngt_require(obj
->ce_ops
->oo_name
);
103 return obj
->ce_cache
;
106 static inline int nl_cb_call(struct nl_cb
*cb
, int type
, struct nl_msg
*msg
)
108 return cb
->cb_set
[type
](msg
, cb
->cb_args
[type
]);
111 #define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
113 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
116 #define __init __attribute__ ((constructor))
117 #define __exit __attribute__ ((destructor))
119 #define __deprecated __attribute__ ((deprecated))
121 #define min(x,y) ({ \
122 typeof(x) _x = (x); \
123 typeof(y) _y = (y); \
124 (void) (&_x == &_y); \
125 _x < _y ? _x : _y; })
127 #define max(x,y) ({ \
128 typeof(x) _x = (x); \
129 typeof(y) _y = (y); \
130 (void) (&_x == &_y); \
131 _x > _y ? _x : _y; })
133 extern int nl_cache_parse(struct nl_cache_ops
*, struct sockaddr_nl
*,
134 struct nlmsghdr
*, struct nl_parser_param
*);
137 static inline char *nl_cache_name(struct nl_cache
*cache
)
139 return cache
->c_ops
? cache
->c_ops
->co_name
: "unknown";
142 #define GENL_FAMILY(id, name) \
144 { id, NL_ACT_UNSPEC, name }, \
145 END_OF_MSGTYPES_LIST, \
148 static inline int wait_for_ack(struct nl_sock
*sk
)
150 if (sk
->s_flags
& NL_NO_AUTO_ACK
)
153 return nl_wait_for_ack(sk
);
This page took 0.04688 seconds and 5 git commands to generate.