Hello, Maxim Samoylov, le ven. 26 oct. 2018 03:03:42 +0300, a ecrit: > +int slirp_remove_ipv6_hostfwd(Slirp *slirp, int is_udp, > + struct in6_addr host_addr, int host_port)
Similarly, we'd rather share the code than duplicate it :) Better put the existing slirp_remove_hostfwd code into a slirp_remove_x_hostfwd(Slirp *slirp, int is_udp, struct sockaddr *addr) by replacing the explicit ipv4 comparison with a call to a helper which compares two struct sockaddr (starting with the so_family field, then testing fields depending the family, and you can put it in slirp/socket.h) and then slirp_remove_hostfwd can be rewritten as putting its parameters into a sockaddr_in and colling slirp_remove_x_hostfwd, and slirp_remove_ipv6_hostfwd implemented similarly for ipv6. > +int slirp_add_ipv6_hostfwd(Slirp *slirp, int is_udp, > + struct in6_addr host_addr, int host_port, > + struct in6_addr guest_addr, int guest_port) > +{ > + if (is_udp) { > + if (!udp6_listen(slirp, host_addr, htons(host_port), > + guest_addr, htons(guest_port), SS_HOSTFWD)) > + return -1; > + } else { > + if (!tcp6_listen(slirp, host_addr, htons(host_port), > + guest_addr, htons(guest_port), SS_HOSTFWD)) > + return -1; > + } > + > + return 0; > +} That one can remains so :) Samuel