diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-02-03 10:29:03 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-02-03 10:29:03 +0100 |
commit | eb7535ee4459b4422105ef65abef5bde1c83e472 (patch) | |
tree | 209879518de2fa59b4c3e7be40b8c8bb4046275f /src/attr.c | |
parent | d337d00183c27619f1eb4a84b06476658a4b7355 (diff) | |
download | libmnl-eb7535ee4459b4422105ef65abef5bde1c83e472.tar.gz libmnl-eb7535ee4459b4422105ef65abef5bde1c83e472.zip |
doc: don't show up EXPORT_SYMBOL in doxygen
Patrick reports that the doxygen output shows up EXPORT_SYMBOL
and tells how to fix this:
> I just noticed the EXPORT_SYMBOLs in libmnl showing up in
> the doxygen output. Just in case you want to avoid this,
> what I'm doing in libdect is (besides the appopriate linker
> flags):
>
> #define __visible __attribute__((visibility("default")))
>
> #define EXPORT_SYMBOL(x) typeof(x) (x) __visible
>
>
> This allows to use EXPORT_SYMBOL as in the kernel, IOW
> after the function definition.
This patch also removes -Wredundant-decls to avoid a warning in every
single use of this new approach.
Now, this looks more like the Linux kernel way of exporting symbols.
Reported-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/attr.c')
-rw-r--r-- | src/attr.c | 110 |
1 files changed, 68 insertions, 42 deletions
@@ -36,10 +36,11 @@ * * This function returns the attribute type. */ -EXPORT_SYMBOL uint16_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; } +EXPORT_SYMBOL(mnl_attr_get_type); /** * mnl_attr_get_len - get length of netlink attribute @@ -48,10 +49,11 @@ EXPORT_SYMBOL uint16_t mnl_attr_get_type(const struct nlattr *attr) * This function returns the attribute length that is the attribute header * plus the attribute payload. */ -EXPORT_SYMBOL uint16_t mnl_attr_get_len(const struct nlattr *attr) +uint16_t mnl_attr_get_len(const struct nlattr *attr) { return attr->nla_len; } +EXPORT_SYMBOL(mnl_attr_get_len); /** * mnl_attr_get_payload_len - get the attribute payload-value length @@ -59,10 +61,11 @@ EXPORT_SYMBOL uint16_t mnl_attr_get_len(const struct nlattr *attr) * * This function returns the attribute payload-value length. */ -EXPORT_SYMBOL uint16_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; } +EXPORT_SYMBOL(mnl_attr_get_payload_len); /** * mnl_attr_get_payload - get pointer to the attribute payload @@ -70,10 +73,11 @@ EXPORT_SYMBOL uint16_t mnl_attr_get_payload_len(const struct nlattr *attr) * * This function return a pointer to the attribute payload. */ -EXPORT_SYMBOL void *mnl_attr_get_payload(const struct nlattr *attr) +void *mnl_attr_get_payload(const struct nlattr *attr) { return (void *)attr + MNL_ATTR_HDRLEN; } +EXPORT_SYMBOL(mnl_attr_get_payload); /** * mnl_attr_ok - check if there is room for an attribute in a buffer @@ -91,12 +95,13 @@ EXPORT_SYMBOL void *mnl_attr_get_payload(const struct nlattr *attr) * The len parameter may be negative in the case of malformed messages during * attribute iteration, that is why we use a signed integer. */ -EXPORT_SYMBOL bool mnl_attr_ok(const struct nlattr *attr, int len) +bool mnl_attr_ok(const struct nlattr *attr, int len) { return len >= (int)sizeof(struct nlattr) && attr->nla_len >= sizeof(struct nlattr) && (int)attr->nla_len <= len; } +EXPORT_SYMBOL(mnl_attr_ok); /** * mnl_attr_next - get the next attribute in the payload of a netlink message @@ -107,10 +112,11 @@ EXPORT_SYMBOL bool mnl_attr_ok(const struct nlattr *attr, int len) * as parameter. You have to use mnl_attr_ok() to ensure that the next * attribute is valid. */ -EXPORT_SYMBOL struct nlattr *mnl_attr_next(const struct nlattr *attr) +struct nlattr *mnl_attr_next(const struct nlattr *attr) { return (struct nlattr *)((void *)attr + MNL_ALIGN(attr->nla_len)); } +EXPORT_SYMBOL(mnl_attr_next); /** * mnl_attr_type_valid - check if the attribute type is valid @@ -126,7 +132,7 @@ EXPORT_SYMBOL struct nlattr *mnl_attr_next(const struct nlattr *attr) * This leads to backward compatibility breakages in user-space. Better check * if you support an attribute, if not, skip it. */ -EXPORT_SYMBOL int mnl_attr_type_valid(const struct nlattr *attr, uint16_t max) +int mnl_attr_type_valid(const struct nlattr *attr, uint16_t max) { if (mnl_attr_get_type(attr) > max) { errno = EOPNOTSUPP; @@ -134,6 +140,7 @@ EXPORT_SYMBOL int mnl_attr_type_valid(const struct nlattr *attr, uint16_t max) } return 1; } +EXPORT_SYMBOL(mnl_attr_type_valid); static int __mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type, size_t exp_len) @@ -205,8 +212,7 @@ static const size_t mnl_attr_data_type_len[MNL_TYPE_MAX] = { * integers (u8, u16, u32 and u64) have enough room for them. This function * returns -1 in case of error, and errno is explicitly set. */ -EXPORT_SYMBOL int -mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type) +int mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type) { int exp_len; @@ -217,6 +223,7 @@ mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type) exp_len = mnl_attr_data_type_len[type]; return __mnl_attr_validate(attr, type, exp_len); } +EXPORT_SYMBOL(mnl_attr_validate); /** * mnl_attr_validate2 - validate netlink attribute (extended version) @@ -228,7 +235,7 @@ mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type) * whose size is variable. If the size of the attribute is not what we expect, * this functions returns -1 and errno is explicitly set. */ -EXPORT_SYMBOL int +int mnl_attr_validate2(const struct nlattr *attr, enum mnl_attr_data_type type, size_t exp_len) { @@ -238,6 +245,7 @@ mnl_attr_validate2(const struct nlattr *attr, enum mnl_attr_data_type type, } return __mnl_attr_validate(attr, type, exp_len); } +EXPORT_SYMBOL(mnl_attr_validate2); /** * mnl_attr_parse - parse attributes @@ -254,7 +262,7 @@ mnl_attr_validate2(const struct nlattr *attr, enum mnl_attr_data_type type, * This function propagates the return value of the callback, which can be * MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP. */ -EXPORT_SYMBOL int +int mnl_attr_parse(const struct nlmsghdr *nlh, unsigned int offset, mnl_attr_cb_t cb, void *data) { @@ -266,6 +274,7 @@ mnl_attr_parse(const struct nlmsghdr *nlh, unsigned int offset, return ret; return ret; } +EXPORT_SYMBOL(mnl_attr_parse); /** * mnl_attr_parse_nested - parse attributes inside a nest @@ -281,7 +290,7 @@ mnl_attr_parse(const struct nlmsghdr *nlh, unsigned int offset, * This function propagates the return value of the callback, which can be * MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP. */ -EXPORT_SYMBOL int +int mnl_attr_parse_nested(const struct nlattr *nested, mnl_attr_cb_t cb, void *data) { @@ -293,6 +302,7 @@ mnl_attr_parse_nested(const struct nlattr *nested, mnl_attr_cb_t cb, return ret; return ret; } +EXPORT_SYMBOL(mnl_attr_parse_nested); /** * mnl_attr_get_u8 - returns 8-bit unsigned integer attribute payload @@ -300,10 +310,11 @@ mnl_attr_parse_nested(const struct nlattr *nested, mnl_attr_cb_t cb, * * This function returns the 8-bit value of the attribute payload. */ -EXPORT_SYMBOL uint8_t mnl_attr_get_u8(const struct nlattr *attr) +uint8_t mnl_attr_get_u8(const struct nlattr *attr) { return *((uint8_t *)mnl_attr_get_payload(attr)); } +EXPORT_SYMBOL(mnl_attr_get_u8); /** * mnl_attr_get_u16 - returns 16-bit unsigned integer attribute payload @@ -311,10 +322,11 @@ EXPORT_SYMBOL uint8_t mnl_attr_get_u8(const struct nlattr *attr) * * This function returns the 16-bit value of the attribute payload. */ -EXPORT_SYMBOL uint16_t mnl_attr_get_u16(const struct nlattr *attr) +uint16_t mnl_attr_get_u16(const struct nlattr *attr) { return *((uint16_t *)mnl_attr_get_payload(attr)); } +EXPORT_SYMBOL(mnl_attr_get_u16); /** * mnl_attr_get_u32 - returns 32-bit unsigned integer attribute payload @@ -322,10 +334,11 @@ EXPORT_SYMBOL uint16_t mnl_attr_get_u16(const struct nlattr *attr) * * This function returns the 32-bit value of the attribute payload. */ -EXPORT_SYMBOL uint32_t mnl_attr_get_u32(const struct nlattr *attr) +uint32_t mnl_attr_get_u32(const struct nlattr *attr) { return *((uint32_t *)mnl_attr_get_payload(attr)); } +EXPORT_SYMBOL(mnl_attr_get_u32); /** * mnl_attr_get_u64 - returns 64-bit unsigned integer attribute. @@ -335,12 +348,13 @@ EXPORT_SYMBOL uint32_t mnl_attr_get_u32(const struct nlattr *attr) * function is align-safe, since accessing 64-bit Netlink attributes is a * common source of alignment issues. */ -EXPORT_SYMBOL uint64_t mnl_attr_get_u64(const struct nlattr *attr) +uint64_t mnl_attr_get_u64(const struct nlattr *attr) { uint64_t tmp; memcpy(&tmp, mnl_attr_get_payload(attr), sizeof(tmp)); return tmp; } +EXPORT_SYMBOL(mnl_attr_get_u64); /** * mnl_attr_get_str - returns pointer to string attribute. @@ -348,10 +362,11 @@ EXPORT_SYMBOL uint64_t mnl_attr_get_u64(const struct nlattr *attr) * * This function returns the payload of string attribute value. */ -EXPORT_SYMBOL const char *mnl_attr_get_str(const struct nlattr *attr) +const char *mnl_attr_get_str(const struct nlattr *attr) { return mnl_attr_get_payload(attr); } +EXPORT_SYMBOL(mnl_attr_get_str); /** * mnl_attr_put - add an attribute to netlink message @@ -363,7 +378,7 @@ EXPORT_SYMBOL const char *mnl_attr_get_str(const struct nlattr *attr) * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL void +void mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data) { struct nlattr *attr = mnl_nlmsg_get_payload_tail(nlh); @@ -374,6 +389,7 @@ mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data) memcpy(mnl_attr_get_payload(attr), data, len); nlh->nlmsg_len += MNL_ALIGN(payload_len); } +EXPORT_SYMBOL(mnl_attr_put); /** * mnl_attr_put_u8 - add 8-bit unsigned integer attribute to netlink message @@ -385,11 +401,11 @@ mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data) * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL void -mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, uint8_t data) +void mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, uint8_t data) { mnl_attr_put(nlh, type, sizeof(uint8_t), &data); } +EXPORT_SYMBOL(mnl_attr_put_u8); /** * mnl_attr_put_u16 - add 16-bit unsigned integer attribute to netlink message @@ -400,11 +416,11 @@ mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, uint8_t data) * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL void -mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, uint16_t data) +void mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, uint16_t data) { mnl_attr_put(nlh, type, sizeof(uint16_t), &data); } +EXPORT_SYMBOL(mnl_attr_put_u16); /** * mnl_attr_put_u32 - add 32-bit unsigned integer attribute to netlink message @@ -415,11 +431,11 @@ mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, uint16_t data) * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL void -mnl_attr_put_u32(struct nlmsghdr *nlh, uint16_t type, uint32_t data) +void mnl_attr_put_u32(struct nlmsghdr *nlh, uint16_t type, uint32_t data) { mnl_attr_put(nlh, type, sizeof(uint32_t), &data); } +EXPORT_SYMBOL(mnl_attr_put_u32); /** * mnl_attr_put_u64 - add 64-bit unsigned integer attribute to netlink message @@ -430,11 +446,11 @@ mnl_attr_put_u32(struct nlmsghdr *nlh, uint16_t type, uint32_t data) * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL void -mnl_attr_put_u64(struct nlmsghdr *nlh, uint16_t type, uint64_t data) +void mnl_attr_put_u64(struct nlmsghdr *nlh, uint16_t type, uint64_t data) { mnl_attr_put(nlh, type, sizeof(uint64_t), &data); } +EXPORT_SYMBOL(mnl_attr_put_u64); /** * mnl_attr_put_str - add string attribute to netlink message @@ -445,11 +461,11 @@ mnl_attr_put_u64(struct nlmsghdr *nlh, uint16_t type, uint64_t data) * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL void -mnl_attr_put_str(struct nlmsghdr *nlh, uint16_t type, const char *data) +void mnl_attr_put_str(struct nlmsghdr *nlh, uint16_t type, const char *data) { mnl_attr_put(nlh, type, strlen(data), data); } +EXPORT_SYMBOL(mnl_attr_put_str); /** * mnl_attr_put_strz - add string attribute to netlink message @@ -463,11 +479,11 @@ mnl_attr_put_str(struct nlmsghdr *nlh, uint16_t type, const char *data) * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL void -mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, const char *data) +void mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, const char *data) { mnl_attr_put(nlh, type, strlen(data)+1, data); } +EXPORT_SYMBOL(mnl_attr_put_strz); /** * mnl_attr_nest_start - start an attribute nest @@ -478,8 +494,7 @@ mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, const char *data) * an attribute nest. This function always returns a valid pointer to the * beginning of the nest. */ -EXPORT_SYMBOL struct nlattr * -mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type) +struct nlattr *mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type) { struct nlattr *start = mnl_nlmsg_get_payload_tail(nlh); @@ -489,6 +504,7 @@ mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type) return start; } +EXPORT_SYMBOL(mnl_attr_nest_start); /** * mnl_attr_put_check - add an attribute to netlink message @@ -504,7 +520,7 @@ mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type) * attribute. The function returns true if the attribute could be added * to the message, otherwise false is returned. */ -EXPORT_SYMBOL bool +bool mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, size_t len, const void *data) { @@ -513,6 +529,7 @@ mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen, mnl_attr_put(nlh, type, len, data); return true; } +EXPORT_SYMBOL(mnl_attr_put_check); /** * mnl_attr_put_u8_check - add 8-bit unsigned int attribute to netlink message @@ -528,12 +545,13 @@ mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen, * attribute. The function returns true if the attribute could be added * to the message, otherwise false is returned. */ -EXPORT_SYMBOL bool +bool mnl_attr_put_u8_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint8_t data) { return mnl_attr_put_check(nlh, buflen, type, sizeof(uint8_t), &data); } +EXPORT_SYMBOL(mnl_attr_put_u8_check); /** * mnl_attr_put_u16_check - add 16-bit unsigned int attribute to netlink message @@ -550,12 +568,13 @@ mnl_attr_put_u8_check(struct nlmsghdr *nlh, size_t buflen, * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL bool +bool mnl_attr_put_u16_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint16_t data) { return mnl_attr_put_check(nlh, buflen, type, sizeof(uint16_t), &data); } +EXPORT_SYMBOL(mnl_attr_put_u16_check); /** * mnl_attr_put_u32_check - add 32-bit unsigned int attribute to netlink message @@ -572,12 +591,13 @@ mnl_attr_put_u16_check(struct nlmsghdr *nlh, size_t buflen, * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL bool +bool mnl_attr_put_u32_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint32_t data) { return mnl_attr_put_check(nlh, buflen, type, sizeof(uint32_t), &data); } +EXPORT_SYMBOL(mnl_attr_put_u32_check); /** * mnl_attr_put_u64_check - add 64-bit unsigned int attribute to netlink message @@ -594,12 +614,13 @@ mnl_attr_put_u32_check(struct nlmsghdr *nlh, size_t buflen, * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL bool +bool mnl_attr_put_u64_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint64_t data) { return mnl_attr_put_check(nlh, buflen, type, sizeof(uint64_t), &data); } +EXPORT_SYMBOL(mnl_attr_put_u64_check); /** * mnl_attr_put_str_check - add string attribute to netlink message @@ -616,12 +637,13 @@ mnl_attr_put_u64_check(struct nlmsghdr *nlh, size_t buflen, * This function updates the length field of the Netlink message (nlmsg_len) * by adding the size (header + payload) of the new attribute. */ -EXPORT_SYMBOL bool +bool mnl_attr_put_str_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data) { return mnl_attr_put_check(nlh, buflen, type, strlen(data), data); } +EXPORT_SYMBOL(mnl_attr_put_str_check); /** * mnl_attr_put_strz_check - add string attribute to netlink message @@ -639,12 +661,13 @@ mnl_attr_put_str_check(struct nlmsghdr *nlh, size_t buflen, * attribute. The function returns true if the attribute could be added * to the message, otherwise false is returned. */ -EXPORT_SYMBOL bool +bool mnl_attr_put_strz_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data) { return mnl_attr_put_check(nlh, buflen, type, strlen(data)+1, data); } +EXPORT_SYMBOL(mnl_attr_put_strz_check); /** * mnl_attr_nest_start_check - start an attribute nest @@ -656,13 +679,14 @@ mnl_attr_put_strz_check(struct nlmsghdr *nlh, size_t buflen, * an attribute nest. If the nested attribute cannot be added then NULL, * otherwise valid pointer to the beginning of the nest is returned. */ -EXPORT_SYMBOL struct nlattr * +struct nlattr * mnl_attr_nest_start_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type) { if (nlh->nlmsg_len + MNL_ATTR_HDRLEN > buflen) return NULL; return mnl_attr_nest_start(nlh, type); } +EXPORT_SYMBOL(mnl_attr_nest_start_check); /** * mnl_attr_nest_end - end an attribute nest @@ -671,11 +695,12 @@ mnl_attr_nest_start_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type) * * This function updates the attribute header that identifies the nest. */ -EXPORT_SYMBOL void +void mnl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *start) { start->nla_len = mnl_nlmsg_get_payload_tail(nlh) - (void *)start; } +EXPORT_SYMBOL(mnl_attr_nest_end); /** * mnl_attr_nest_cancel - cancel an attribute nest @@ -684,11 +709,12 @@ mnl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *start) * * This function updates the attribute header that identifies the nest. */ -EXPORT_SYMBOL void +void mnl_attr_nest_cancel(struct nlmsghdr *nlh, struct nlattr *start) { nlh->nlmsg_len -= mnl_nlmsg_get_payload_tail(nlh) - (void *)start; } +EXPORT_SYMBOL(mnl_attr_nest_cancel); /** * @} |