: Small VNC related cleanup
cover : Small VNC related cleanup
This series makes VNC events code use inet_strfamily() from qemu-socket
instead of duplicating code, as suggested by Gerd.
Thanks.
PATCH 1/3 net: Make inet_strfamily() public
So that it can be used by other subsystems.
Signed-off-by Luiz Capitulino <[email protected]>
--- qemu-sockets.c | 2 +- qemu_socket.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)
qemu-sockets.c +1 -1
@@ -91,7 +91,7 @@ static void inet_setport(struct addrinfo *e, int port) } } -static const char *inet_strfamily (int family) +const char *inet_strfamily (int family) {switch (family) {case PF_INET6 :return "ipv6" ;
qemu_socket.h +1 -0
@@ -44,6 +44,7 @@ int inet_listen(const char *str, char *ostr, int olen,int inet_connect_opts (QemuOpts *opts);int inet_connect (const char *str,int socktype);int inet_dgram_opts (QemuOpts *opts); +const char *inet_strfamily (int family);int unix_listen_opts (QemuOpts *opts);int unix_listen (const char *path,char *ostr,int olen);
Signature · 1 line
1.6.6
Anthony Liguori
AppliedRe: [Qemu-devel] [PATCH 1/3] net: Make inet_strfamily() public
Quoted 4 lines · Luiz Capitulino
So that it can be used by other subsystems.
Signed-off-by Luiz Capitulino<[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 31 lines
--- qemu-sockets.c | 2 +- qemu_socket.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)qemu-sockets.c +1
-1@@ -91,7 +91,7 @@ static void inet_setport(struct addrinfo *e, int port) } } -static const char *inet_strfamily (int family) +const char *inet_strfamily (int family) {switch (family) {case PF_INET6 :return "ipv6" ;qemu_socket.h +1
-0@@ -44,6 +44,7 @@ int inet_listen(const char *str, char *ostr, int olen,int inet_connect_opts (QemuOpts *opts);int inet_connect (const char *str,int socktype);int inet_dgram_opts (QemuOpts *opts); +const char *inet_strfamily (int family);int unix_listen_opts (QemuOpts *opts);int unix_listen (const char *path,char *ostr,int olen);
PATCH 2/3 net: inet_strfamily(): Better unknown family report
In reply to Luiz CapitulinoReturning "????" is a bit meaningless, let's call it "unknown".
Signed-off-by Luiz Capitulino <[email protected]>
--- qemu-sockets.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-sockets.c +1 -1
@@ -98,7 +98,7 @@ const char *inet_strfamily(int family)case PF_INET :return "ipv4" ;case PF_UNIX :return "unix" ; } -return "????" ; +return "unknown" ; }static void inet_print_addrinfo (const char *tag,struct addrinfo *res)
Signature · 1 line
1.6.6
PATCH 3/3 vnc: Use inet_strfamily()
In reply to Luiz CapitulinoSigned-off-by Luiz Capitulino <[email protected]>
--- vnc.c | 22 +--------------------- 1 files changed, 1 insertions(+), 21 deletions(-)
vnc.c +1 -21
@@ -100,26 +100,6 @@ char *vnc_socket_remote_addr(const char *format, int fd) {return addr_to_string (format, &sa, salen); } -static QString *get_sock_family (const struct sockaddr_storage *sa) -{ -const char *name; - -switch (sa->ss_family) - { -case AF_INET : - name ="ipv4" ; -break ; -case AF_INET6 : - name ="ipv6" ; -break ; -default : - name ="unknown" ; -break ; - } - -return qstring_from_str (name); -} -static int put_addr_qdict (QDict *qdict,struct sockaddr_storage *sa,socklen_t salen) {
@@ -138,7 +118,7 @@ static int put_addr_qdict(QDict *qdict, struct sockaddr_storage *sa,qdict_put (qdict,"host" ,qstring_from_str (host));qdict_put (qdict,"service" ,qstring_from_str (serv)); -qdict_put (qdict,"family" ,get_sock_family (sa)); +qdict_put (qdict,"family" ,qstring_from_str (inet_strfamily (sa->ss_family)));return 0 ; }
Signature · 1 line
1.6.6