convert netaddr to string

This commit is contained in:
Doug MacEachern 2004-09-17 21:05:59 +00:00
parent 14599dcd6a
commit 47a544ec5a
1 changed files with 37 additions and 0 deletions

View File

@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Collections;
using System.Runtime.InteropServices;
using System.Text;
namespace Hyperic.Sigar {
public class Sigar {
@ -395,5 +396,41 @@ namespace Hyperic.Sigar {
return ifconfig;
}
[DllImport(Sigar.LIBSIGAR)]
private static extern int
sigar_inet_ntoa(IntPtr sigar, ulong address,
StringBuilder addr_str);
private string inet_ntoa(ulong address) {
StringBuilder buffer = new StringBuilder();
buffer.Capacity = (3 * 4 + 3 + 1);
sigar_inet_ntoa(IntPtr.Zero, address, buffer);
return buffer.ToString();
}
public string Address {
get {
return inet_ntoa(this.address);
}
}
public string Destination {
get {
return inet_ntoa(this.destination);
}
}
public string Broadcast {
get {
return inet_ntoa(this.broadcast);
}
}
public string Netmask {
get {
return inet_ntoa(this.netmask);
}
}
}
}