From 6e4027a7fa9356d155043b7b0290e1860cf739e1 Mon Sep 17 00:00:00 2001 From: Julien Mulot Date: Mon, 2 Aug 2021 10:09:44 +0200 Subject: [PATCH 1/5] New version 2.2 Add Broadcast and Hosts Range info to VLSM tabview and CSV export --- Base.lproj/MainMenu.xib | 32 ++++++++++++++++++++++++---- SubnetCalc-Info.plist | 2 +- SubnetCalc.xcodeproj/project.pbxproj | 6 ++++-- SubnetCalcAppDelegate.swift | 31 +++++++++++++++++++++++++-- 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/Base.lproj/MainMenu.xib b/Base.lproj/MainMenu.xib index c680f3c..cda6082 100644 --- a/Base.lproj/MainMenu.xib +++ b/Base.lproj/MainMenu.xib @@ -539,7 +539,7 @@ - + @@ -1021,7 +1021,7 @@ - + @@ -1063,7 +1063,7 @@ - + @@ -1087,6 +1087,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -1103,7 +1127,7 @@ - + diff --git a/SubnetCalc-Info.plist b/SubnetCalc-Info.plist index 0a089da..4924201 100644 --- a/SubnetCalc-Info.plist +++ b/SubnetCalc-Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2.1 + $(MARKETING_VERSION) CFBundleSignature JMUL CFBundleVersion diff --git a/SubnetCalc.xcodeproj/project.pbxproj b/SubnetCalc.xcodeproj/project.pbxproj index 3021f2a..30225b3 100644 --- a/SubnetCalc.xcodeproj/project.pbxproj +++ b/SubnetCalc.xcodeproj/project.pbxproj @@ -401,7 +401,7 @@ CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = VNLK894MAE; ENABLE_HARDENED_RUNTIME = YES; GCC_DYNAMIC_NO_PIC = NO; @@ -411,6 +411,7 @@ INFOPLIST_FILE = "SubnetCalc-Info.plist"; INSTALL_PATH = "$(HOME)/Applications"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MARKETING_VERSION = 2.2; PRODUCT_BUNDLE_IDENTIFIER = net.mulot.subnetcalc; PRODUCT_NAME = SubnetCalc; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -429,7 +430,7 @@ CODE_SIGN_ENTITLEMENTS = SubnetCalc.entitlements; CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = VNLK894MAE; ENABLE_HARDENED_RUNTIME = YES; @@ -438,6 +439,7 @@ INFOPLIST_FILE = "SubnetCalc-Info.plist"; INSTALL_PATH = /Applications; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MARKETING_VERSION = 2.2; PRODUCT_BUNDLE_IDENTIFIER = net.mulot.subnetcalc; PRODUCT_NAME = SubnetCalc; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/SubnetCalcAppDelegate.swift b/SubnetCalcAppDelegate.swift index e8e9271..8dda087 100644 --- a/SubnetCalcAppDelegate.swift +++ b/SubnetCalcAppDelegate.swift @@ -848,6 +848,32 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, else if (tableColumn!.identifier.rawValue == "usedVLSMCol") { return (subnetsVLSM[row].2) } + else if (tableColumn!.identifier.rawValue == "rangeVLSMCol") { + var subnet = IPSubnetCalc.numerize(ipAddress: ipsc!.subnetId()) + if (row > 0) { + for index in (0...(row - 1)) { + subnet = subnet + ~IPSubnetCalc.numerize(maskbits: subnetsVLSM[index].0) + 1 + } + } + let ipsc_tmp = IPSubnetCalc(ipAddress: IPSubnetCalc.digitize(ipAddress: subnet), maskbits: (subnetsVLSM[row].0)) + if (ipsc_tmp != nil) + { + return (ipsc_tmp!.subnetRange()) + } + } + else if (tableColumn!.identifier.rawValue == "broadcastVLSMCol") { + var subnet = IPSubnetCalc.numerize(ipAddress: ipsc!.subnetId()) + if (row > 0) { + for index in (0...(row - 1)) { + subnet = subnet + ~IPSubnetCalc.numerize(maskbits: subnetsVLSM[index].0) + 1 + } + } + let ipsc_tmp = IPSubnetCalc(ipAddress: IPSubnetCalc.digitize(ipAddress: subnet), maskbits: (subnetsVLSM[row].0)) + if (ipsc_tmp != nil) + { + return (ipsc_tmp!.subnetBroadcast()) + } + } } } } @@ -1174,7 +1200,7 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, var cvsData = Data(capacity: Constants.BUFFER_LINES) let cvsFile = FileHandle(forWritingAtPath: panel.url!.path) if (cvsFile != nil) { - var cvsStr = "#;Subnet ID;Mask bits;Subnet Name;Used\n" + var cvsStr = "#;Subnet Name;Subnet ID;Mask bits;Hosts Range;Broadcast;Used\n" let subnetid = IPSubnetCalc.numerize(ipAddress: self.ipsc!.subnetId()) for index in (0...(self.subnetsVLSM.count - 1)) { var subnet = subnetid @@ -1183,8 +1209,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, subnet = subnet + ~IPSubnetCalc.numerize(maskbits: self.subnetsVLSM[index2].0) + 1 } } + let ipsc_tmp = IPSubnetCalc(ipAddress: IPSubnetCalc.digitize(ipAddress: subnet), maskbits: self.subnetsVLSM[index].0)! //print("VLSM: \(index + 1);\(IPSubnetCalc.digitize(ipAddress: subnet));\(self.subnetsVLSM[index].0);\(self.subnetsVLSM[index].1);\(self.subnetsVLSM[index].2)\n") - cvsStr.append("\(index + 1);\(IPSubnetCalc.digitize(ipAddress: subnet));\(self.subnetsVLSM[index].0);\(self.subnetsVLSM[index].1);\(self.subnetsVLSM[index].2)\n") + cvsStr.append("\(index + 1);\(self.subnetsVLSM[index].1);\(ipsc_tmp.subnetId());\(self.subnetsVLSM[index].0);\(ipsc_tmp.subnetRange());\(ipsc_tmp.subnetBroadcast());\(self.subnetsVLSM[index].2)\n") } cvsData.append(cvsStr.data(using: String.Encoding.ascii)!) cvsFile!.write(cvsData) From 1688e9954db1421b2bc44aeacc19dff5de3278a2 Mon Sep 17 00:00:00 2001 From: Julien Mulot Date: Mon, 2 Aug 2021 14:37:49 +0200 Subject: [PATCH 2/5] Handle change VLSM Subnet Name by editing value in Column --- Base.lproj/MainMenu.xib | 6 +++--- SubnetCalcAppDelegate.swift | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Base.lproj/MainMenu.xib b/Base.lproj/MainMenu.xib index cda6082..c471e3c 100644 --- a/Base.lproj/MainMenu.xib +++ b/Base.lproj/MainMenu.xib @@ -539,7 +539,7 @@ - + @@ -831,7 +831,7 @@ - + @@ -1068,7 +1068,7 @@ - + diff --git a/SubnetCalcAppDelegate.swift b/SubnetCalcAppDelegate.swift index 8dda087..02f09c9 100644 --- a/SubnetCalcAppDelegate.swift +++ b/SubnetCalcAppDelegate.swift @@ -776,6 +776,19 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, return 0 } + //edit a value from a TabView - only for VLSM Subnet Name + func tableView(_ tableView: NSTableView, setObjectValue object: Any?, for tableColumn: NSTableColumn?, row: Int) + { + print("edit table View") + if (tableView == viewVLSM) { + print("edit table View VLSM") + if (tableColumn!.identifier.rawValue == "nameVLSMCol") { + print("edit tableView Name VLSM: \(row) \(object as! String)") + subnetsVLSM[row].1 = object as! String + } + } + } + //Display all subnets info in the TableView Subnet/Hosts func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? @@ -879,7 +892,7 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, } return (nil) } - + @IBAction func subnetBitsSlide(_ sender: AnyObject) { if (ipsc == nil) From 36f26462062876504cce57f25b11c528a2a93d3a Mon Sep 17 00:00:00 2001 From: Julien Mulot Date: Mon, 2 Aug 2021 16:37:16 +0200 Subject: [PATCH 3/5] Update README file for version 2.2 --- README.md | 10 +++++----- SubnetCalcAppDelegate.swift | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ef4fb4b..fa5b765 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # SubnetCalc Subnet Calculator for MacOS -What's New in version 2.1: -- FLSM (Fixed Length Subnet Mask) support -- VLSM (Variable Length Subnet Mask) support -- Export FSLM result in a CSV file -- Export VSLM result in a CSV file +What's New in version 2.2: +- Can change the VLSM Subnet Name by editing the corresponding column +- Add Hosts Range and Broadcast columns to the VLSM view +- Add Hosts Range and Broadcast VLSM infos to the exported CSV file + For more information: http://subnetcalc.mulot.org diff --git a/SubnetCalcAppDelegate.swift b/SubnetCalcAppDelegate.swift index 02f09c9..3c1b1a5 100644 --- a/SubnetCalcAppDelegate.swift +++ b/SubnetCalcAppDelegate.swift @@ -776,14 +776,13 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, return 0 } - //edit a value from a TabView - only for VLSM Subnet Name + //Invoked when editing a value from a TabView + //Used only for VLSM Subnet Name func tableView(_ tableView: NSTableView, setObjectValue object: Any?, for tableColumn: NSTableColumn?, row: Int) { - print("edit table View") if (tableView == viewVLSM) { - print("edit table View VLSM") if (tableColumn!.identifier.rawValue == "nameVLSMCol") { - print("edit tableView Name VLSM: \(row) \(object as! String)") + //print("edit tableView Name VLSM: \(row) \(object as! String)") subnetsVLSM[row].1 = object as! String } } From 4d6be6c6f63e40af8bd8738e32e8bbd9c69cce65 Mon Sep 17 00:00:00 2001 From: Julien Mulot Date: Mon, 2 Aug 2021 18:32:22 +0200 Subject: [PATCH 4/5] change build version --- SubnetCalc.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SubnetCalc.xcodeproj/project.pbxproj b/SubnetCalc.xcodeproj/project.pbxproj index 30225b3..f50e9e9 100644 --- a/SubnetCalc.xcodeproj/project.pbxproj +++ b/SubnetCalc.xcodeproj/project.pbxproj @@ -401,7 +401,7 @@ CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 8; DEVELOPMENT_TEAM = VNLK894MAE; ENABLE_HARDENED_RUNTIME = YES; GCC_DYNAMIC_NO_PIC = NO; @@ -430,7 +430,7 @@ CODE_SIGN_ENTITLEMENTS = SubnetCalc.entitlements; CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 8; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = VNLK894MAE; ENABLE_HARDENED_RUNTIME = YES; From 2089c986e9de48c310f884ff0576890924a9653a Mon Sep 17 00:00:00 2001 From: Julien Mulot Date: Mon, 2 Aug 2021 18:36:26 +0200 Subject: [PATCH 5/5] Change README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fa5b765..31185b7 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ Subnet Calculator for MacOS What's New in version 2.2: -- Can change the VLSM Subnet Name by editing the corresponding column -- Add Hosts Range and Broadcast columns to the VLSM view -- Add Hosts Range and Broadcast VLSM infos to the exported CSV file +- Change the VLSM Subnet Name by editing the corresponding column +- Display Hosts Range and Broadcast columns in the VLSM view +- Export Hosts Range and Broadcast infos to the CSV file