@@ -10,6 +10,9 @@ import Cocoa
1010
1111@main
1212class SubnetCalcAppDelegate : NSObject , NSApplicationDelegate , NSWindowDelegate , NSTableViewDataSource {
13+ //*******************
14+ //Private Constants
15+ //*******************
1316 private enum Constants {
1417 static let defaultIP : String = " 10.0.0.0 "
1518 static let defaultIPv6Mask : String = " 64 "
@@ -95,6 +98,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
9598 //**********************
9699 //Private IPv4 functions
97100 //**********************
101+ /**
102+ Init IPv4 CIDR Tab combo lists
103+ */
98104 private func initCIDRTab( ) {
99105 for bits in ( 1 ... 32 ) {
100106 supernetMaskBitsCombo. addItem ( withObjectValue: String ( bits) )
@@ -114,6 +120,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
114120 }
115121 }
116122
123+ /**
124+ Init IPv4 Tab combo lists
125+ */
117126 private func initSubnetsTab( ) {
118127 for index in ( 0 ... 24 ) . reversed ( ) {
119128 if ( wildcard. state == NSControl . StateValue. on) {
@@ -140,19 +149,28 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
140149 classHexaMap. stringValue = " 01.00.00.00 "
141150 }
142151
152+ /**
153+ Init FLSM Tab
154+ */
143155 private func initFLSMTab( ) {
144156 for bits in ( 8 ... 32 ) {
145157 maskBitsFLSMCombo. addItem ( withObjectValue: String ( bits) )
146158 }
147159 slideFLSM. integerValue = 1
148160 }
149161
162+ /**
163+ Init VLSM Tab
164+ */
150165 private func initVLSMTab( ) {
151166 for bits in ( 8 ... 32 ) {
152167 maskBitsVLSMCombo. addItem ( withObjectValue: String ( bits) )
153168 }
154169 }
155170
171+ /**
172+ Init mask bits number of the Mask Bits slide on Subnets/Hosts Tab
173+ */
156174 private func bitsOnSlidePos( )
157175 {
158176 var coordLabel = bitsOnSlide. frame
@@ -162,6 +180,11 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
162180 bitsOnSlide. frame = coordLabel
163181 }
164182
183+ /**
184+ Select Address Class Type on IPv4 Tab
185+
186+ - Parameter c: Class type of the IPv4 address: A, B, C, D or E
187+ */
165188 private func initClassInfos( _ c: String )
166189 {
167190 if ( c == " A " )
@@ -186,6 +209,15 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
186209 }
187210 }
188211
212+ /**
213+ Split the given Address to its IP and mask
214+
215+ - Parameters address: IP Address with or without its mask as /XX notation
216+
217+ - Returns:
218+ First String: IP Address. Second String: mask bits number
219+
220+ */
189221 private func splitAddrMask( address: String ) -> ( String , String ? ) {
190222 let ipInfo = address. split ( separator: " / " )
191223 if ipInfo. count == 2 {
@@ -198,6 +230,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
198230 return ( address, nil )
199231 }
200232
233+ /**
234+ Generate the Binary Map, Bits Maps and Hexa Map of the current IP
235+ */
201236 private func doAddressMap( ) {
202237 if ( ipsc != nil ) {
203238 self . initClassInfos ( ipsc!. netClass ( ) )
@@ -214,6 +249,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
214249 }
215250 }
216251
252+ /**
253+ Generate infos of the IPv4 Tab for the current IP and mask
254+ */
217255 private func doSubnet( )
218256 {
219257 if ( ipsc != nil ) {
@@ -233,6 +271,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
233271 }
234272 }
235273
274+ /**
275+ Generate infos of the Subnets/Hosts Tab for the current IP and mask
276+ */
236277 private func doSubnetHost( )
237278 {
238279 if ( ipsc != nil ) {
@@ -243,6 +284,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
243284 }
244285 }
245286
287+ /**
288+ Generate infos of the FLSM Tab for the current IP and mask
289+ */
246290 private func doFLSM( )
247291 {
248292 if ( ipsc != nil ) {
@@ -263,6 +307,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
263307 }
264308 }
265309
310+ /**
311+ Generate infos of the VLSM Tab for the current IP and mask if there are some Hosts requirements
312+ */
266313 private func doVLSM( )
267314 {
268315 if ( ipsc != nil ) {
@@ -296,6 +343,12 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
296343 }
297344 }
298345
346+ /**
347+ Generate infos of the CIDR Tab
348+
349+ - Parameter maskbits: mask bits number
350+
351+ */
299352 private func doCIDR( maskbits: Int ? = nil )
300353 {
301354 if ( ipsc != nil ) {
@@ -323,6 +376,14 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
323376 }
324377 }
325378
379+ /**
380+ Display an alert window pop-up with customs message and info
381+
382+ - Parameters:
383+ - message: Main displayed message
384+ - info: message info
385+
386+ */
326387 private func myAlert( message: String , info: String )
327388 {
328389 let alert = NSAlert ( )
@@ -333,6 +394,13 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
333394 alert. runModal ( )
334395 }
335396
397+ /**
398+ Generate infos for all IPv4 tabs.
399+
400+ Check if there is are current IP address and mask otherwise take the default IP and mask.
401+
402+ Check if the IP address and mask are valid.
403+ */
336404 private func doIPSubnetCalc( )
337405 {
338406 var ipaddr : String
@@ -398,6 +466,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
398466 //**********************
399467 //Private IPv6 functions
400468 //**********************
469+ /**
470+ Init IPv6 Tab combo lists
471+ */
401472 private func initIPv6Tab( ) {
402473 var total = Decimal ( )
403474 var number : Decimal = 2
@@ -411,6 +482,9 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
411482 }
412483 }
413484
485+ /**
486+ Generate info for IPv6 tab
487+ */
414488 private func doIPv6( )
415489 {
416490 if ( ipsc != nil ) {
@@ -449,6 +523,13 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
449523 }
450524 }
451525
526+ /**
527+ Generate infos for IPv6 tab
528+
529+ Genrate infos also for all IPv4 tabs based on the converted IPv4 address
530+
531+ Check if the IPv6 address and mask are valid.
532+ */
452533 private func doIPv6SubnetCalc( )
453534 {
454535 var ipaddr : String
0 commit comments