Network.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
  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. #import <Foundation/Foundation.h>
  19. enum NetworkStatus {
  20. REQUESTING_CONFIGURATION,
  21. OK,
  22. ACCESS_DENIED,
  23. NOT_FOUND,
  24. PORT_ERROR,
  25. CLIENT_TOO_OLD,
  26. };
  27. enum NetworkType {
  28. PUBLIC,
  29. PRIVATE,
  30. };
  31. @interface Network : NSObject <NSCoding>
  32. @property (readonly) NSArray<NSString*> *assignedAddresses;
  33. @property (readonly) BOOL bridge;
  34. @property (readonly) BOOL broadcastEnabled;
  35. @property (readonly) BOOL dhcp;
  36. @property (readonly) NSString *mac;
  37. @property (readonly) int mtu;
  38. @property (readonly) int netconfRevision;
  39. @property (readonly) NSString *name;
  40. @property (readonly) UInt64 nwid;
  41. @property (readonly) NSString *portDeviceName;
  42. @property (readonly) int portError;
  43. @property (readonly) enum NetworkStatus status;
  44. @property (readonly) enum NetworkType type;
  45. @property (readonly) BOOL allowManaged;
  46. @property (readonly) BOOL allowGlobal;
  47. @property (readonly) BOOL allowDefault;
  48. @property (readonly) BOOL allowDNS;
  49. @property (readonly) BOOL connected; // not persisted. set to YES if loaded via json
  50. - (id)initWithJsonData:(NSDictionary*)jsonData;
  51. - (id)initWithCoder:(NSCoder *)aDecoder;
  52. - (void)encodeWithCoder:(NSCoder *)aCoder;
  53. + (BOOL)defaultRouteExists:(NSArray<Network *>*)netList;
  54. - (NSString*)statusString;
  55. - (NSString*)typeString;
  56. - (BOOL)hasSameNetworkId:(UInt64)networkId;
  57. - (BOOL)isEqualToNetwork:(Network*)network;
  58. - (BOOL)isEqual:(id)object;
  59. - (NSUInteger)hash;
  60. @end