aboutsummaryrefslogtreecommitdiff
path: root/socket.h
diff options
context:
space:
mode:
authorGuillaume Subiron <maethor@subiron.org>2015-12-19 22:24:58 +0100
committerJason Wang <jasowang@redhat.com>2016-02-04 13:22:06 +0800
commit836f56407c2c6297f8cea1e9569502d165f2c30c (patch)
tree3fd66547adfc73e592c603e709f987de70cf3ca2 /socket.h
parentfdb78b68f75f2d6baeec281cd2f0793bca5a5626 (diff)
downloadslirp-836f56407c2c6297f8cea1e9569502d165f2c30c.zip
slirp-836f56407c2c6297f8cea1e9569502d165f2c30c.tar.gz
slirp-836f56407c2c6297f8cea1e9569502d165f2c30c.tar.bz2
slirp: Make Socket structure IPv6 compatible
This patch replaces foreign and local address/port couples in Socket structure by 2 sockaddr_storage which can be casted in sockaddr_in. Direct access to address and port is still possible thanks to some \#define, so retrocompatibility of the existing code is assured. The ss_family field of sockaddr_storage is declared after each socket creation. The whole structure is also saved/restored when a Qemu session is saved/restored. 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 'socket.h')
-rw-r--r--socket.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/socket.h b/socket.h
index a40aa66..d3ba89f 100644
--- a/socket.h
+++ b/socket.h
@@ -31,10 +31,21 @@ struct socket {
struct tcpiphdr *so_ti; /* Pointer to the original ti within
* so_mconn, for non-blocking connections */
int so_urgc;
- struct in_addr so_faddr; /* foreign host table entry */
- struct in_addr so_laddr; /* local host table entry */
- uint16_t so_fport; /* foreign port */
- uint16_t so_lport; /* local port */
+ union { /* foreign host */
+ struct sockaddr_storage ss;
+ struct sockaddr_in sin;
+ } fhost;
+#define so_faddr fhost.sin.sin_addr
+#define so_fport fhost.sin.sin_port
+#define so_ffamily fhost.ss.ss_family
+
+ union { /* local host */
+ struct sockaddr_storage ss;
+ struct sockaddr_in sin;
+ } lhost;
+#define so_laddr lhost.sin.sin_addr
+#define so_lport lhost.sin.sin_port
+#define so_lfamily lhost.ss.ss_family
uint8_t so_iptos; /* Type of service */
uint8_t so_emu; /* Is the socket emulated? */