diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2013-02-27 14:10:47 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2013-03-13 10:27:46 +0100 |
commit | 3ecc059dcd06a79495d1bf171ef7f193eff79e98 (patch) | |
tree | d9c78970f3cc568486f4d0f7eab452aff783ace3 /util | |
parent | 1da48c658a26d0c1444d05d8d3a545d311e01026 (diff) | |
download | qemu-3ecc059dcd06a79495d1bf171ef7f193eff79e98.zip qemu-3ecc059dcd06a79495d1bf171ef7f193eff79e98.tar.gz qemu-3ecc059dcd06a79495d1bf171ef7f193eff79e98.tar.bz2 |
chardev: add udp support to qapi
This patch adds 'udp' support to qapi.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/qemu-sockets.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 3f12296..83e4e08 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -949,6 +949,31 @@ int socket_listen(SocketAddress *addr, Error **errp) return fd; } +int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp) +{ + QemuOpts *opts; + int fd; + + opts = qemu_opts_create_nofail(&dummy_opts); + switch (remote->kind) { + case SOCKET_ADDRESS_KIND_INET: + qemu_opt_set(opts, "host", remote->inet->host); + qemu_opt_set(opts, "port", remote->inet->port); + if (local) { + qemu_opt_set(opts, "localaddr", local->inet->host); + qemu_opt_set(opts, "localport", local->inet->port); + } + fd = inet_dgram_opts(opts, errp); + break; + + default: + error_setg(errp, "socket type unsupported for datagram"); + return -1; + } + qemu_opts_del(opts); + return fd; +} + #ifdef _WIN32 static void socket_cleanup(void) { |