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