Skip to content

Commit 5cc46aa

Browse files
authored
Merge pull request #6 from mulot/developpement
Developpement
2 parents d75a6ea + 295e241 commit 5cc46aa

File tree

7 files changed

+836
-139
lines changed

7 files changed

+836
-139
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ iOSInjectionProject/
9191

9292
__MACOSX
9393
.DS_Store
94+
.zhistory
95+

Base.lproj/MainMenu.xib

Lines changed: 459 additions & 57 deletions
Large diffs are not rendered by default.

IPSubnetcalc.swift

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,19 @@ class IPSubnetCalc: NSObject {
502502
return (bitMap)
503503
}
504504

505+
// return maskbits and number of max hosts for this mask
506+
static func fittingSubnet(hosts: UInt) -> (Int, UInt) {
507+
var maxHosts: UInt
508+
509+
for index in 1...31 {
510+
maxHosts = UInt(truncating: NSDecimalNumber(decimal: pow(2, index))) - 2
511+
if (hosts <= maxHosts) {
512+
return (32 - index, maxHosts)
513+
}
514+
}
515+
return (0, 0)
516+
}
517+
505518
func displayIPInfo() {
506519
print("IP Host : " + self.ipv4Address)
507520
print("Mask bits : \(self.maskBits)")
@@ -548,39 +561,39 @@ class IPSubnetCalc: NSObject {
548561

549562
ip4Hex = ipAddress.components(separatedBy: ":")
550563
if (ip4Hex == nil) {
551-
print("\(ipAddress) invalid")
564+
//print("\(ipAddress) invalid")
552565
return false
553566
}
554567
if (ip4Hex!.count != 8) {
555-
print("no 8 hex")
568+
//print("no 8 hex")
556569
if (ipAddress.contains("::"))
557570
{
558571
if (ipAddress.components(separatedBy: "::").count > 2) {
559-
print("too many '::'")
572+
//print("too many '::'")
560573
return false
561574
}
562575
}
563576
else {
564-
print("IPv6 \(ipAddress) bad format")
577+
//print("IPv6 \(ipAddress) bad format")
565578
return false
566579
}
567580
}
568581
for index in 0...(ip4Hex!.count - 1) {
569582
//print("Index : \(index) IPHex : \(ip4Hex[index]) Dec : \(String(UInt16(ip4Hex[index], radix: 16)!, radix: 16))")
570583
if (ip4Hex![index].count > 4 && ip4Hex![index].count != 0) {
571-
print("\(ip4Hex![index]) too large")
584+
//print("\(ip4Hex![index]) too large")
572585
return false
573586
}
574587
hex = UInt16(ip4Hex![index], radix: 16)
575588
if hex != nil {
576589
if (hex! < 0 || hex! > 0xFFFF) {
577-
print("\(hex!) is invalid")
590+
//print("\(hex!) is invalid")
578591
return false
579592
}
580593
}
581594
else {
582595
if (ip4Hex![index] != "") {
583-
print("\(ip4Hex![index]) not an integer")
596+
//print("\(ip4Hex![index]) not an integer")
584597
return false
585598
}
586599
}

README.md

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

4-
What's New in version 2.0:
5-
- IPv6 support!
6-
- Address Class D (Multicast) and Class E (Reserved) support
7-
- 31 and 32 mask bits support
8-
- New Tab presentation
9-
- Recoded in Swift
10-
- Add alerts for bad IP or mask format
11-
- Fix bugs
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
129

1310

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

SubnetCalc-Info.plist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.0</string>
18+
<string>2.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>JMUL</string>
2121
<key>CFBundleVersion</key>
22-
<string>4</string>
22+
<string>$(CURRENT_PROJECT_VERSION)</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.utilities</string>
2525
<key>LSMinimumSystemVersion</key>
2626
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
2727
<key>NSHumanReadableCopyright</key>
28-
<string>Copyright 2020 Julien Mulot</string>
28+
<string>Copyright 2021 Julien Mulot</string>
2929
<key>NSMainNibFile</key>
3030
<string>MainMenu</string>
3131
<key>NSPrincipalClass</key>

SubnetCalc.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
8D1107310486CEB800E47090 /* SubnetCalc-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "SubnetCalc-Info.plist"; sourceTree = "<group>"; };
3737
8D1107320486CEB800E47090 /* SubnetCalc.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SubnetCalc.app; sourceTree = BUILT_PRODUCTS_DIR; };
3838
945E62EF25658A9500CDC9C7 /* SubnetCalc.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = SubnetCalc.xctestplan; sourceTree = "<group>"; };
39-
945E62F525658DBF00CDC9C7 /* SubnetCalcUITests-Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SubnetCalcUITests-Runner.app"; sourceTree = BUILT_PRODUCTS_DIR; };
39+
945E62F525658DBF00CDC9C7 /* SubnetCalcUITests-Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = "SubnetCalcUITests-Runner.app"; path = SubnetCalcUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4040
945E62F925658DBF00CDC9C7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4141
9482A32625765B30008D2C56 /* SubnetCalcUITest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubnetCalcUITest.swift; sourceTree = "<group>"; };
4242
949420B712D3C62A00E2F57D /* License.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = License.txt; sourceTree = "<group>"; };
@@ -401,6 +401,7 @@
401401
CODE_SIGN_IDENTITY = "Mac Developer";
402402
COMBINE_HIDPI_IMAGES = YES;
403403
COPY_PHASE_STRIP = NO;
404+
CURRENT_PROJECT_VERSION = 7;
404405
DEVELOPMENT_TEAM = VNLK894MAE;
405406
ENABLE_HARDENED_RUNTIME = YES;
406407
GCC_DYNAMIC_NO_PIC = NO;
@@ -428,6 +429,7 @@
428429
CODE_SIGN_ENTITLEMENTS = SubnetCalc.entitlements;
429430
CODE_SIGN_IDENTITY = "Mac Developer";
430431
COMBINE_HIDPI_IMAGES = YES;
432+
CURRENT_PROJECT_VERSION = 7;
431433
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
432434
DEVELOPMENT_TEAM = VNLK894MAE;
433435
ENABLE_HARDENED_RUNTIME = YES;

0 commit comments

Comments
 (0)