mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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>
This commit is contained in:
parent
5379229a27
commit
a5fd24aa6d
4 changed files with 31 additions and 43 deletions
21
slirp/udp.c
21
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) {
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue