2011-06-22 21:42:51 +00:00
|
|
|
/*
|
2012-05-03 14:39:04 +00:00
|
|
|
* Copyright (C) 2010-2012 Red Hat, Inc.
|
2012-02-03 14:13:19 +00:00
|
|
|
* Copyright (C) 2010-2012 IBM Corporation
|
2011-06-22 21:42:51 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-07-21 10:06:23 +00:00
|
|
|
* License along with this library; If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2011-06-22 21:42:51 +00:00
|
|
|
*/
|
|
|
|
|
2011-06-22 18:17:36 +00:00
|
|
|
#ifndef __VIR_NETLINK_H__
|
|
|
|
# define __VIR_NETLINK_H__
|
|
|
|
|
2011-06-23 15:54:11 +00:00
|
|
|
# include "config.h"
|
2012-02-22 13:17:13 +00:00
|
|
|
# include "internal.h"
|
2012-07-17 12:07:59 +00:00
|
|
|
# include "virmacaddr.h"
|
2011-06-23 15:54:11 +00:00
|
|
|
|
|
|
|
# if defined(__linux__) && defined(HAVE_LIBNL)
|
2011-06-22 18:17:36 +00:00
|
|
|
|
|
|
|
# include <netlink/msg.h>
|
|
|
|
|
|
|
|
# else
|
|
|
|
|
|
|
|
struct nl_msg;
|
2012-02-22 13:17:13 +00:00
|
|
|
struct sockaddr_nl;
|
2012-03-06 01:12:34 +00:00
|
|
|
struct nlattr;
|
2011-06-22 18:17:36 +00:00
|
|
|
|
|
|
|
# endif /* __linux__ */
|
|
|
|
|
2012-05-03 14:39:04 +00:00
|
|
|
int virNetlinkStartup(void);
|
|
|
|
void virNetlinkShutdown(void);
|
|
|
|
|
2012-02-03 14:13:19 +00:00
|
|
|
int virNetlinkCommand(struct nl_msg *nl_msg,
|
|
|
|
unsigned char **respbuf, unsigned int *respbuflen,
|
2012-08-22 04:10:23 +00:00
|
|
|
uint32_t src_pid, uint32_t dst_pid,
|
|
|
|
unsigned int protocol, unsigned int groups);
|
2011-06-22 18:17:36 +00:00
|
|
|
|
2012-02-22 13:17:13 +00:00
|
|
|
typedef void (*virNetlinkEventHandleCallback)(unsigned char *msg, int length, struct sockaddr_nl *peer, bool *handled, void *opaque);
|
|
|
|
|
2012-07-17 12:07:59 +00:00
|
|
|
typedef void (*virNetlinkEventRemoveCallback)(int watch, const virMacAddrPtr macaddr, void *opaque);
|
2012-02-22 13:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* stopNetlinkEventServer: stop the monitor to receive netlink messages for libvirtd
|
|
|
|
*/
|
2012-08-22 04:10:23 +00:00
|
|
|
int virNetlinkEventServiceStop(unsigned int protocol);
|
2012-02-22 13:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* startNetlinkEventServer: start a monitor to receive netlink messages for libvirtd
|
|
|
|
*/
|
2012-08-22 04:10:23 +00:00
|
|
|
int virNetlinkEventServiceStart(unsigned int protocol, unsigned int groups);
|
2012-02-22 13:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* virNetlinkEventServiceIsRunning: returns if the netlink event service is running.
|
|
|
|
*/
|
2012-08-22 04:10:23 +00:00
|
|
|
bool virNetlinkEventServiceIsRunning(unsigned int protocol);
|
2012-02-22 13:17:13 +00:00
|
|
|
|
2012-05-04 17:19:51 +00:00
|
|
|
/**
|
|
|
|
* virNetlinkEventServiceLocalPid: returns nl_pid used to bind() netlink socket
|
|
|
|
*/
|
2012-08-22 04:10:23 +00:00
|
|
|
int virNetlinkEventServiceLocalPid(unsigned int protocol);
|
2012-05-04 17:19:51 +00:00
|
|
|
|
2012-02-22 13:17:13 +00:00
|
|
|
/**
|
|
|
|
* virNetlinkEventAddClient: register a callback for handling of netlink messages
|
|
|
|
*/
|
|
|
|
int virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB,
|
|
|
|
virNetlinkEventRemoveCallback removeCB,
|
2012-08-22 04:10:23 +00:00
|
|
|
void *opaque, const virMacAddrPtr macaddr,
|
|
|
|
unsigned int protocol);
|
2012-02-22 13:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* virNetlinkEventRemoveClient: unregister a callback from a netlink monitor
|
|
|
|
*/
|
2012-08-22 04:10:23 +00:00
|
|
|
int virNetlinkEventRemoveClient(int watch, const virMacAddrPtr macaddr,
|
|
|
|
unsigned int protocol);
|
2012-02-22 13:17:13 +00:00
|
|
|
|
2011-06-22 18:17:36 +00:00
|
|
|
#endif /* __VIR_NETLINK_H__ */
|