提交 7eddf37c 编写于 作者: D Dr. David Alan Gilbert 提交者: Samuel Thibault

slirp: Common lhost/fhost union

The socket structure has a pair of unions for lhost and fhost
addresses; the unions are identical so split them out into
a separate union declaration.
Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: NJuan Quintela <quintela@redhat.com>
Signed-off-by: NSamuel Thibault <samuel.thibault@ens-lyon.org>
上级 2a7cab9e
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
* Our socket structure * Our socket structure
*/ */
union slirp_sockaddr {
struct sockaddr_storage ss;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
};
struct socket { struct socket {
struct socket *so_next,*so_prev; /* For a linked list of sockets */ struct socket *so_next,*so_prev; /* For a linked list of sockets */
...@@ -31,22 +37,14 @@ struct socket { ...@@ -31,22 +37,14 @@ struct socket {
struct tcpiphdr *so_ti; /* Pointer to the original ti within struct tcpiphdr *so_ti; /* Pointer to the original ti within
* so_mconn, for non-blocking connections */ * so_mconn, for non-blocking connections */
int so_urgc; int so_urgc;
union { /* foreign host */ union slirp_sockaddr fhost; /* Foreign host */
struct sockaddr_storage ss;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
} fhost;
#define so_faddr fhost.sin.sin_addr #define so_faddr fhost.sin.sin_addr
#define so_fport fhost.sin.sin_port #define so_fport fhost.sin.sin_port
#define so_faddr6 fhost.sin6.sin6_addr #define so_faddr6 fhost.sin6.sin6_addr
#define so_fport6 fhost.sin6.sin6_port #define so_fport6 fhost.sin6.sin6_port
#define so_ffamily fhost.ss.ss_family #define so_ffamily fhost.ss.ss_family
union { /* local host */ union slirp_sockaddr lhost; /* Local host */
struct sockaddr_storage ss;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
} lhost;
#define so_laddr lhost.sin.sin_addr #define so_laddr lhost.sin.sin_addr
#define so_lport lhost.sin.sin_port #define so_lport lhost.sin.sin_port
#define so_laddr6 lhost.sin6.sin6_addr #define so_laddr6 lhost.sin6.sin6_addr
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册