VirtualNetworkConfig.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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.lang.String;
  29. import java.util.ArrayList;
  30. import java.net.InetSocketAddress;
  31. public final class VirtualNetworkConfig {
  32. public static final int MAX_MULTICAST_SUBSCRIPTIONS = 4096;
  33. public static final int ZT_MAX_ZT_ASSIGNED_ADDRESSES = 16;
  34. private long nwid;
  35. private long mac;
  36. private String name;
  37. private VirtualNetworkStatus status;
  38. private VirtualNetworkType type;
  39. private int mtu;
  40. private boolean dhcp;
  41. private boolean bridge;
  42. private boolean broadcastEnabled;
  43. private int portError;
  44. private boolean enabled;
  45. private long netconfRevision;
  46. private MulticastGroup[] multicastSubscriptions;
  47. private InetSocketAddress[] assignedAddresses;
  48. private VirtualNetworkConfig() {
  49. }
  50. /**
  51. * 64-bit ZeroTier network ID
  52. */
  53. public final long networkId() {
  54. return nwid;
  55. }
  56. /**
  57. * Ethernet MAC (40 bits) that should be assigned to port
  58. */
  59. public final long macAddress() {
  60. return mac;
  61. }
  62. /**
  63. * Network name (from network configuration master)
  64. */
  65. public final String name() {
  66. return name;
  67. }
  68. /**
  69. * Network configuration request status
  70. */
  71. public final VirtualNetworkStatus networkStatus() {
  72. return status;
  73. }
  74. /**
  75. * Network type
  76. */
  77. public final VirtualNetworkType networkType() {
  78. return type;
  79. }
  80. /**
  81. * Maximum interface MTU
  82. */
  83. public final int mtu() {
  84. return mtu;
  85. }
  86. /**
  87. * If the network this port belongs to indicates DHCP availability
  88. *
  89. * <p>This is a suggestion. The underlying implementation is free to ignore it
  90. * for security or other reasons. This is simply a netconf parameter that
  91. * means 'DHCP is available on this network.'</p>
  92. */
  93. public final boolean isDhcpAvailable() {
  94. return dhcp;
  95. }
  96. /**
  97. * If this port is allowed to bridge to other networks
  98. *
  99. * <p>This is informational. If this is false, bridged packets will simply
  100. * be dropped and bridging won't work.</p>
  101. */
  102. public final boolean isBridgeEnabled() {
  103. return bridge;
  104. }
  105. /**
  106. * If true, this network supports and allows broadcast (ff:ff:ff:ff:ff:ff) traffic
  107. */
  108. public final boolean broadcastEnabled() {
  109. return broadcastEnabled;
  110. }
  111. /**
  112. * If the network is in PORT_ERROR state, this is the error most recently returned by the port config callback
  113. */
  114. public final int portError() {
  115. return portError;
  116. }
  117. /**
  118. * Is this network enabled? If not, all frames to/from are dropped.
  119. */
  120. public final boolean isEnabled() {
  121. return enabled;
  122. }
  123. /**
  124. * Network config revision as reported by netconf master
  125. *
  126. * <p>If this is zero, it means we're still waiting for our netconf.</p>
  127. */
  128. public final long netconfRevision() {
  129. return netconfRevision;
  130. }
  131. /**
  132. * Multicast group subscriptions
  133. */
  134. public final MulticastGroup[] multicastSubscriptions() {
  135. return multicastSubscriptions;
  136. }
  137. /**
  138. * ZeroTier-assigned addresses (in {@link java.net.InetSocketAddress} objects)
  139. *
  140. * For IP, the port number of the sockaddr_XX structure contains the number
  141. * of bits in the address netmask. Only the IP address and port are used.
  142. * Other fields like interface number can be ignored.
  143. *
  144. * This is only used for ZeroTier-managed address assignments sent by the
  145. * virtual network's configuration master.
  146. */
  147. public final InetSocketAddress[] assignedAddresses() {
  148. return assignedAddresses;
  149. }
  150. }