Peer.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2015 ZeroTier, Inc.
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * --
  19. *
  20. * ZeroTier may be used and distributed under the terms of the GPLv3, which
  21. * are available at: http://www.gnu.org/licenses/gpl-3.0.html
  22. *
  23. * If you would like to embed ZeroTier into a commercial application or
  24. * redistribute it in a modified binary form, please contact ZeroTier Networks
  25. * LLC. Start here: http://www.zerotier.com/
  26. */
  27. package com.zerotier.sdk;
  28. import java.util.ArrayList;
  29. /**
  30. * Peer status result
  31. */
  32. public final class Peer {
  33. private long address;
  34. private long lastUnicastFrame;
  35. private long lastMulticastFrame;
  36. private int versionMajor;
  37. private int versionMinor;
  38. private int versionRev;
  39. private int latency;
  40. private PeerRole role;
  41. private ArrayList<PeerPhysicalPath> paths;
  42. private Peer() {}
  43. /**
  44. * ZeroTier address (40 bits)
  45. */
  46. public final long address() {
  47. return address;
  48. }
  49. /**
  50. * Time we last received a unicast frame from this peer
  51. */
  52. public final long lastUnicastFrame() {
  53. return lastUnicastFrame;
  54. }
  55. /**
  56. * Time we last received a multicast rame from this peer
  57. */
  58. public final long lastMulticastFrame() {
  59. return lastMulticastFrame;
  60. }
  61. /**
  62. * Remote major version or -1 if not known
  63. */
  64. public final int versionMajor() {
  65. return versionMajor;
  66. }
  67. /**
  68. * Remote minor version or -1 if not known
  69. */
  70. public final int versionMinor() {
  71. return versionMinor;
  72. }
  73. /**
  74. * Remote revision or -1 if not known
  75. */
  76. public final int versionRev() {
  77. return versionRev;
  78. }
  79. /**
  80. * Last measured latency in milliseconds or zero if unknown
  81. */
  82. public final int latency() {
  83. return latency;
  84. }
  85. /**
  86. * What trust hierarchy role does this device have?
  87. */
  88. public final PeerRole role() {
  89. return role;
  90. }
  91. /**
  92. * Known network paths to peer
  93. */
  94. public final ArrayList<PeerPhysicalPath> paths() {
  95. return paths;
  96. }
  97. }