Skip to content

Commit 36eb680

Browse files
authored
Merge pull request #7 from mulot/developpement
Developpement
2 parents 5cc46aa + 2089c98 commit 36eb680

File tree

5 files changed

+81
-16
lines changed

5 files changed

+81
-16
lines changed

Base.lproj/MainMenu.xib

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@
831831
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
832832
<clipView key="contentView" id="rby-ox-fjA">
833833
<rect key="frame" x="1" y="1" width="567" height="485"/>
834-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
834+
<autoresizingMask key="autoresizingMask"/>
835835
<subviews>
836836
<tableView identifier="tabViewFLSM" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" headerView="ELH-v1-zWW" id="zYs-mh-V7e">
837837
<rect key="frame" x="0.0" y="0.0" width="567" height="457"/>
@@ -1021,7 +1021,7 @@
10211021
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
10221022
<subviews>
10231023
<tableView identifier="tabViewVLSM" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" headerView="SoM-fw-J5F" id="Xp5-Sj-frC">
1024-
<rect key="frame" x="0.0" y="0.0" width="579" height="457"/>
1024+
<rect key="frame" x="0.0" y="0.0" width="884" height="457"/>
10251025
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
10261026
<size key="intercellSpacing" width="3" height="2"/>
10271027
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -1063,12 +1063,12 @@
10631063
</textFieldCell>
10641064
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
10651065
</tableColumn>
1066-
<tableColumn identifier="nameVLSMCol" editable="NO" width="203.843994140625" minWidth="36.844001770019531" maxWidth="1000" id="rxF-Te-Q4K">
1066+
<tableColumn identifier="nameVLSMCol" width="203.843994140625" minWidth="36.844001770019531" maxWidth="1000" id="rxF-Te-Q4K">
10671067
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Subnet Name">
10681068
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
10691069
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
10701070
</tableHeaderCell>
1071-
<textFieldCell key="dataCell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" alignment="left" id="juC-wO-jPv">
1071+
<textFieldCell key="dataCell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" alignment="left" id="juC-wO-jPv">
10721072
<font key="font" metaFont="system"/>
10731073
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
10741074
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -1087,6 +1087,30 @@
10871087
</textFieldCell>
10881088
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
10891089
</tableColumn>
1090+
<tableColumn identifier="rangeVLSMCol" editable="NO" width="149.51300048828125" minWidth="60.01300048828125" maxWidth="1000" id="i5N-yj-4Gi">
1091+
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Range">
1092+
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
1093+
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
1094+
</tableHeaderCell>
1095+
<textFieldCell key="dataCell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" alignment="left" id="cBn-5z-Byv">
1096+
<font key="font" metaFont="system"/>
1097+
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
1098+
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
1099+
</textFieldCell>
1100+
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
1101+
</tableColumn>
1102+
<tableColumn identifier="broadcastVLSMCol" editable="NO" width="149.51300048828125" minWidth="60.01300048828125" maxWidth="1000" id="2mz-yz-Fkv">
1103+
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Broadcast">
1104+
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
1105+
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
1106+
</tableHeaderCell>
1107+
<textFieldCell key="dataCell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" alignment="left" id="mXd-Jc-hvk">
1108+
<font key="font" metaFont="system"/>
1109+
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
1110+
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
1111+
</textFieldCell>
1112+
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
1113+
</tableColumn>
10901114
</tableColumns>
10911115
<connections>
10921116
<outlet property="dataSource" destination="b7w-M5-ti7" id="wKM-A7-jKm"/>
@@ -1103,7 +1127,7 @@
11031127
<autoresizingMask key="autoresizingMask"/>
11041128
</scroller>
11051129
<tableHeaderView key="headerView" wantsLayer="YES" id="SoM-fw-J5F">
1106-
<rect key="frame" x="0.0" y="0.0" width="579" height="28"/>
1130+
<rect key="frame" x="0.0" y="0.0" width="884" height="28"/>
11071131
<autoresizingMask key="autoresizingMask"/>
11081132
</tableHeaderView>
11091133
</scrollView>

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# SubnetCalc
22
Subnet Calculator for MacOS
33

4-
What's New in version 2.1:
5-
- FLSM (Fixed Length Subnet Mask) support
6-
- VLSM (Variable Length Subnet Mask) support
7-
- Export FSLM result in a CSV file
8-
- Export VSLM result in a CSV file
4+
What's New in version 2.2:
5+
- Change the VLSM Subnet Name by editing the corresponding column
6+
- Display Hosts Range and Broadcast columns in the VLSM view
7+
- Export Hosts Range and Broadcast infos to the CSV file
8+
99

1010

1111
For more information: http://subnetcalc.mulot.org

SubnetCalc-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.1</string>
18+
<string>$(MARKETING_VERSION)</string>
1919
<key>CFBundleSignature</key>
2020
<string>JMUL</string>
2121
<key>CFBundleVersion</key>

