From 178c7155a396596258be27b603c474c351425313 Mon Sep 17 00:00:00 2001 From: Abdul Rehman Date: Tue, 10 Nov 2020 22:31:41 +0500 Subject: [PATCH] threadshare/udpsrc: SocketAddr to InetSocketAddress direct conversion --- generic/threadshare/src/udpsrc.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/generic/threadshare/src/udpsrc.rs b/generic/threadshare/src/udpsrc.rs index f8dd26ad..2572f2f0 100644 --- a/generic/threadshare/src/udpsrc.rs +++ b/generic/threadshare/src/udpsrc.rs @@ -454,16 +454,10 @@ impl TaskImpl for UdpSrcTask { .await .retrieve_sender_address { - let inet_addr = match saddr.ip() { - IpAddr::V4(ip) => { - gio::InetAddress::from_bytes(gio::InetAddressBytes::V4(&ip.octets())) - } - IpAddr::V6(ip) => { - gio::InetAddress::from_bytes(gio::InetAddressBytes::V6(&ip.octets())) - } - }; - let inet_socket_addr = &gio::InetSocketAddress::new(&inet_addr, saddr.port()); - NetAddressMeta::add(buffer.get_mut().unwrap(), inet_socket_addr); + NetAddressMeta::add( + buffer.get_mut().unwrap(), + &gio::InetSocketAddress::from(saddr), + ); } }