1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

Revert "netlink: make netlink_snl(3) c++ friendly."

Was pushed accidentally.

This reverts commit 629d9219d9.
This commit is contained in:
Alexander V. Chernikov 2023-02-12 12:16:58 +00:00
parent 69e7d9b7e6
commit 6d7da7c849
2 changed files with 10 additions and 18 deletions

View File

@ -44,7 +44,6 @@
#include <sys/socket.h>
#include <netlink/netlink.h>
__BEGIN_DECLS
#define _roundup2(x, y) (((x)+((y)-1))&(~((y)-1)))
@ -84,7 +83,7 @@ lb_allocz(struct linear_buffer *lb, int len)
return (NULL);
void *data = (void *)(lb->base + lb->offset);
lb->offset += len;
return ((char *)data);
return (data);
}
static inline void
@ -133,10 +132,10 @@ struct snl_hdr_parser {
#define SNL_DECLARE_PARSER(_name, _t, _fp, _np) \
static const struct snl_hdr_parser _name = { \
.hdr_off = sizeof(_t), \
.fp_size = NL_ARRAY_LEN(_fp), \
.np_size = NL_ARRAY_LEN(_np), \
.fp = &((_fp)[0]), \
.np = &((_np)[0]), \
.fp_size = NL_ARRAY_LEN(_fp), \
.np_size = NL_ARRAY_LEN(_np), \
}
#define SNL_DECLARE_ATTR_PARSER(_name, _np) \
@ -176,14 +175,14 @@ snl_init(struct snl_state *ss, int netlink_family)
}
ss->bufsize = rcvbuf;
ss->buf = (char *)malloc(ss->bufsize);
ss->buf = malloc(ss->bufsize);
if (ss->buf == NULL) {
snl_free(ss);
return (false);
}
ss->lb.size = SCRATCH_BUFFER_SIZE;
ss->lb.base = (char *)calloc(1, ss->lb.size);
ss->lb.base = calloc(1, ss->lb.size);
if (ss->lb.base == NULL) {
snl_free(ss);
return (false);
@ -361,7 +360,7 @@ snl_attr_get_uint16(struct snl_state *ss __unused, struct nlattr *nla,
const void *arg __unused, void *target)
{
if (NLA_DATA_LEN(nla) == sizeof(uint16_t)) {
*((uint16_t *)target) = *((const uint16_t *)NL_RTA_DATA_CONST(nla));
*((uint16_t *)target) = *((const uint16_t *)NLA_DATA_CONST(nla));
return (true);
}
return (false);
@ -372,7 +371,7 @@ snl_attr_get_uint32(struct snl_state *ss __unused, struct nlattr *nla,
const void *arg __unused, void *target)
{
if (NLA_DATA_LEN(nla) == sizeof(uint32_t)) {
*((uint32_t *)target) = *((const uint32_t *)NL_RTA_DATA_CONST(nla));
*((uint32_t *)target) = *((const uint32_t *)NLA_DATA_CONST(nla));
return (true);
}
return (false);
@ -397,7 +396,7 @@ snl_attr_get_stringn(struct snl_state *ss, struct nlattr *nla,
{
int maxlen = NLA_DATA_LEN(nla);
char *buf = (char *)snl_allocz(ss, maxlen + 1);
char *buf = snl_allocz(ss, maxlen + 1);
if (buf == NULL)
return (false);
buf[maxlen] = '\0';
@ -417,8 +416,7 @@ snl_attr_get_nested(struct snl_state *ss, struct nlattr *nla, const void *arg, v
}
static inline bool
snl_attr_get_nla(struct snl_state *ss __unused, struct nlattr *nla,
const void *arg __unused, void *target)
snl_attr_get_nla(struct snl_state *ss __unused, struct nlattr *nla, void *target)
{
*((struct nlattr **)target) = nla;
return (true);
@ -442,6 +440,4 @@ snl_field_get_uint32(struct snl_state *ss __unused, void *src, void *target)
*((uint32_t *)target) = *((uint32_t *)src);
}
__END_DECLS
#endif

View File

@ -31,8 +31,6 @@
#include <netlink/netlink_route.h>
#include <netinet/in.h>
__BEGIN_DECLS
/*
* Simple Netlink Library - NETLINK_ROUTE helpers
*/
@ -102,7 +100,7 @@ snl_attr_get_ip(struct snl_state *ss, struct nlattr *nla,
static inline struct sockaddr *
parse_rta_via(struct snl_state *ss, struct rtattr *rta, int *perror)
{
struct rtvia *via = (struct rtvia *)NL_RTA_DATA(rta);
struct rtvia *via = NL_RTA_DATA(rta);
switch (via->rtvia_family) {
case AF_INET:
@ -129,6 +127,4 @@ snl_attr_get_ipvia(struct snl_state *ss, struct nlattr *nla,
return (false);
}
__END_DECLS
#endif