summaryrefslogtreecommitdiff
path: root/slirp/socket.h
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-04-28 18:53:08 +0200
committerPeter Maydell <peter.maydell@linaro.org>2016-04-28 18:12:08 +0100
commit0d48dfedc5c2beb418ad4c08b78de14e794bb199 (patch)
treebd061e316c485320611cf0d3f1c2f34e1a302bce /slirp/socket.h
parent8c4bf97580a7556e3e61b7bc41dedb5958f0b2f9 (diff)
downloadqemu-0d48dfedc5c2beb418ad4c08b78de14e794bb199.zip
slirp: fix guest network access with darwin host
On Darwin, connect, sendto and friends want the exact size of the sockaddr, not more (and in particular, not sizeof(struct sockaddr_storaget)) This commit adds the sockaddr_size helper to be used when passing a sockaddr size to such function, and makes use of it int sendto and connect calls. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: John Arbuckle <programmingkidx@gmail.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'slirp/socket.h')
-rw-r--r--slirp/socket.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/slirp/socket.h b/slirp/socket.h
index 7dca506973..b602e69b95 100644
--- a/slirp/socket.h
+++ b/slirp/socket.h
@@ -122,6 +122,18 @@ static inline int sockaddr_equal(struct sockaddr_storage *a,
return 0;
}
+static inline socklen_t sockaddr_size(struct sockaddr_storage *a)
+{
+ switch (a->ss_family) {
+ case AF_INET:
+ return sizeof(struct sockaddr_in);
+ case AF_INET6:
+ return sizeof(struct sockaddr_in6);
+ default:
+ g_assert_not_reached();
+ }
+}
+
struct socket *solookup(struct socket **, struct socket *,
struct sockaddr_storage *, struct sockaddr_storage *);
struct socket *socreate(Slirp *);