コード例 #1
0
ファイル: SubnetList.cs プロジェクト: nterry/ohNet
 /// <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;
 }
コード例 #2
0
ファイル: TestProxy.cs プロジェクト: simoncn/ohNet
 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);
     }
 }
コード例 #3
0
ファイル: OhNet.cs プロジェクト: chinshou/ohNet
 /// <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());
 }
コード例 #4
0
ファイル: OhNet.cs プロジェクト: kevin5391/ohNet
 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);
     }
 }
コード例 #5
0
ファイル: TestAdapterChange.cs プロジェクト: Wodath/ohNet
 private void NetworkAdapterChanged(NetworkAdapter aAdapter)
 {
     Console.WriteLine(String.Format("NetworkAdapterChanged: {0}", aAdapter.Name()));
 }
コード例 #6
0
ファイル: TestAdapterChange.cs プロジェクト: Wodath/ohNet
 private void SubnetRemoved(NetworkAdapter aAdapter)
 {
     Console.WriteLine(String.Format("SubnetRemoved: {0}", aAdapter.Name()));
 }
コード例 #7
0
 /// <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());
 }