aboutsummaryrefslogtreecommitdiff
path: root/slirp/socket.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/socket.c
parenta5fd24aa6d0f26aeb9f15b24daa2d68427631c40 (diff)
downloadqemu-arm-8a87f121ca82fbb34877ec843dfc50b327baef9d.tar.gz
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/socket.c')
-rw-r--r--slirp/socket.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/slirp/socket.c b/slirp/socket.c
index 8f73e906e2..f7e596859f 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -15,29 +15,20 @@
static void sofcantrcvmore(struct socket *so);
static void sofcantsendmore(struct socket *so);
-struct socket *
-solookup(struct socket **last, struct socket *head,
- struct in_addr laddr, u_int lport,
- struct in_addr faddr, u_int fport)
+struct socket *solookup(struct socket **last, struct socket *head,
+ struct sockaddr_storage *lhost, struct sockaddr_storage *fhost)
{
struct socket *so = *last;
/* Optimisation */
- if (so != head &&
- so->so_lport == lport &&
- so->so_laddr.s_addr == laddr.s_addr &&
- (!faddr.s_addr ||
- (so->so_faddr.s_addr == faddr.s_addr &&
- so->so_fport == fport))) {
+ if (so != head && sockaddr_equal(&(so->lhost.ss), lhost)
+ && (!fhost || sockaddr_equal(&so->fhost.ss, fhost))) {
return so;
}
for (so = head->so_next; so != head; so = so->so_next) {
- if (so->so_lport == lport &&
- so->so_laddr.s_addr == laddr.s_addr &&
- (!faddr.s_addr ||
- (so->so_faddr.s_addr == faddr.s_addr &&
- so->so_fport == fport))) {
+ if (sockaddr_equal(&(so->lhost.ss), lhost)
+ && (!fhost || sockaddr_equal(&so->fhost.ss, fhost))) {
*last = so;
return so;
}