summaryrefslogtreecommitdiff
path: root/slirp/udp.c
diff options
context:
space:
mode:
authorGuillaume Subiron <maethor@subiron.org>2015-12-19 22:25:00 +0100
committerJason Wang <jasowang@redhat.com>2016-02-04 13:22:06 +0800
commita5fd24aa6d0f26aeb9f15b24daa2d68427631c40 (patch)
tree83dcbdd530a4e23f3408bbc8ba60b54d78fa48dd /slirp/udp.c
parent5379229a2708df3a1506113315214c3ce5325859 (diff)
downloadqemu-a5fd24aa6d0f26aeb9f15b24daa2d68427631c40.tar.gz
qemu-a5fd24aa6d0f26aeb9f15b24daa2d68427631c40.tar.bz2
qemu-a5fd24aa6d0f26aeb9f15b24daa2d68427631c40.zip
slirp: Factorizing and cleaning solookup()
solookup() was only compatible with TCP. Having the socket list in argument, it is now compatible with UDP too. Some optimization code is factorized inside the function (the function look at the last returned result before browsing the complete socket list). 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.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/slirp/udp.c b/slirp/udp.c
index 8203eb1bb2..126ef82a8e 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -151,25 +151,8 @@ udp_input(register struct mbuf *m, int iphlen)
/*
* Locate pcb for datagram.
*/
- so = slirp->udp_last_so;
- if (so == &slirp->udb || so->so_lport != uh->uh_sport ||
- so->so_laddr.s_addr != ip->ip_src.s_addr) {
- struct socket *tmp;
-
- for (tmp = slirp->udb.so_next; tmp != &slirp->udb;
- tmp = tmp->so_next) {
- if (tmp->so_lport == uh->uh_sport &&
- tmp->so_laddr.s_addr == ip->ip_src.s_addr) {
- so = tmp;
- break;
- }
- }
- if (tmp == &slirp->udb) {
- so = NULL;
- } else {
- slirp->udp_last_so = so;
- }
- }
+ so = solookup(&slirp->udp_last_so, &slirp->udb,
+ ip->ip_src, uh->uh_sport, (struct in_addr) {0}, 0);
if (so == NULL) {
/*