summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2010-10-26 23:21:50 (GMT)
committerThomas Graf <tgraf@suug.ch>2010-10-26 23:21:50 (GMT)
commit65e386c8ba490d405f539322a12e1f1c7ea2eb5c (patch)
tree155a0dafacd32619123042f926a8d1638b28ed8b /include
parentb57a697ef1053a70264e9bedea3d2b98b8b24019 (diff)
downloadlibnl-65e386c8ba490d405f539322a12e1f1c7ea2eb5c.zip
libnl-65e386c8ba490d405f539322a12e1f1c7ea2eb5c.tar.gz
libnl-65e386c8ba490d405f539322a12e1f1c7ea2eb5c.tar.bz2
Packet location updates
This patch includes various bugfixes in the packet location parser. Namely it removes two memory leaks if parsing fails. The parser is correctly quit if an allocation error occurs and it is no longer possible to add duplicates. It removes the possibility to differ between net and host byteorder. This is better done in the actual classifiers as it makes more sense to specify this together with the value to compare against. The patch also extends the API to add new packet locations via rtnl_pktloc_add(). It introduces reference counting, therefore you now have to give back packet locations with rtnl_pktloc_put() after looking them up with rtnl_pktloc_lookup(). But you are allowed to keep using them if the packet location file has been reread. The packet location file now also understands "eth", "ip", and "tcp" for "link", "net", and "transport". A --list option has been added to nl-pktloc-lookup to list all packet location definitions A --u32=VALUE option has been added to let nl-pktloc-lookup print the definition in iproute2's u32 selector style. A manual page has been written for nl-pktloc-lookup. Finally, nl-pktloc-lookup has been made installable.
Diffstat (limited to 'include')
-rw-r--r--include/netlink/errno.h3
-rw-r--r--include/netlink/route/pktloc.h13
2 files changed, 10 insertions, 6 deletions
diff --git a/include/netlink/errno.h b/include/netlink/errno.h
index c8a376e..dde12b7 100644
--- a/include/netlink/errno.h
+++ b/include/netlink/errno.h
@@ -46,8 +46,9 @@ extern "C" {
#define NLE_NOACCESS 27
#define NLE_PERM 28
#define NLE_PKTLOC_FILE 29
+#define NLE_PARSE_ERR 30
-#define NLE_MAX NLE_PKTLOC_FILE
+#define NLE_MAX NLE_PARSE_ERR
extern const char * nl_geterror(int);
extern void nl_perror(int, const char *);
diff --git a/include/netlink/route/pktloc.h b/include/netlink/route/pktloc.h
index 28e1dc2..dbca8dc 100644
--- a/include/netlink/route/pktloc.h
+++ b/include/netlink/route/pktloc.h
@@ -25,17 +25,20 @@ extern "C" {
struct rtnl_pktloc
{
char * name;
- uint8_t align:4;
- uint8_t layer:4;
- uint8_t flags;
+ uint8_t align;
+ uint8_t layer;
uint16_t offset;
uint32_t mask;
+ uint32_t refcnt;
struct nl_list_head list;
};
-extern int rtnl_pktloc_lookup(const char *, struct rtnl_pktloc **);
-
+extern int rtnl_pktloc_lookup(const char *, struct rtnl_pktloc **);
+extern void rtnl_pktloc_put(struct rtnl_pktloc *);
+extern int rtnl_pktloc_add(struct rtnl_pktloc *);
+extern void rtnl_pktloc_foreach(void (*cb)(struct rtnl_pktloc *, void *),
+ void *);
#ifdef __cplusplus
}