Migrated netlink_socket to INIT/METHOD macros
This commit is contained in:
@@ -61,11 +61,9 @@ struct private_netlink_socket_t {
|
|||||||
*/
|
*/
|
||||||
extern enum_name_t *xfrm_msg_names;
|
extern enum_name_t *xfrm_msg_names;
|
||||||
|
|
||||||
/**
|
METHOD(netlink_socket_t, netlink_send, status_t,
|
||||||
* Implementation of netlink_socket_t.send
|
private_netlink_socket_t *this, struct nlmsghdr *in, struct nlmsghdr **out,
|
||||||
*/
|
size_t *out_len)
|
||||||
static status_t netlink_send(private_netlink_socket_t *this, struct nlmsghdr *in,
|
|
||||||
struct nlmsghdr **out, size_t *out_len)
|
|
||||||
{
|
{
|
||||||
int len, addr_len;
|
int len, addr_len;
|
||||||
struct sockaddr_nl addr;
|
struct sockaddr_nl addr;
|
||||||
@@ -182,10 +180,8 @@ static status_t netlink_send(private_netlink_socket_t *this, struct nlmsghdr *in
|
|||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(netlink_socket_t, netlink_send_ack, status_t,
|
||||||
* Implementation of netlink_socket_t.send_ack.
|
private_netlink_socket_t *this, struct nlmsghdr *in)
|
||||||
*/
|
|
||||||
static status_t netlink_send_ack(private_netlink_socket_t *this, struct nlmsghdr *in)
|
|
||||||
{
|
{
|
||||||
struct nlmsghdr *out, *hdr;
|
struct nlmsghdr *out, *hdr;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -231,10 +227,8 @@ static status_t netlink_send_ack(private_netlink_socket_t *this, struct nlmsghdr
|
|||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(netlink_socket_t, destroy, void,
|
||||||
* Implementation of netlink_socket_t.destroy.
|
private_netlink_socket_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_netlink_socket_t *this)
|
|
||||||
{
|
{
|
||||||
if (this->socket > 0)
|
if (this->socket > 0)
|
||||||
{
|
{
|
||||||
@@ -249,22 +243,23 @@ static void destroy(private_netlink_socket_t *this)
|
|||||||
*/
|
*/
|
||||||
netlink_socket_t *netlink_socket_create(int protocol)
|
netlink_socket_t *netlink_socket_create(int protocol)
|
||||||
{
|
{
|
||||||
private_netlink_socket_t *this = malloc_thing(private_netlink_socket_t);
|
private_netlink_socket_t *this;
|
||||||
struct sockaddr_nl addr;
|
struct sockaddr_nl addr;
|
||||||
|
|
||||||
/* public functions */
|
INIT(this,
|
||||||
this->public.send = (status_t(*)(netlink_socket_t*,struct nlmsghdr*, struct nlmsghdr**, size_t*))netlink_send;
|
.public = {
|
||||||
this->public.send_ack = (status_t(*)(netlink_socket_t*,struct nlmsghdr*))netlink_send_ack;
|
.send = _netlink_send,
|
||||||
this->public.destroy = (void(*)(netlink_socket_t*))destroy;
|
.send_ack = _netlink_send_ack,
|
||||||
|
.destroy = _destroy,
|
||||||
/* private members */
|
},
|
||||||
this->seq = 200;
|
.seq = 200,
|
||||||
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
|
||||||
|
.protocol = protocol,
|
||||||
|
);
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
addr.nl_family = AF_NETLINK;
|
addr.nl_family = AF_NETLINK;
|
||||||
|
|
||||||
this->protocol = protocol;
|
|
||||||
this->socket = socket(AF_NETLINK, SOCK_RAW, protocol);
|
this->socket = socket(AF_NETLINK, SOCK_RAW, protocol);
|
||||||
if (this->socket < 0)
|
if (this->socket < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user