.destroy = _destroy,
},
},
- .socket = netlink_socket_create(NETLINK_ROUTE),
+ .socket = netlink_socket_create(NETLINK_ROUTE, NULL),
.rt_exclude = linked_list_create(),
.routes = hashtable_create((hashtable_hash_t)route_entry_hash,
(hashtable_equals_t)route_entry_equals, 16),
int seq;
/**
- * netlink socket protocol
+ * netlink socket
*/
- int protocol;
+ int socket;
/**
- * netlink socket
+ * Enum names for Netlink messages
*/
- int socket;
+ enum_name_t *names;
};
/**
addr.nl_pid = 0;
addr.nl_groups = 0;
- if (this->protocol == NETLINK_XFRM)
+ if (this->names)
{
DBG3(DBG_KNL, "sending %N: %b",
- xfrm_msg_names, in->nlmsg_type, in, in->nlmsg_len);
+ this->names, in->nlmsg_type, in, in->nlmsg_len);
}
while (TRUE)
{
/**
* Described in header.
*/
-netlink_socket_t *netlink_socket_create(int protocol)
+netlink_socket_t *netlink_socket_create(int protocol, enum_name_t *names)
{
private_netlink_socket_t *this;
struct sockaddr_nl addr = {
.seq = 200,
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
.socket = socket(AF_NETLINK, SOCK_RAW, protocol),
- .protocol = protocol,
+ .names = names,
);
if (this->socket == -1)
/**
* Create a netlink_socket_t object.
*
- * @param protocol protocol type (e.g. NETLINK_XFRM or NETLINK_ROUTE)
+ * @param protocol protocol type (e.g. NETLINK_XFRM or NETLINK_ROUTE)
+ * @param names optional enum names for Netlink messages
*/
-netlink_socket_t *netlink_socket_create(int protocol);
+netlink_socket_t *netlink_socket_create(int protocol, enum_name_t *names);
/**
* Creates an rtattr and adds it to the given netlink message.