@@ -84,8 +84,8 @@ public static void BreakWhen(bool c)
8484 public static uint BitFromI ( uint i ) => ( uint ) 1 << ( ( int ) i - 1 ) ; // i: 1-based
8585
8686 // https://github.com/dotnet/runtime/issues/58378
87- static AddressFamily AF_HYPERV = ( AddressFamily ) 34 ;
88- static AddressFamily AF_VSOCK = ( AddressFamily ) 40 ;
87+ public static AddressFamily AF_HYPERV = ( AddressFamily ) 34 ;
88+ public static AddressFamily AF_VSOCK = ( AddressFamily ) 40 ;
8989
9090 static readonly IPEndPoint ipEndPointv4 = new IPEndPoint ( 0 , 0 ) ;
9191 static readonly IPEndPoint ipEndPointv6 = new IPEndPoint ( IPAddress . IPv6Any , 0 ) ;
@@ -110,6 +110,7 @@ public static IPEndPoint NewEndPoint(in SocketAddress socket)
110110 // AF_HYPERV & AF_VSOCK:
111111 // https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/make-integration-service#bind-to-a-hyper-v-socket
112112 // https://man7.org/linux/man-pages/man7/vsock.7.html
113+ // https://github.com/search?q=repo%3Amicrosoft%2FWSL2-Linux-Kernel+AF_HYPERV
113114
114115 if ( socket . Family == AF_HYPERV && socket . Size >= 20 )
115116 {
@@ -128,6 +129,18 @@ public static IPEndPoint NewEndPoint(in SocketAddress socket)
128129 return ( IPEndPoint ) ipEndPointv6 . Create ( sa ) ;
129130 }
130131
132+ if ( socket . Family == AF_HYPERV && socket . Size >= 16 )
133+ {
134+ // Create an IpV6 socket and copy the data to the IpV6 address, and that's the best we can do.
135+
136+ SocketAddress sa = new SocketAddress ( AddressFamily . InterNetworkV6 , 64 ) ;
137+
138+ for ( int i = 0 ; i < 12 ; ++ i ) { sa [ i + 12 ] = socket [ i + 4 ] ; }
139+ sa [ 3 ] = ( byte ) AF_HYPERV ; // port = HyperV tag, big-endian
140+
141+ return ( IPEndPoint ) ipEndPointv6 . Create ( sa ) ;
142+ }
143+
131144 if ( socket . Family == AF_VSOCK && socket . Size >= 12 )
132145 {
133146 // Copy the svm_port and the svm_cid to the IPv6 address, and that's the best we can do.
@@ -235,6 +248,15 @@ static public string ServiceFromPort(int port)
235248 {
236249 switch ( port )
237250 {
251+ case 20 :
252+ case 21 :
253+ return "FTP" ;
254+ case 22 :
255+ return "SSH/SCP/SFTP" ;
256+ case 23 :
257+ return "TELNET" ;
258+ case 25 :
259+ return "SMTP" ;
238260 case 53 :
239261 return "DNS" ;
240262 case 80 :
@@ -243,17 +265,38 @@ static public string ServiceFromPort(int port)
243265 return "HTTP" ;
244266 case 88 :
245267 return "Kerberos" ;
268+ case 110 :
269+ return "POP3" ;
270+ case 119 :
271+ return "NNTP" ;
272+ case 123 :
273+ return "NTP" ;
246274 case 135 :
247275 return "DCE/DHCP/DNS/WINS/DCOM" ;
248- case portLDAP :
276+ case 137 :
277+ return "NetBIOS" ;
278+ case 143 :
279+ return "IMAP" ;
280+ case portLDAP : // 389
249281 return "LDAP" ;
250282 case 443 :
251283 case 8443 :
252284 return "HTTPS" ;
253285 case 445 :
254286 return "AD/SMB" ;
287+ case 465 :
288+ return "SMTPS" ;
289+ case 563 :
290+ return "NNTPS" ;
255291 case 636 :
256292 return "LDAPs" ;
293+ case 989 :
294+ case 990 :
295+ return "FTPS" ;
296+ case 993 :
297+ return "IMAPS" ;
298+ case 995 :
299+ return "POP3S" ;
257300 case 1433 :
258301 return "MSSQL" ;
259302 case 2555 :
@@ -264,6 +307,10 @@ static public string ServiceFromPort(int port)
264307 return "LDAPs/AD" ;
265308 case 3389 :
266309 return "TS/RDP" ;
310+ case 5353 :
311+ return "UDP" ;
312+ case 5355 :
313+ return "LLMNR" ;
267314 case 5985 :
268315 return "CIM/DMTF" ;
269316 case 7680 :
0 commit comments