summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2010-04-03 01:30:52 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2010-04-03 01:30:52 +0200
commitccf40b8b3789193554ae13182c38ba7e69841cce (patch)
treefdc23b19a491d255cdf8f755e999d1b191280628
parentf8fb875d3e48d833c1a120e7c3f470d614cbba50 (diff)
downloadlibmnl-ccf40b8b3789193554ae13182c38ba7e69841cce.tar.gz
libmnl-ccf40b8b3789193554ae13182c38ba7e69841cce.zip
use C99 types uintXX_t instead of POSIX u_intXX_t
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/libmnl/libmnl.h25
-rw-r--r--src/attr.c38
-rw-r--r--src/msg.c2
3 files changed, 33 insertions, 32 deletions
diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index d971172..e114cef 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -1,6 +1,7 @@
#ifndef _LIBMNL_H_
#define _LIBMNL_H_
+#include <stdint.h>
#include <sys/socket.h> /* for sa_family_t */
#include <linux/netlink.h>
@@ -48,7 +49,7 @@ extern struct nlmsghdr *mnl_nlmsg_next(const struct nlmsghdr *nlh, int *len);
extern int mnl_nlmsg_seq_ok(const struct nlmsghdr *nlh, unsigned int seq);
/* Netlink header getters */
-extern u_int16_t mnl_nlmsg_get_len(const struct nlmsghdr *nlh);
+extern uint16_t mnl_nlmsg_get_len(const struct nlmsghdr *nlh);
extern void *mnl_nlmsg_get_data(const struct nlmsghdr *nlh);
extern void *mnl_nlmsg_get_data_offset(const struct nlmsghdr *nlh, int offset);
extern void *mnl_nlmsg_get_tail(const struct nlmsghdr *nlh);
@@ -62,22 +63,22 @@ extern void mnl_nlmsg_print(const struct nlmsghdr *nlh);
#define MNL_ATTR_HDRLEN mnl_align(sizeof(struct nlattr))
/* TLV attribute getters */
-extern u_int16_t mnl_attr_get_type(const struct nlattr *attr);
-extern u_int16_t mnl_attr_get_len(const struct nlattr *attr);
-extern u_int16_t mnl_attr_get_payload_len(const struct nlattr *attr);
+extern uint16_t mnl_attr_get_type(const struct nlattr *attr);
+extern uint16_t mnl_attr_get_len(const struct nlattr *attr);
+extern uint16_t mnl_attr_get_payload_len(const struct nlattr *attr);
extern void *mnl_attr_get_data(const struct nlattr *attr);
-extern u_int8_t mnl_attr_get_u8(const struct nlattr *attr);
-extern u_int16_t mnl_attr_get_u16(const struct nlattr *attr);
-extern u_int32_t mnl_attr_get_u32(const struct nlattr *attr);
-extern u_int64_t mnl_attr_get_u64(const struct nlattr *attr);
+extern uint8_t mnl_attr_get_u8(const struct nlattr *attr);
+extern uint16_t mnl_attr_get_u16(const struct nlattr *attr);
+extern uint32_t mnl_attr_get_u32(const struct nlattr *attr);
+extern uint64_t mnl_attr_get_u64(const struct nlattr *attr);
extern const char *mnl_attr_get_str(const struct nlattr *attr);
/* TLV attribute putters */
extern void mnl_attr_put(struct nlmsghdr *nlh, int type, size_t len, const void *data);
-extern void mnl_attr_put_u8(struct nlmsghdr *nlh, int type, u_int8_t data);
-extern void mnl_attr_put_u16(struct nlmsghdr *nlh, int type, u_int16_t data);
-extern void mnl_attr_put_u32(struct nlmsghdr *nlh, int type, u_int32_t data);
-extern void mnl_attr_put_u64(struct nlmsghdr *nlh, int type, u_int64_t data);
+extern void mnl_attr_put_u8(struct nlmsghdr *nlh, int type, uint8_t data);
+extern void mnl_attr_put_u16(struct nlmsghdr *nlh, int type, uint16_t data);
+extern void mnl_attr_put_u32(struct nlmsghdr *nlh, int type, uint32_t data);
+extern void mnl_attr_put_u64(struct nlmsghdr *nlh, int type, uint64_t data);
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);
diff --git a/src/attr.c b/src/attr.c
index d4a88f6..0c09aef 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -26,7 +26,7 @@
*
* This function returns the attribute type.
*/
-u_int16_t mnl_attr_get_type(const struct nlattr *attr)
+uint16_t mnl_attr_get_type(const struct nlattr *attr)
{
return attr->nla_type & NLA_TYPE_MASK;
}
@@ -37,7 +37,7 @@ u_int16_t mnl_attr_get_type(const struct nlattr *attr)
*
* This function returns the attribute length, including the attribute header.
*/
-u_int16_t mnl_attr_get_len(const struct nlattr *attr)
+uint16_t mnl_attr_get_len(const struct nlattr *attr)
{
return attr->nla_len;
}
@@ -48,7 +48,7 @@ u_int16_t mnl_attr_get_len(const struct nlattr *attr)
*
* This function returns the attribute payload-value length.
*/
-u_int16_t mnl_attr_get_payload_len(const struct nlattr *attr)
+uint16_t mnl_attr_get_payload_len(const struct nlattr *attr)
{
return attr->nla_len - MNL_ATTR_HDRLEN;
}
@@ -176,9 +176,9 @@ int mnl_attr_parse_nested(const struct nlattr *nested,
*
* This function returns the 8-bit value of a netlink attribute.
*/
-u_int8_t mnl_attr_get_u8(const struct nlattr *attr)
+uint8_t mnl_attr_get_u8(const struct nlattr *attr)
{
- return *((u_int8_t *)mnl_attr_get_data(attr));
+ return *((uint8_t *)mnl_attr_get_data(attr));
}
/**
@@ -187,9 +187,9 @@ u_int8_t mnl_attr_get_u8(const struct nlattr *attr)
*
* This function returns the 16-bit value of a netlink attribute.
*/
-u_int16_t mnl_attr_get_u16(const struct nlattr *attr)
+uint16_t mnl_attr_get_u16(const struct nlattr *attr)
{
- return *((u_int16_t *)mnl_attr_get_data(attr));
+ return *((uint16_t *)mnl_attr_get_data(attr));
}
/**
@@ -198,9 +198,9 @@ u_int16_t mnl_attr_get_u16(const struct nlattr *attr)
*
* This function returns the 32-bit value of a netlink attribute.
*/
-u_int32_t mnl_attr_get_u32(const struct nlattr *attr)
+uint32_t mnl_attr_get_u32(const struct nlattr *attr)
{
- return *((u_int32_t *)mnl_attr_get_data(attr));
+ return *((uint32_t *)mnl_attr_get_data(attr));
}
/**
@@ -211,9 +211,9 @@ u_int32_t mnl_attr_get_u32(const struct nlattr *attr)
* is align-safe since accessing 64-bit Netlink attributes is a common
* source of alignment issues.
*/
-u_int64_t mnl_attr_get_u64(const struct nlattr *attr)
+uint64_t mnl_attr_get_u64(const struct nlattr *attr)
{
- u_int64_t tmp;
+ uint64_t tmp;
memcpy(&tmp, mnl_attr_get_data(attr), sizeof(tmp));
return tmp;
}
@@ -254,9 +254,9 @@ void mnl_attr_put(struct nlmsghdr *nlh, int type, size_t len, const void *data)
* @len: netlink attribute payload size
* @data: 8-bit unsigned integer data that is stored by the new attribute
*/
-void mnl_attr_put_u8(struct nlmsghdr *nlh, int type, u_int8_t data)
+void mnl_attr_put_u8(struct nlmsghdr *nlh, int type, uint8_t data)
{
- mnl_attr_put(nlh, type, sizeof(u_int8_t), &data);
+ mnl_attr_put(nlh, type, sizeof(uint8_t), &data);
}
/**
@@ -265,9 +265,9 @@ void mnl_attr_put_u8(struct nlmsghdr *nlh, int type, u_int8_t data)
* @type: netlink attribute type
* @data: 16-bit unsigned integer data that is stored by the new attribute
*/
-void mnl_attr_put_u16(struct nlmsghdr *nlh, int type, u_int16_t data)
+void mnl_attr_put_u16(struct nlmsghdr *nlh, int type, uint16_t data)
{
- mnl_attr_put(nlh, type, sizeof(u_int16_t), &data);
+ mnl_attr_put(nlh, type, sizeof(uint16_t), &data);
}
/**
@@ -276,9 +276,9 @@ void mnl_attr_put_u16(struct nlmsghdr *nlh, int type, u_int16_t data)
* @type: netlink attribute type
* @data: 32-bit unsigned integer data that is stored by the new attribute
*/
-void mnl_attr_put_u32(struct nlmsghdr *nlh, int type, u_int32_t data)
+void mnl_attr_put_u32(struct nlmsghdr *nlh, int type, uint32_t data)
{
- mnl_attr_put(nlh, type, sizeof(u_int32_t), &data);
+ mnl_attr_put(nlh, type, sizeof(uint32_t), &data);
}
/**
@@ -287,9 +287,9 @@ void mnl_attr_put_u32(struct nlmsghdr *nlh, int type, u_int32_t data)
* @type: netlink attribute type
* @data: 64-bit unsigned integer data that is stored by the new attribute
*/
-void mnl_attr_put_u64(struct nlmsghdr *nlh, int type, u_int64_t data)
+void mnl_attr_put_u64(struct nlmsghdr *nlh, int type, uint64_t data)
{
- mnl_attr_put(nlh, type, sizeof(u_int64_t), &data);
+ mnl_attr_put(nlh, type, sizeof(uint64_t), &data);
}
/**
diff --git a/src/msg.c b/src/msg.c
index be828f5..6b603b2 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -104,7 +104,7 @@ void *mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, int size)
* This function returns the length of the netlink message by return the field
* nlmsg_len of the message.
*/
-u_int16_t mnl_nlmsg_get_len(const struct nlmsghdr *nlh)
+uint16_t mnl_nlmsg_get_len(const struct nlmsghdr *nlh)
{
return nlh->nlmsg_len;
}