@@ -96,19 +96,6 @@ public static NetworkInterface[] GetAllNetworkInterfaces()
9696 return ifaces ;
9797 }
9898
99- private string IPv4AddressToString ( uint ipv4Address )
100- {
101- return string . Concat (
102- ( ( ipv4Address >> 0 ) & 0xFF ) . ToString ( ) ,
103- "." ,
104- ( ( ipv4Address >> 8 ) & 0xFF ) . ToString ( ) ,
105- "." ,
106- ( ( ipv4Address >> 16 ) & 0xFF ) . ToString ( ) ,
107- "." ,
108- ( ( ipv4Address >> 24 ) & 0xFF ) . ToString ( )
109- ) ;
110- }
111-
11299 private string IPv6AddressToString ( uint [ ] ipv6Address )
113100 {
114101 throw new NotImplementedException ( ) ;
@@ -134,9 +121,9 @@ public void EnableStaticIPv4(string ipv4Address, string ipv4SubnetMask, string i
134121 {
135122 try
136123 {
137- _ipv4Address = IPAddressFromString ( ipv4Address ) ;
138- _ipv4NetMask = IPAddressFromString ( ipv4SubnetMask ) ;
139- _ipv4GatewayAddress = IPAddressFromString ( ipv4GatewayAddress ) ;
124+ _ipv4Address = ( uint ) IPAddressFromString ( ipv4Address ) ;
125+ _ipv4NetMask = ( uint ) IPAddressFromString ( ipv4SubnetMask ) ;
126+ _ipv4GatewayAddress = ( uint ) IPAddressFromString ( ipv4GatewayAddress ) ;
140127 _startupAddressMode = AddressMode . Static ;
141128
142129 UpdateConfiguration ( ( int ) UpdateOperation . Dhcp ) ;
@@ -190,9 +177,9 @@ public void EnableStaticIP(string ipv4Address, string ipv4subnetMask, string ipv
190177 {
191178 throw new NotImplementedException ( ) ;
192179
193- _ipv4Address = IPAddressFromString ( ipv4Address ) ;
194- _ipv4NetMask = IPAddressFromString ( ipv4subnetMask ) ;
195- _ipv4GatewayAddress = IPAddressFromString ( ipv4gatewayAddress ) ;
180+ _ipv4Address = ( uint ) IPAddressFromString ( ipv4Address ) ;
181+ _ipv4NetMask = ( uint ) IPAddressFromString ( ipv4subnetMask ) ;
182+ _ipv4GatewayAddress = ( uint ) IPAddressFromString ( ipv4gatewayAddress ) ;
196183
197184 // FIXME
198185 // need to test this
@@ -242,7 +229,7 @@ public void EnableStaticIPv4Dns(string[] dnsAddresses)
242229 int iAddress = 0 ;
243230 for ( int i = 0 ; i < dnsAddresses . Length ; i ++ )
244231 {
245- uint address = IPAddressFromString ( dnsAddresses [ i ] ) ;
232+ uint address = ( uint ) IPAddressFromString ( dnsAddresses [ i ] ) ;
246233
247234 addresses [ iAddress ] = address ;
248235
@@ -351,23 +338,23 @@ public bool IsAutomaticDnsEnabled
351338 /// </summary>
352339 public string IPv4Address
353340 {
354- get { return IPv4AddressToString ( _ipv4Address ) ; }
341+ get { return IPAddress . IPv4ToString ( _ipv4Address ) ; }
355342 }
356343
357344 /// <summary>
358345 /// Contains the gateway IPv4 address.
359346 /// </summary>
360347 public string IPv4GatewayAddress
361348 {
362- get { return IPv4AddressToString ( _ipv4GatewayAddress ) ; }
349+ get { return IPAddress . IPv4ToString ( _ipv4GatewayAddress ) ; }
363350 }
364351
365352 /// <summary>
366353 /// Retrieves the network interface's IPv4 subnet mask.
367354 /// </summary>
368355 public string IPv4SubnetMask
369356 {
370- get { return IPv4AddressToString ( _ipv4NetMask ) ; }
357+ get { return IPAddress . IPv4ToString ( _ipv4NetMask ) ; }
371358 }
372359
373360 /// <summary>
@@ -390,12 +377,12 @@ public string[] IPv4DnsAddresses
390377
391378 if ( _ipv4dnsAddress1 != 0 )
392379 {
393- list . Add ( IPv4AddressToString ( _ipv4dnsAddress1 ) ) ;
380+ list . Add ( IPAddress . IPv4ToString ( _ipv4dnsAddress1 ) ) ;
394381 }
395382
396383 if ( _ipv4dnsAddress2 != 0 )
397384 {
398- list . Add ( IPv4AddressToString ( _ipv4dnsAddress2 ) ) ;
385+ list . Add ( IPAddress . IPv4ToString ( _ipv4dnsAddress2 ) ) ;
399386 }
400387
401388 return ( string [ ] ) list . ToArray ( typeof ( string ) ) ;
@@ -489,7 +476,7 @@ public NetworkInterfaceType NetworkInterfaceType
489476 private extern void UpdateConfiguration ( int updateType ) ;
490477
491478 [ MethodImpl ( MethodImplOptions . InternalCall ) ]
492- private static extern uint IPAddressFromString ( string ipAddress ) ;
479+ internal static extern long IPAddressFromString ( string ipAddress ) ;
493480
494481 #endregion
495482 }
0 commit comments