SubnetCalc.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@
401401
CODE_SIGN_IDENTITY = "Mac Developer";
402402
COMBINE_HIDPI_IMAGES = YES;
403403
COPY_PHASE_STRIP = NO;
404-
CURRENT_PROJECT_VERSION = 7;
404+
CURRENT_PROJECT_VERSION = 8;
405405
DEVELOPMENT_TEAM = VNLK894MAE;
406406
ENABLE_HARDENED_RUNTIME = YES;
407407
GCC_DYNAMIC_NO_PIC = NO;
@@ -411,6 +411,7 @@
411411
INFOPLIST_FILE = "SubnetCalc-Info.plist";
412412
INSTALL_PATH = "$(HOME)/Applications";
413413
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
414+
MARKETING_VERSION = 2.2;
414415
PRODUCT_BUNDLE_IDENTIFIER = net.mulot.subnetcalc;
415416
PRODUCT_NAME = SubnetCalc;
416417
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -429,7 +430,7 @@
429430
CODE_SIGN_ENTITLEMENTS = SubnetCalc.entitlements;
430431
CODE_SIGN_IDENTITY = "Mac Developer";
431432
COMBINE_HIDPI_IMAGES = YES;
432-
CURRENT_PROJECT_VERSION = 7;
433+
CURRENT_PROJECT_VERSION = 8;
433434
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
434435
DEVELOPMENT_TEAM = VNLK894MAE;
435436
ENABLE_HARDENED_RUNTIME = YES;
@@ -438,6 +439,7 @@
438439
INFOPLIST_FILE = "SubnetCalc-Info.plist";
439440
INSTALL_PATH = /Applications;
440441
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
442+
MARKETING_VERSION = 2.2;
441443
PRODUCT_BUNDLE_IDENTIFIER = net.mulot.subnetcalc;
442444
PRODUCT_NAME = SubnetCalc;
443445
PROVISIONING_PROFILE_SPECIFIER = "";

SubnetCalcAppDelegate.swift

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,18 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
776776
return 0
777777
}
778778

779+
//Invoked when editing a value from a TabView
780+
//Used only for VLSM Subnet Name
781+
func tableView(_ tableView: NSTableView, setObjectValue object: Any?, for tableColumn: NSTableColumn?, row: Int)
782+
{
783+
if (tableView == viewVLSM) {
784+
if (tableColumn!.identifier.rawValue == "nameVLSMCol") {
785+
//print("edit tableView Name VLSM: \(row) \(object as! String)")
786+
subnetsVLSM[row].1 = object as! String
787+
}
788+
}
789+
}
790+
779791
//Display all subnets info in the TableView Subnet/Hosts
780792
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?,
781793
row: Int) -> Any?
@@ -848,12 +860,38 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
848860
else if (tableColumn!.identifier.rawValue == "usedVLSMCol") {
849861
return (subnetsVLSM[row].2)
850862
}
863+
else if (tableColumn!.identifier.rawValue == "rangeVLSMCol") {
864+
var subnet = IPSubnetCalc.numerize(ipAddress: ipsc!.subnetId())
865+
if (row > 0) {
866+
for index in (0...(row - 1)) {
867+
subnet = subnet + ~IPSubnetCalc.numerize(maskbits: subnetsVLSM[index].0) + 1
868+
}
869+
}
870+
let ipsc_tmp = IPSubnetCalc(ipAddress: IPSubnetCalc.digitize(ipAddress: subnet), maskbits: (subnetsVLSM[row].0))
871+
if (ipsc_tmp != nil)
872+
{
873+
return (ipsc_tmp!.subnetRange())
874+
}
875+
}
876+
else if (tableColumn!.identifier.rawValue == "broadcastVLSMCol") {
877+
var subnet = IPSubnetCalc.numerize(ipAddress: ipsc!.subnetId())
878+
if (row > 0) {
879+
for index in (0...(row - 1)) {
880+
subnet = subnet + ~IPSubnetCalc.numerize(maskbits: subnetsVLSM[index].0) + 1
881+
}
882+
}
883+
let ipsc_tmp = IPSubnetCalc(ipAddress: IPSubnetCalc.digitize(ipAddress: subnet), maskbits: (subnetsVLSM[row].0))
884+
if (ipsc_tmp != nil)
885+
{
886+
return (ipsc_tmp!.subnetBroadcast())
887+
}
888+
}
851889
}
852890
}
853891
}
854892
return (nil)
855893
}
856-
894+
857895
@IBAction func subnetBitsSlide(_ sender: AnyObject)
858896
{
859897
if (ipsc == nil)
@@ -1174,7 +1212,7 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
11741212
var cvsData = Data(capacity: Constants.BUFFER_LINES)
11751213
let cvsFile = FileHandle(forWritingAtPath: panel.url!.path)
11761214
if (cvsFile != nil) {
1177-
var cvsStr = "#;Subnet ID;Mask bits;Subnet Name;Used\n"
1215+
var cvsStr = "#;Subnet Name;Subnet ID;Mask bits;Hosts Range;Broadcast;Used\n"
11781216
let subnetid = IPSubnetCalc.numerize(ipAddress: self.ipsc!.subnetId())
11791217
for index in (0...(self.subnetsVLSM.count - 1)) {
11801218
var subnet = subnetid
@@ -1183,8 +1221,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
11831221
subnet = subnet + ~IPSubnetCalc.numerize(maskbits: self.subnetsVLSM[index2].0) + 1
11841222
}
11851223
}
1224+
let ipsc_tmp = IPSubnetCalc(ipAddress: IPSubnetCalc.digitize(ipAddress: subnet), maskbits: self.subnetsVLSM[index].0)!
11861225
//print("VLSM: \(index + 1);\(IPSubnetCalc.digitize(ipAddress: subnet));\(self.subnetsVLSM[index].0);\(self.subnetsVLSM[index].1);\(self.subnetsVLSM[index].2)\n")
1187-
cvsStr.append("\(index + 1);\(IPSubnetCalc.digitize(ipAddress: subnet));\(self.subnetsVLSM[index].0);\(self.subnetsVLSM[index].1);\(self.subnetsVLSM[index].2)\n")
1226+
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")
11881227
}
11891228
cvsData.append(cvsStr.data(using: String.Encoding.ascii)!)
11901229
cvsFile!.write(cvsData)

0 commit comments

Comments
 (0)