summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2010-04-04 16:29:58 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2010-04-04 16:29:58 +0200
commit8bc402318be9f09b70cdb61d81799e90d8a64e7b (patch)
tree6eebf08f463f15d87c6a151b4cc43969588a3b70
parentbd00b928e678b3ede5dbc5abc933539fe5cc31e6 (diff)
downloadlibmnl-8bc402318be9f09b70cdb61d81799e90d8a64e7b.tar.gz
libmnl-8bc402318be9f09b70cdb61d81799e90d8a64e7b.zip
rename mnl_attr_type_invalid() by mnl_attr_type_ok()
And include the prototype in libmnl.h, since it was missing Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--examples/genl-family-get.c12
-rw-r--r--examples/rtnl-link-dump.c4
-rw-r--r--examples/rtnl-link-dump2.c4
-rw-r--r--examples/rtnl-link-dump3.c4
-rw-r--r--examples/rtnl-link-event.c4
-rw-r--r--examples/rtnl-route-dump.c8
-rw-r--r--include/libmnl/libmnl.h2
-rw-r--r--src/attr.c4
8 files changed, 22 insertions, 20 deletions
diff --git a/examples/genl-family-get.c b/examples/genl-family-get.c
index fbe1bf1..c8352ab 100644
--- a/examples/genl-family-get.c
+++ b/examples/genl-family-get.c
@@ -10,8 +10,8 @@ static int parse_mc_grps_cb(const struct nlattr *attr, void *data)
const struct nlattr **tb = (const struct nlattr **)data;
int type = mnl_attr_get_type(attr);
- if (mnl_attr_type_invalid(attr, CTRL_ATTR_MCAST_GRP_MAX) < 0) {
- perror("mnl_attr_type_invalid");
+ if (mnl_attr_type_ok(attr, CTRL_ATTR_MCAST_GRP_MAX) < 0) {
+ perror("mnl_attr_type_ok");
return MNL_CB_ERROR;
}
@@ -59,8 +59,8 @@ static int parse_family_ops_cb(const struct nlattr *attr, void *data)
const struct nlattr **tb = (const struct nlattr **)data;
int type = mnl_attr_get_type(attr);
- if (mnl_attr_type_invalid(attr, CTRL_ATTR_OP_MAX) < 0) {
- perror("mnl_attr_type_invalid");
+ if (mnl_attr_type_ok(attr, CTRL_ATTR_OP_MAX) < 0) {
+ perror("mnl_attr_type_ok");
return MNL_CB_ERROR;
}
@@ -105,8 +105,8 @@ static int data_attr_cb(const struct nlattr *attr, void *data)
const struct nlattr **tb = (const struct nlattr **)data;
int type = mnl_attr_get_type(attr);
- if (mnl_attr_type_invalid(attr, CTRL_ATTR_MAX) < 0) {
- perror("mnl_attr_type_invalid");
+ if (mnl_attr_type_ok(attr, CTRL_ATTR_MAX) < 0) {
+ perror("mnl_attr_type_ok");
return MNL_CB_ERROR;
}
diff --git a/examples/rtnl-link-dump.c b/examples/rtnl-link-dump.c
index 42843aa..b0c8e76 100644
--- a/examples/rtnl-link-dump.c
+++ b/examples/rtnl-link-dump.c
@@ -12,8 +12,8 @@ static int data_attr_cb(const struct nlattr *attr, void *data)
const struct nlattr **tb = (const struct nlattr **)data;
int type = mnl_attr_get_type(attr);
- if (mnl_attr_type_invalid(attr, IFLA_MAX) < 0) {
- perror("mnl_attr_type_invalid");
+ if (mnl_attr_type_ok(attr, IFLA_MAX) < 0) {
+ perror("mnl_attr_type_ok");
return MNL_CB_ERROR;
}
diff --git a/examples/rtnl-link-dump2.c b/examples/rtnl-link-dump2.c
index 3c62006..d333071 100644
--- a/examples/rtnl-link-dump2.c
+++ b/examples/rtnl-link-dump2.c
@@ -9,8 +9,8 @@
static int data_attr_cb(const struct nlattr *attr, void *data)
{
- if (mnl_attr_type_invalid(attr, IFLA_MAX) < 0) {
- perror("mnl_attr_type_invalid");
+ if (mnl_attr_type_ok(attr, IFLA_MAX) < 0) {
+ perror("mnl_attr_type_ok");
return MNL_CB_ERROR;
}
diff --git a/examples/rtnl-link-dump3.c b/examples/rtnl-link-dump3.c
index ce59f9f..87a15a5 100644
--- a/examples/rtnl-link-dump3.c
+++ b/examples/rtnl-link-dump3.c
@@ -25,8 +25,8 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
mnl_attr_for_each(attr, nlh, sizeof(*ifm)) {
int type = mnl_attr_get_type(attr);
- if (mnl_attr_type_invalid(attr, IFLA_MAX) < 0) {
- perror("mnl_attr_type_invalid");
+ if (mnl_attr_type_ok(attr, IFLA_MAX) < 0) {
+ perror("mnl_attr_type_ok");
return MNL_CB_ERROR;
}
switch(type) {
diff --git a/examples/rtnl-link-event.c b/examples/rtnl-link-event.c
index 84daf01..bba59cd 100644
--- a/examples/rtnl-link-event.c
+++ b/examples/rtnl-link-event.c
@@ -12,8 +12,8 @@ static int data_attr_cb(const struct nlattr *attr, void *data)
const struct nlattr **tb = (const struct nlattr **)data;
int type = mnl_attr_get_type(attr);
- if (mnl_attr_type_invalid(attr, IFLA_MAX) < 0) {
- perror("mnl_attr_type_invalid");
+ if (mnl_attr_type_ok(attr, IFLA_MAX) < 0) {
+ perror("mnl_attr_type_ok");
return MNL_CB_ERROR;
}
diff --git a/examples/rtnl-route-dump.c b/examples/rtnl-route-dump.c
index c3fd577..0d89cae 100644
--- a/examples/rtnl-route-dump.c
+++ b/examples/rtnl-route-dump.c
@@ -12,8 +12,8 @@ static int data_attr_cb2(const struct nlattr *attr, void *data)
const struct nlattr **tb = (const struct nlattr **)data;
int type = mnl_attr_get_type(attr);
- if (mnl_attr_type_invalid(attr, RTAX_MAX) < 0) {
- perror("mnl_attr_type_invalid");
+ if (mnl_attr_type_ok(attr, RTAX_MAX) < 0) {
+ perror("mnl_attr_type_ok");
return MNL_CB_ERROR;
}
if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0) {
@@ -68,8 +68,8 @@ static int data_attr_cb(const struct nlattr *attr, void *data)
const struct nlattr **tb = (const struct nlattr **)data;
int type = mnl_attr_get_type(attr);
- if (mnl_attr_type_invalid(attr, RTA_MAX) < 0) {
- perror("mnl_attr_type_invalid");
+ if (mnl_attr_type_ok(attr, RTA_MAX) < 0) {
+ perror("mnl_attr_type_ok");
return MNL_CB_ERROR;
}
diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index efdae74..ac488a7 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -86,6 +86,8 @@ extern void mnl_attr_put_str(struct nlmsghdr *nlh, int type, const void *data);
extern void mnl_attr_put_str_null(struct nlmsghdr *nlh, int type, const void *data);
/* TLV validation */
+extern int mnl_attr_type_ok(const struct nlattr *attr, int maxtype);
+
enum mnl_attr_data_type {
MNL_TYPE_UNSPEC,
MNL_TYPE_U8,
diff --git a/src/attr.c b/src/attr.c
index f0828c0..75c856b 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -96,7 +96,7 @@ struct nlattr *mnl_attr_next(const struct nlattr *attr, int *len)
}
/**
- * mnl_attr_type_invalid - check if the attribute type is valid
+ * mnl_attr_type_ok - check if the attribute type is valid
* @attr: pointer to attribute to be checked
* @max: maximum attribute type
*
@@ -104,7 +104,7 @@ struct nlattr *mnl_attr_next(const struct nlattr *attr, int *len)
* maximum supported type. If the attribute type is invalid, this function
* returns -1 and errno is explicitly set.
*/
-int mnl_attr_type_invalid(const struct nlattr *attr, int max)
+int mnl_attr_type_ok(const struct nlattr *attr, int max)
{
if (mnl_attr_get_type(attr) > max) {
errno = EINVAL;