2010-12-06 17:03:35 +00:00
|
|
|
/*
|
|
|
|
* virnetsocket.h: generic network socket handling
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006-2011 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2006 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* 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-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-12-06 17:03:35 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_NET_SOCKET_H__
|
|
|
|
# define __VIR_NET_SOCKET_H__
|
|
|
|
|
Split src/util/network.{c,h} into 5 pieces
The src/util/network.c file is a dumping ground for many different
APIs. Split it up into 5 pieces, along functional lines
- src/util/virnetdevbandwidth.c: virNetDevBandwidth type & helper APIs
- src/util/virnetdevvportprofile.c: virNetDevVPortProfile type & helper APIs
- src/util/virsocketaddr.c: virSocketAddr and APIs
- src/conf/netdev_bandwidth_conf.c: XML parsing / formatting
for virNetDevBandwidth
- src/conf/netdev_vport_profile_conf.c: XML parsing / formatting
for virNetDevVPortProfile
* src/util/network.c, src/util/network.h: Split into 5 pieces
* src/conf/netdev_bandwidth_conf.c, src/conf/netdev_bandwidth_conf.h,
src/conf/netdev_vport_profile_conf.c, src/conf/netdev_vport_profile_conf.h,
src/util/virnetdevbandwidth.c, src/util/virnetdevbandwidth.h,
src/util/virnetdevvportprofile.c, src/util/virnetdevvportprofile.h,
src/util/virsocketaddr.c, src/util/virsocketaddr.h: New pieces
* daemon/libvirtd.h, daemon/remote.c, src/conf/domain_conf.c,
src/conf/domain_conf.h, src/conf/network_conf.c,
src/conf/network_conf.h, src/conf/nwfilter_conf.h,
src/esx/esx_util.h, src/network/bridge_driver.c,
src/qemu/qemu_conf.c, src/rpc/virnetsocket.c,
src/rpc/virnetsocket.h, src/util/dnsmasq.h, src/util/interface.h,
src/util/iptables.h, src/util/macvtap.c, src/util/macvtap.h,
src/util/virnetdev.h, src/util/virnetdevtap.c,
tools/virsh.c: Update include files
2011-11-02 15:40:08 +00:00
|
|
|
# include "virsocketaddr.h"
|
2012-12-12 16:27:01 +00:00
|
|
|
# include "vircommand.h"
|
2013-01-08 21:02:05 +00:00
|
|
|
# ifdef WITH_GNUTLS
|
2013-01-07 14:54:18 +00:00
|
|
|
# include "virnettlscontext.h"
|
|
|
|
# endif
|
2012-07-11 13:35:51 +00:00
|
|
|
# include "virobject.h"
|
2012-09-20 11:58:29 +00:00
|
|
|
# ifdef WITH_SASL
|
2010-12-10 12:22:03 +00:00
|
|
|
# include "virnetsaslcontext.h"
|
|
|
|
# endif
|
2012-12-12 17:53:50 +00:00
|
|
|
# include "virjson.h"
|
2010-12-06 17:03:35 +00:00
|
|
|
|
|
|
|
typedef struct _virNetSocket virNetSocket;
|
|
|
|
typedef virNetSocket *virNetSocketPtr;
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*virNetSocketIOFunc)(virNetSocketPtr sock,
|
|
|
|
int events,
|
|
|
|
void *opaque);
|
|
|
|
|
|
|
|
|
|
|
|
int virNetSocketNewListenTCP(const char *nodename,
|
|
|
|
const char *service,
|
|
|
|
virNetSocketPtr **addrs,
|
|
|
|
size_t *naddrs);
|
|
|
|
|
|
|
|
int virNetSocketNewListenUNIX(const char *path,
|
|
|
|
mode_t mask,
|
2011-08-12 09:10:19 +00:00
|
|
|
uid_t user,
|
2010-12-06 17:03:35 +00:00
|
|
|
gid_t grp,
|
|
|
|
virNetSocketPtr *addr);
|
2012-08-09 14:09:19 +00:00
|
|
|
|
|
|
|
int virNetSocketNewListenFD(int fd,
|
|
|
|
virNetSocketPtr *addr);
|
2010-12-06 17:03:35 +00:00
|
|
|
|
|
|
|
int virNetSocketNewConnectTCP(const char *nodename,
|
|
|
|
const char *service,
|
|
|
|
virNetSocketPtr *addr);
|
|
|
|
|
|
|
|
int virNetSocketNewConnectUNIX(const char *path,
|
|
|
|
bool spawnDaemon,
|
|
|
|
const char *binary,
|
|
|
|
virNetSocketPtr *addr);
|
|
|
|
|
|
|
|
int virNetSocketNewConnectCommand(virCommandPtr cmd,
|
|
|
|
virNetSocketPtr *retsock);
|
|
|
|
|
|
|
|
int virNetSocketNewConnectSSH(const char *nodename,
|
|
|
|
const char *service,
|
|
|
|
const char *binary,
|
|
|
|
const char *username,
|
|
|
|
bool noTTY,
|
2011-07-11 19:50:31 +00:00
|
|
|
bool noVerify,
|
2010-12-06 17:03:35 +00:00
|
|
|
const char *netcat,
|
2011-07-19 17:52:21 +00:00
|
|
|
const char *keyfile,
|
2010-12-06 17:03:35 +00:00
|
|
|
const char *path,
|
|
|
|
virNetSocketPtr *addr);
|
|
|
|
|
2011-11-14 14:50:02 +00:00
|
|
|
int virNetSocketNewConnectLibSSH2(const char *host,
|
|
|
|
const char *port,
|
|
|
|
const char *username,
|
|
|
|
const char *password,
|
|
|
|
const char *privkey,
|
|
|
|
const char *knownHosts,
|
|
|
|
const char *knownHostsVerify,
|
|
|
|
const char *authMethods,
|
|
|
|
const char *command,
|
|
|
|
virConnectAuthPtr auth,
|
|
|
|
virNetSocketPtr *retsock);
|
|
|
|
|
2010-12-06 17:03:35 +00:00
|
|
|
int virNetSocketNewConnectExternal(const char **cmdargv,
|
|
|
|
virNetSocketPtr *addr);
|
|
|
|
|
2012-08-09 11:54:54 +00:00
|
|
|
|
|
|
|
virNetSocketPtr virNetSocketNewPostExecRestart(virJSONValuePtr object);
|
|
|
|
|
|
|
|
virJSONValuePtr virNetSocketPreExecRestart(virNetSocketPtr sock);
|
|
|
|
|
2010-12-06 17:03:35 +00:00
|
|
|
int virNetSocketGetFD(virNetSocketPtr sock);
|
2011-07-07 14:17:21 +00:00
|
|
|
int virNetSocketDupFD(virNetSocketPtr sock, bool cloexec);
|
|
|
|
|
2010-12-06 17:03:35 +00:00
|
|
|
bool virNetSocketIsLocal(virNetSocketPtr sock);
|
|
|
|
|
2011-10-21 10:13:21 +00:00
|
|
|
bool virNetSocketHasPassFD(virNetSocketPtr sock);
|
|
|
|
|
2011-03-02 17:11:42 +00:00
|
|
|
int virNetSocketGetPort(virNetSocketPtr sock);
|
|
|
|
|
2012-01-18 17:41:36 +00:00
|
|
|
int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
|
|
|
|
uid_t *uid,
|
|
|
|
gid_t *gid,
|
|
|
|
pid_t *pid);
|
2012-01-20 17:18:28 +00:00
|
|
|
int virNetSocketGetSecurityContext(virNetSocketPtr sock,
|
|
|
|
char **context);
|
2010-12-06 17:03:35 +00:00
|
|
|
|
|
|
|
int virNetSocketSetBlocking(virNetSocketPtr sock,
|
|
|
|
bool blocking);
|
|
|
|
|
|
|
|
ssize_t virNetSocketRead(virNetSocketPtr sock, char *buf, size_t len);
|
|
|
|
ssize_t virNetSocketWrite(virNetSocketPtr sock, const char *buf, size_t len);
|
|
|
|
|
2011-10-21 10:13:21 +00:00
|
|
|
int virNetSocketSendFD(virNetSocketPtr sock, int fd);
|
2011-11-04 16:02:14 +00:00
|
|
|
int virNetSocketRecvFD(virNetSocketPtr sock, int *fd);
|
2011-10-21 10:13:21 +00:00
|
|
|
|
2013-01-08 21:02:05 +00:00
|
|
|
# ifdef WITH_GNUTLS
|
2010-12-10 12:22:03 +00:00
|
|
|
void virNetSocketSetTLSSession(virNetSocketPtr sock,
|
|
|
|
virNetTLSSessionPtr sess);
|
2013-01-07 14:54:18 +00:00
|
|
|
# endif
|
2011-11-14 14:50:02 +00:00
|
|
|
|
2012-09-20 11:58:29 +00:00
|
|
|
# ifdef WITH_SASL
|
2010-12-10 12:22:03 +00:00
|
|
|
void virNetSocketSetSASLSession(virNetSocketPtr sock,
|
|
|
|
virNetSASLSessionPtr sess);
|
|
|
|
# endif
|
|
|
|
bool virNetSocketHasCachedData(virNetSocketPtr sock);
|
2011-11-08 09:13:27 +00:00
|
|
|
bool virNetSocketHasPendingData(virNetSocketPtr sock);
|
2010-12-06 17:03:35 +00:00
|
|
|
|
|
|
|
const char *virNetSocketLocalAddrString(virNetSocketPtr sock);
|
|
|
|
const char *virNetSocketRemoteAddrString(virNetSocketPtr sock);
|
|
|
|
|
2011-08-12 09:07:51 +00:00
|
|
|
int virNetSocketListen(virNetSocketPtr sock, int backlog);
|
2010-12-06 17:03:35 +00:00
|
|
|
int virNetSocketAccept(virNetSocketPtr sock,
|
|
|
|
virNetSocketPtr *clientsock);
|
|
|
|
|
|
|
|
int virNetSocketAddIOCallback(virNetSocketPtr sock,
|
|
|
|
int events,
|
|
|
|
virNetSocketIOFunc func,
|
2011-07-19 13:11:33 +00:00
|
|
|
void *opaque,
|
|
|
|
virFreeCallback ff);
|
2010-12-06 17:03:35 +00:00
|
|
|
|
|
|
|
void virNetSocketUpdateIOCallback(virNetSocketPtr sock,
|
|
|
|
int events);
|
|
|
|
|
|
|
|
void virNetSocketRemoveIOCallback(virNetSocketPtr sock);
|
|
|
|
|
2011-08-04 08:54:58 +00:00
|
|
|
void virNetSocketClose(virNetSocketPtr sock);
|
2010-12-06 17:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* __VIR_NET_SOCKET_H__ */
|