PageRenderTime 47ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/verify/src/Checked/Libraries/NetStack2/DNSImpConnection.cs

#
C# | 72 lines | 48 code | 8 blank | 16 comment | 9 complexity | cef95a6024c90fb6e97ba40a0058cb13 MD5 | raw file
  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft Research Singularity
  4. //
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. //
  7. // File: DNSImpConnection.gs
  8. // Author: maiken
  9. // Note: Client-side helper for the IP Channel Contract
  10. //
  11. using System;
  12. using System.Threading;
  13. using System.Net.IP;
  14. //using Microsoft.Singularity.Drivers.Net;
  15. //using Microsoft.SingSharp;
  16. using Microsoft.Singularity;
  17. using Microsoft.Singularity.Channels;
  18. using Microsoft.Singularity.Directory;
  19. using Microsoft.Singularity.NetStack2;
  20. //using Microsoft.Singularity.NetStack.Runtime;
  21. using DNSContract = Microsoft.Singularity.NetStack2.Channels.Private.DNSContract;
  22. namespace Microsoft.Singularity.NetStack2
  23. {
  24. public class DNSImpConnection
  25. {
  26. // Converts the results of GerNameServers to IPv4 structures
  27. public static IPv4[] GetNameServers(DNSContract/*.Imp*/ ep)
  28. {
  29. IPv4[] addrList = ep.GetNameServers();
  30. IPv4[] retval;
  31. if (addrList == null) {
  32. retval = new IPv4[0];
  33. }
  34. else {
  35. retval = addrList;
  36. }
  37. return retval;
  38. }
  39. // Converts the retrieved address(es) to IPv4 structures.
  40. // Returns true iff the named host was found successfully.
  41. public static bool Resolve(DNSContract/*.Imp*/ ep, string name,
  42. out string[] aliases, out IPv4[] addrs)
  43. {
  44. aliases = null;
  45. addrs = null;
  46. IPv4[] addrList;
  47. String[] aliasesResult;
  48. ep.Resolve(name, out addrList, out aliasesResult);
  49. if (aliasesResult != null) {
  50. aliases = aliasesResult;
  51. }
  52. else {
  53. aliases = new string[0];
  54. }
  55. if (addrList != null) {
  56. addrs = addrList;
  57. }
  58. else {
  59. addrs = new IPv4[0];
  60. }
  61. return true; // success;
  62. }
  63. }
  64. }