aboutsummaryrefslogtreecommitdiff
path: root/slirp/udp.c
diff options
context:
space:
mode:
authorGuillaume Subiron <maethor@subiron.org>2015-12-19 22:25:01 +0100
committerJason Wang <jasowang@redhat.com>2016-02-04 13:22:06 +0800
commit8a87f121ca82fbb34877ec843dfc50b327baef9d (patch)
tree2e13bcac23ec476d279b31e742711b264ad4ca6d /slirp/udp.c
parenta5fd24aa6d0f26aeb9f15b24daa2d68427631c40 (diff)
slirp: Add sockaddr_equal, make solookup family-agnostic
This patch makes solookup() compatible with varying address families, by using a new sockaddr_equal() function that compares two sockaddr_storage. This prepares for IPv6 support. Signed-off-by: Guillaume Subiron <maethor@subiron.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'slirp/udp.c')
-rw-r--r--slirp/udp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/slirp/udp.c b/slirp/udp.c
index 126ef82a8e..63776c007d 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -70,6 +70,8 @@ udp_input(register struct mbuf *m, int iphlen)
int len;
struct ip save_ip;
struct socket *so;
+ struct sockaddr_storage lhost;
+ struct sockaddr_in *lhost4;
DEBUG_CALL("udp_input");
DEBUG_ARG("m = %p", m);
@@ -151,8 +153,12 @@ udp_input(register struct mbuf *m, int iphlen)
/*
* Locate pcb for datagram.
*/
- so = solookup(&slirp->udp_last_so, &slirp->udb,
- ip->ip_src, uh->uh_sport, (struct in_addr) {0}, 0);
+ lhost.ss_family = AF_INET;
+ lhost4 = (struct sockaddr_in *) &lhost;
+ lhost4->sin_addr = ip->ip_src;
+ lhost4->sin_port = uh->uh_sport;
+
+ so = solookup(&slirp->udp_last_so, &slirp->udb, &lhost, NULL);
if (so == NULL) {
/*