/// <summary> /// Query which subnet is in use. /// </summary> /// <param name="aCookie">Identifier for NetworkAdapter reference. Must be used in a later call to NetworkAdapter.RemoveRef()</param> /// <returns>Network adapter. Or null if no subnet is selected or we're running the device stack on all subnets.</returns> public static NetworkAdapter CurrentAdapter(string aCookie) { IntPtr cookie = InteropUtils.StringToHGlobalUtf8(aCookie); IntPtr nif = OhNetCurrentSubnetAdapter(cookie); if (nif == IntPtr.Zero) return null; NetworkAdapter n = new NetworkAdapter(nif); n.AddManagedCookie(aCookie, cookie); return n; }
public static void Main(string[] args) { Core.InitParams initParams = new Core.InitParams(); using (Core.Library lib = Core.Library.Create(initParams)) { Core.SubnetList subnetList = new Core.SubnetList(); Core.NetworkAdapter nif = subnetList.SubnetAt(0); uint subnet = nif.Subnet(); Console.WriteLine("Using adapter: {0}", nif.Name()); subnetList.Dispose(); lib.StartCp(subnet); new Runner((int)initParams.MsearchTimeSecs); } }
/// <summary> /// Set which subnet the library should use /// </summary> /// <remarks>Device lists and subscriptions will be automatically updated. /// /// No other subnet will be selected if aSubnet is not available</remarks> /// <param name="aSubnet">Handle returned by SubnetAt()</param> public void SetCurrentSubnet(NetworkAdapter aSubnet) { OhNetSetCurrentSubnet(aSubnet.Subnet()); }
public static void NetworkAdapter(IntPtr aPtr, IntPtr aAdapter) { GCHandle gch = GCHandle.FromIntPtr(aPtr); NetworkAdapterListener listener = (NetworkAdapterListener)gch.Target; NetworkAdapter adapter = new NetworkAdapter(aAdapter); if(listener.iHandler != null) { listener.iHandler(adapter); } }
private void NetworkAdapterChanged(NetworkAdapter aAdapter) { Console.WriteLine(String.Format("NetworkAdapterChanged: {0}", aAdapter.Name())); }
private void SubnetRemoved(NetworkAdapter aAdapter) { Console.WriteLine(String.Format("SubnetRemoved: {0}", aAdapter.Name())); }