mirror of
https://github.com/lissy93/networking-toolbox.git
synced 2026-12-01 09:22:25 +03:00
VLSM Calculator
This commit is contained in:
1 parent
fcc173eb07
commit
42f505862b
8 files changed
+1412
-19
No files matched your search
@@ -56,6 +56,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M112 272C112 289.7 126.3 304 144 304C161.7 304 176 289.7 176 272C176 254.3 161.7 240 144 240C126.3 240 112 254.3 112 272zM368 496C368 513.7 382.3 528 400 528C417.7 528 432 513.7 432 496C432 478.3 417.7 464 400 464C382.3 464 368 478.3 368 496zM432 144C432 161.7 446.3 176 464 176C481.7 176 496 161.7 496 144C496 126.3 481.7 112 464 112C446.3 112 432 126.3 432 144z"/><path d="M432 144C432 126.3 446.3 112 464 112C481.7 112 496 126.3 496 144C496 161.7 481.7 176 464 176C446.3 176 432 161.7 432 144zM402.1 194.6C408.9 202.9 417.3 209.8 426.8 214.8L390 416.6C378.5 418 367.8 421.9 358.3 427.7L217.3 304.2C221.6 294.3 224 283.5 224 272C224 270 223.9 267.9 223.8 265.9L402.1 194.6zM474 223.4C513.5 218.5 544 184.8 544 144C544 99.8 508.2 64 464 64C419.8 64 384 99.8 384 144C384 146 384.1 148.1 384.2 150.1L205.9 221.4C191.3 203.4 169 192 144 192C99.8 192 64 227.8 64 272C64 316.2 99.8 352 144 352C159.3 352 173.5 347.7 185.6 340.3L326.7 463.8C322.4 473.7 320 484.5 320 496C320 540.2 355.8 576 400 576C444.2 576 480 540.2 480 496C480 465.3 462.7 438.6 437.3 425.2L474 223.4zM368 496C368 478.3 382.3 464 400 464C417.7 464 432 478.3 432 496C432 513.7 417.7 528 400 528C382.3 528 368 513.7 368 496zM144 240C161.7 240 176 254.3 176 272C176 289.7 161.7 304 144 304C126.3 304 112 289.7 112 272C112 254.3 126.3 240 144 240z"/></svg>
|
||||
{:else if name === 'subnet-calculator'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M176 240L176 512C176 520.8 183.2 528 192 528L448 528C456.8 528 464 520.8 464 512L464 240L176 240zM256 296C256 309.3 245.3 320 232 320C218.7 320 208 309.3 208 296C208 282.7 218.7 272 232 272C245.3 272 256 282.7 256 296zM256 384C256 397.3 245.3 408 232 408C218.7 408 208 397.3 208 384C208 370.7 218.7 360 232 360C245.3 360 256 370.7 256 384zM208 472C208 458.7 218.7 448 232 448L320 448C333.3 448 344 458.7 344 472C344 485.3 333.3 496 320 496L232 496C218.7 496 208 485.3 208 472zM344 296C344 309.3 333.3 320 320 320C306.7 320 296 309.3 296 296C296 282.7 306.7 272 320 272C333.3 272 344 282.7 344 296zM344 384C344 397.3 333.3 408 320 408C306.7 408 296 397.3 296 384C296 370.7 306.7 360 320 360C333.3 360 344 370.7 344 384zM432 296C432 309.3 421.3 320 408 320C394.7 320 384 309.3 384 296C384 282.7 394.7 272 408 272C421.3 272 432 282.7 432 296zM432 384C432 397.3 421.3 408 408 408C394.7 408 384 397.3 384 384C384 370.7 394.7 360 408 360C421.3 360 432 370.7 432 384zM384 472C384 458.7 394.7 448 408 448C421.3 448 432 458.7 432 472C432 485.3 421.3 496 408 496C394.7 496 384 485.3 384 472z"/><path d="M464 240L464 512C464 520.8 456.8 528 448 528L192 528C183.2 528 176 520.8 176 512L176 240L464 240zM464 192L176 192L176 128C176 119.2 183.2 112 192 112L448 112C456.8 112 464 119.2 464 128L464 192zM512 192L512 128C512 92.7 483.3 64 448 64L192 64C156.7 64 128 92.7 128 128L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 192zM208 296C208 309.3 218.7 320 232 320C245.3 320 256 309.3 256 296C256 282.7 245.3 272 232 272C218.7 272 208 282.7 208 296zM232 360C218.7 360 208 370.7 208 384C208 397.3 218.7 408 232 408C245.3 408 256 397.3 256 384C256 370.7 245.3 360 232 360zM208 472C208 485.3 218.7 496 232 496L320 496C333.3 496 344 485.3 344 472C344 458.7 333.3 448 320 448L232 448C218.7 448 208 458.7 208 472zM320 272C306.7 272 296 282.7 296 296C296 309.3 306.7 320 320 320C333.3 320 344 309.3 344 296C344 282.7 333.3 272 320 272zM296 384C296 397.3 306.7 408 320 408C333.3 408 344 397.3 344 384C344 370.7 333.3 360 320 360C306.7 360 296 370.7 296 384zM408 272C394.7 272 384 282.7 384 296C384 309.3 394.7 320 408 320C421.3 320 432 309.3 432 296C432 282.7 421.3 272 408 272zM384 384C384 397.3 394.7 408 408 408C421.3 408 432 397.3 432 384C432 370.7 421.3 360 408 360C394.7 360 384 370.7 384 384zM408 448C394.7 448 384 458.7 384 472C384 485.3 394.7 496 408 496C421.3 496 432 485.3 432 472C432 458.7 421.3 448 408 448z"/></svg>
|
||||
{:else if name === 'vlsm-calculator'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M139.2 212C132.6 223.5 136.5 238.2 148 244.8C159.5 251.4 174.2 247.5 180.8 236C187.4 224.5 183.5 209.8 172 203.2C160.5 196.6 145.8 200.5 139.2 212zM139.2 428C145.8 439.5 160.5 443.4 172 436.8C183.5 430.2 187.4 415.5 180.8 404C174.2 392.5 159.5 388.6 148 395.2C136.5 401.8 132.6 416.5 139.2 428zM296 128C296 141.3 306.7 152 320 152C333.3 152 344 141.3 344 128C344 114.7 333.3 104 320 104C306.7 104 296 114.7 296 128zM296 320C296 333.3 306.7 344 320 344C333.3 344 344 333.3 344 320C344 306.7 333.3 296 320 296C306.7 296 296 306.7 296 320zM296 512C296 525.3 306.7 536 320 536C333.3 536 344 525.3 344 512C344 498.7 333.3 488 320 488C306.7 488 296 498.7 296 512zM459.2 236C465.8 247.5 480.5 251.4 492 244.8C503.5 238.2 507.4 223.5 500.8 212C494.2 200.5 479.5 196.6 468 203.2C456.5 209.8 452.6 224.5 459.2 236zM459.2 404C452.6 415.5 456.5 430.2 468 436.8C479.5 443.4 494.2 439.5 500.8 428C507.4 416.5 503.5 401.8 492 395.2C480.5 388.6 465.8 392.5 459.2 404z"/><path d="M320 152C333.3 152 344 141.3 344 128C344 114.7 333.3 104 320 104C306.7 104 296 114.7 296 128C296 141.3 306.7 152 320 152zM384 128C384 154.9 367.5 177.9 344 187.3L344 260.6C367.5 270.1 384 293.1 384 319.9C384 323.3 383.7 326.6 383.2 329.9L441.4 364.8C445.9 361.4 450.8 358.7 455.9 356.6L455.9 283.3C450.7 281.2 445.9 278.5 441.4 275.1L412 292.7C407.3 276.9 398.7 262.8 387.3 251.6L416.7 234C412.7 208.6 424.4 182.3 447.9 168.6C478.5 150.9 517.7 161.4 535.3 192C552.9 222.6 542.5 261.8 511.9 279.4C509.3 280.9 506.6 282.2 503.9 283.3L503.9 356.6C506.6 357.7 509.3 359 511.9 360.5C542.5 378.2 553 417.3 535.3 447.9C517.6 478.5 478.5 489 447.9 471.3C424.3 457.7 412.7 431.3 416.7 405.9L358.5 371C354.1 374.3 349.2 377.1 344 379.2L344 452.5C367.5 462 384 485 384 511.8C384 547.1 355.3 575.8 320 575.8C284.7 575.8 256 547.1 256 511.8C256 484.9 272.5 461.9 296 452.5L296 379.2C272.5 369.7 256 346.7 256 319.9C256 316.5 256.3 313.2 256.8 309.9L198.6 275C194.1 278.4 189.2 281.1 184 283.2L184 356.5C189.1 358.6 194 361.3 198.5 364.7L227.9 347.1C232.6 362.9 241.2 377 252.6 388.2L223.2 406C227.2 431.4 215.6 457.8 192 471.4C161.4 489.1 122.3 478.6 104.6 448C86.9 417.4 97.4 378.3 128 360.6C130.6 359.1 133.3 357.8 136 356.7L136 283.4C133.3 282.3 130.6 281 128 279.5C97.4 261.8 86.9 222.6 104.6 192C122.3 161.4 161.4 150.9 192 168.6C215.6 182.2 227.2 208.6 223.2 234L281.4 268.9C285.8 265.6 290.7 262.8 295.9 260.7L295.9 187.4C272.4 177.9 255.9 154.9 255.9 128.1C255.9 92.8 284.6 64.1 319.9 64.1C355.2 64.1 383.9 92.8 383.9 128.1zM320 344C333.3 344 344 333.3 344 320C344 306.7 333.3 296 320 296C306.7 296 296 306.7 296 320C296 333.3 306.7 344 320 344zM492 244.8C503.5 238.2 507.4 223.5 500.8 212C494.2 200.5 479.5 196.6 468 203.2C456.5 209.8 452.6 224.5 459.2 236C465.8 247.5 480.5 251.4 492 244.8zM180.8 236C187.4 224.5 183.5 209.8 172 203.2C160.5 196.6 145.8 200.5 139.2 212C132.6 223.5 136.5 238.2 148 244.8C159.5 251.4 174.2 247.5 180.8 236zM344 512C344 498.7 333.3 488 320 488C306.7 488 296 498.7 296 512C296 525.3 306.7 536 320 536C333.3 536 344 525.3 344 512zM139.2 428C145.8 439.5 160.5 443.4 172 436.8C183.5 430.2 187.4 415.5 180.8 404C174.2 392.5 159.5 388.6 148 395.2C136.5 401.8 132.6 416.5 139.2 428zM492 395.2C480.5 388.6 465.8 392.5 459.2 404C452.6 415.5 456.5 430.2 468 436.8C479.5 443.4 494.2 439.5 500.8 428C507.4 416.5 503.5 401.8 492 395.2z"/></svg>
|
||||
{:else if name === 'cidr-convertor'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M86.6 384L208 262.6L208 320C208 326.4 210.5 332.5 215 337C219.5 341.5 225.6 344 232 344L320 344L320 448C320 434.7 309.3 424 296 424L232 424C218.7 424 208 434.7 208 448L208 505.4L86.6 384zM320 192C320 205.3 330.7 216 344 216L408 216C421.3 216 432 205.3 432 192L432 134.6L553.4 256L432 377.4L432 320C432 313.6 429.5 307.5 425 303C420.5 298.5 414.4 296 408 296L320 296L320 192z"/><path d="M432 134.6L432 192C432 205.3 421.3 216 408 216L344 216C330.7 216 320 205.3 320 192C320 178.7 330.7 168 344 168L384 168L384 96C384 83.1 391.8 71.4 403.8 66.4L403.8 66.4C415.8 61.4 429.5 64.2 438.7 73.3L598.7 233.3C611.2 245.8 611.2 266.1 598.7 278.6L438.7 438.6C429.5 447.8 415.8 450.5 403.8 445.5C391.8 440.5 384 428.9 384 416L384 344L232 344C225.6 344 219.5 341.5 215 337C210.5 332.5 208 326.4 208 320L208 262.6L86.6 384L208 505.4L208 448C208 434.7 218.7 424 232 424L296 424C309.3 424 320 434.7 320 448C320 461.3 309.3 472 296 472L256 472L256 544C256 556.9 248.2 568.6 236.2 573.6L236.2 573.6C224.2 578.6 210.5 575.8 201.3 566.7L41.3 406.7C28.8 394.2 28.8 373.9 41.3 361.4L201.3 201.4C210.5 192.2 224.2 189.5 236.2 194.5C248.2 199.5 256 211.1 256 224L256 296L408 296C414.4 296 420.5 298.5 425 303C429.5 307.5 432 313.6 432 320L432 377.4L553.4 256L432 134.6zM404.7 404.7L404.7 404.7zM235.3 532.7L235.3 532.7C235.3 532.7 235.3 532.7 235.3 532.7zM75.3 372.7C75.3 372.7 75.3 372.7 75.3 372.7L75.3 372.7L75.3 372.7z"/></svg>
|
||||
{:else if name === 'network-classes'}
|
||||
@@ -64,6 +66,18 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M112 432L112 528L528 528L528 432L112 432z"/><path d="M344 64L344 192C344 205.3 333.3 216 320 216C306.7 216 296 205.3 296 192L296 64C296 50.7 306.7 40 320 40C333.3 40 344 50.7 344 64zM192 352C192 334.3 206.3 320 224 320L416 320C433.7 320 448 334.3 448 352L448 384L528 384C554.5 384 576 405.5 576 432L576 528C576 554.5 554.5 576 528 576L112 576C85.5 576 64 554.5 64 528L64 432C64 405.5 85.5 384 112 384L192 384L192 352zM528 528L528 432L112 432L112 528L528 528zM44 178.7C51.4 167.7 66.3 164.7 77.3 172L173.3 236C184.3 243.4 187.3 258.3 180 269.3C172.7 280.3 157.7 283.3 146.7 276L50.7 212C39.7 204.6 36.7 189.7 44 178.7zM562.7 172C573.7 164.6 588.6 167.6 596 178.7C603.4 189.8 600.4 204.6 589.3 212L493.3 276C482.3 283.4 467.4 280.4 460 269.3C452.6 258.2 455.6 243.4 466.7 236L562.7 172z"/></svg>
|
||||
{:else if name === 'common-subnets'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M112 144L208 144L208 240L112 240L112 144zM304 400L400 400L400 496L304 496L304 400zM432 144L528 144L528 240L432 240L432 144z"/><path d="M112 144L112 240L208 240L208 144L112 144zM64 144C64 117.5 85.5 96 112 96L208 96C234.5 96 256 117.5 256 144L256 168L384 168L384 144C384 117.5 405.5 96 432 96L528 96C554.5 96 576 117.5 576 144L576 240C576 266.5 554.5 288 528 288L432 288C405.5 288 384 266.5 384 240L384 216L256 216L256 240C256 250.4 252.7 260.1 247 268L310 352L400 352C426.5 352 448 373.5 448 400L448 496C448 522.5 426.5 544 400 544L304 544C277.5 544 256 522.5 256 496L256 400C256 389.6 259.3 379.9 265 372L202 288L112 288C85.5 288 64 266.5 64 240L64 144zM304 400L304 496L400 496L400 400L304 400zM528 144L432 144L432 240L528 240L528 144z"/></svg>
|
||||
{:else if name === 'plus'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d=""/><path d="M344 88C344 74.7 333.3 64 320 64C306.7 64 296 74.7 296 88L296 296L88 296C74.7 296 64 306.7 64 320C64 333.3 74.7 344 88 344L296 344L296 552C296 565.3 306.7 576 320 576C333.3 576 344 565.3 344 552L344 344L552 344C565.3 344 576 333.3 576 320C576 306.7 565.3 296 552 296L344 296L344 88z"/></svg>
|
||||
{:else if name === 'trash'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M172.9 208L195.5 513.2C196.1 521.6 203.1 528 211.5 528L428.6 528C437 528 443.9 521.5 444.6 513.2L467.1 208L172.9 208z"/><path d="M232.2 68.8C236.9 56.3 248.8 48 262.2 48L377.8 48C391.1 48 403.1 56.3 407.8 68.8L424 112L520 112C533.3 112 544 122.7 544 136C544 149.3 533.3 160 520 160L120 160C106.7 160 96 149.3 96 136C96 122.7 106.7 112 120 112L216 112L232.2 68.8zM147.6 516.8L124.7 208L172.9 208L195.5 513.2C196.1 521.6 203.1 528 211.5 528L428.6 528C437 528 443.9 521.5 444.6 513.2L467.2 208L515.3 208L492.4 516.7C489.9 550.1 462.1 576 428.6 576L211.5 576C178 576 150.2 550.1 147.7 516.7z"/></svg>
|
||||
{:else if name === 'chevron-up'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d=""/><path d="M303.5 167C312.9 157.6 328.1 157.6 337.4 167L537.4 367C546.8 376.4 546.8 391.6 537.4 400.9C528 410.2 512.8 410.3 503.5 400.9L320.5 217.9L137.5 400.9C128.1 410.3 112.9 410.3 103.6 400.9C94.3 391.5 94.2 376.3 103.6 367L303.6 167z"/></svg>
|
||||
{:else if name === 'chevron-down'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d=""/><path d="M303.5 473C312.9 482.4 328.1 482.4 337.4 473L537.4 273C546.8 263.6 546.8 248.4 537.4 239.1C528 229.8 512.8 229.7 503.5 239.1L320.5 422.1L137.5 239.1C128.1 229.7 112.9 229.7 103.6 239.1C94.3 248.5 94.2 263.7 103.6 273L303.6 473z"/></svg>
|
||||
{:else if name === 'copy'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M272 128L272 384C272 392.8 279.2 400 288 400L480 400C488.8 400 496 392.8 496 384L496 186.5C496 182.3 494.3 178.2 491.3 175.2L432.8 116.7C429.8 113.7 425.7 112 421.5 112L288 112C279.2 112 272 119.2 272 128z"/><path d="M480 400L288 400C279.2 400 272 392.8 272 384L272 128C272 119.2 279.2 112 288 112L421.5 112C425.7 112 429.8 113.7 432.8 116.7L491.3 175.2C494.3 178.2 496 182.3 496 186.5L496 384C496 392.8 488.8 400 480 400zM288 448L480 448C515.3 448 544 419.3 544 384L544 186.5C544 169.5 537.3 153.2 525.3 141.2L466.7 82.7C454.7 70.7 438.5 64 421.5 64L288 64C252.7 64 224 92.7 224 128L224 384C224 419.3 252.7 448 288 448zM160 192C124.7 192 96 220.7 96 256L96 512C96 547.3 124.7 576 160 576L352 576C387.3 576 416 547.3 416 512L416 496L368 496L368 512C368 520.8 360.8 528 352 528L160 528C151.2 528 144 520.8 144 512L144 256C144 247.2 151.2 240 160 240L176 240L176 192L160 192z"/></svg>
|
||||
{:else if name === 'tick'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d=""/><path d="M534 132.5C544.8 140.2 547.2 155.2 539.5 166L275.5 534C271.4 539.7 265 543.4 258 543.9C251 544.4 244 542 239 537L103 401C93.6 391.6 93.6 376.4 103 367.1C112.4 357.8 127.6 357.7 136.9 367.1L253 483L500.5 138C508.2 127.2 523.2 124.8 534 132.5z"/></svg>
|
||||
{:else if name === 'grid'}
|
||||
<svg fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M3 3h8v8H3V3zm10 0h8v8h-8V3zM3 13h8v8H3v-8zm10 0h8v8h-8v-8z"/>
|
||||
|
||||
@@ -0,0 +1,825 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
calculateVLSM,
|
||||
generateSubnetId,
|
||||
validateSubnetRequirement,
|
||||
type SubnetRequirement,
|
||||
type VLSMResult
|
||||
} from '$lib/utils/vlsm-calculations.js';
|
||||
import { validateIPv4 } from '$lib/utils/ip-validation.js';
|
||||
import IPInput from './IPInput.svelte';
|
||||
import Tooltip from './Tooltip.svelte';
|
||||
import Icon from './Icon.svelte';
|
||||
|
||||
let networkIP = $state('192.168.1.0');
|
||||
let cidr = $state(24);
|
||||
let subnets = $state<SubnetRequirement[]>([]);
|
||||
let vlsmResult = $state<VLSMResult | null>(null);
|
||||
let copiedStates = $state<Record<string, boolean>>({});
|
||||
let expandedSubnets = $state<Set<string>>(new Set());
|
||||
|
||||
// Add initial subnet requirement
|
||||
$effect(() => {
|
||||
if (subnets.length === 0) {
|
||||
addSubnet();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Add a new subnet requirement
|
||||
*/
|
||||
function addSubnet() {
|
||||
subnets.push({
|
||||
id: generateSubnetId(),
|
||||
name: `Subnet ${subnets.length + 1}`,
|
||||
hostsNeeded: 50,
|
||||
description: ''
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a subnet requirement
|
||||
*/
|
||||
function removeSubnet(id: string) {
|
||||
subnets = subnets.filter(subnet => subnet.id !== id);
|
||||
if (subnets.length === 0) {
|
||||
vlsmResult = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update subnet requirement
|
||||
*/
|
||||
function updateSubnet(id: string, field: keyof SubnetRequirement, value: any) {
|
||||
const index = subnets.findIndex(s => s.id === id);
|
||||
if (index !== -1) {
|
||||
subnets[index] = { ...subnets[index], [field]: value };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate VLSM subnets
|
||||
*/
|
||||
function calculateSubnets() {
|
||||
const ipValidation = validateIPv4(networkIP);
|
||||
if (!ipValidation.valid) {
|
||||
vlsmResult = {
|
||||
success: false,
|
||||
subnets: [],
|
||||
error: ipValidation.error,
|
||||
originalNetwork: networkIP,
|
||||
originalCIDR: cidr,
|
||||
totalHostsRequested: 0,
|
||||
totalHostsProvided: 0,
|
||||
totalWastedHosts: 0,
|
||||
remainingAddresses: 0
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate all subnet requirements
|
||||
for (const subnet of subnets) {
|
||||
const validation = validateSubnetRequirement(subnet);
|
||||
if (!validation.valid) {
|
||||
vlsmResult = {
|
||||
success: false,
|
||||
subnets: [],
|
||||
error: `${subnet.name}: ${validation.error}`,
|
||||
originalNetwork: networkIP,
|
||||
originalCIDR: cidr,
|
||||
totalHostsRequested: 0,
|
||||
totalHostsProvided: 0,
|
||||
totalWastedHosts: 0,
|
||||
remainingAddresses: 0
|
||||
};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vlsmResult = calculateVLSM(networkIP, cidr, subnets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle subnet details expansion
|
||||
*/
|
||||
function toggleSubnetExpansion(subnetId: string) {
|
||||
const newSet = new Set(expandedSubnets);
|
||||
if (newSet.has(subnetId)) {
|
||||
newSet.delete(subnetId);
|
||||
} else {
|
||||
newSet.add(subnetId);
|
||||
}
|
||||
expandedSubnets = newSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy text to clipboard
|
||||
*/
|
||||
async function copyToClipboard(text: string, id: string) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
copiedStates[id] = true;
|
||||
setTimeout(() => {
|
||||
copiedStates[id] = false;
|
||||
}, 3000);
|
||||
} catch (err) {
|
||||
console.error('Failed to copy text: ', err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get efficiency color based on waste percentage
|
||||
*/
|
||||
function getEfficiencyColor(wastedHosts: number, providedHosts: number): string {
|
||||
const wastePercentage = (wastedHosts / providedHosts) * 100;
|
||||
if (wastePercentage < 25) return 'var(--color-success)';
|
||||
if (wastePercentage < 50) return 'var(--color-warning)';
|
||||
return 'var(--color-danger)';
|
||||
}
|
||||
|
||||
// Reactive calculations
|
||||
$effect(() => {
|
||||
if (networkIP && cidr && subnets.length > 0) {
|
||||
calculateSubnets();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
<header class="card-header">
|
||||
<h2>VLSM Calculator</h2>
|
||||
<p>Design efficient subnets with Variable Length Subnet Masking for optimal address space utilization.</p>
|
||||
</header>
|
||||
|
||||
<!-- Network Configuration -->
|
||||
<div class="network-config">
|
||||
<h3>Network Configuration</h3>
|
||||
<div class="grid grid-2">
|
||||
<div class="form-group">
|
||||
<IPInput
|
||||
bind:value={networkIP}
|
||||
label="Network Address"
|
||||
placeholder="192.168.1.0"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="cidr-input">CIDR Notation</label>
|
||||
<div class="cidr-input">
|
||||
<span class="cidr-prefix">/{cidr}</span>
|
||||
<input
|
||||
id="cidr-input"
|
||||
type="range"
|
||||
min="8"
|
||||
max="30"
|
||||
bind:value={cidr}
|
||||
class="cidr-slider"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
min="8"
|
||||
max="30"
|
||||
bind:value={cidr}
|
||||
class="cidr-number"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Subnet Requirements -->
|
||||
<div class="subnet-requirements">
|
||||
<div class="requirements-header">
|
||||
<h3>Subnet Requirements</h3>
|
||||
<button type="button" class="btn btn-primary" onclick={addSubnet}>
|
||||
<Icon name="plus" size="sm" />
|
||||
Add Subnet
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="requirements-list">
|
||||
{#each subnets as subnet, index (subnet.id)}
|
||||
<div class="requirement-item">
|
||||
<div class="requirement-header">
|
||||
<span class="requirement-number">{index + 1}</span>
|
||||
<div class="requirement-inputs">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Subnet name"
|
||||
bind:value={subnet.name}
|
||||
oninput={(e) => updateSubnet(subnet.id, 'name', e.target?.value)}
|
||||
class="subnet-name-input"
|
||||
/>
|
||||
<div class="hosts-input">
|
||||
<label>Hosts needed:</label>
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="16777214"
|
||||
bind:value={subnet.hostsNeeded}
|
||||
oninput={(e) => updateSubnet(subnet.id, 'hostsNeeded', parseInt(e.target?.value || '1'))}
|
||||
class="hosts-number-input"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-danger-ghost"
|
||||
onclick={() => removeSubnet(subnet.id)}
|
||||
disabled={subnets.length === 1}
|
||||
>
|
||||
<Icon name="trash" size="sm" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="requirement-description">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Description (optional)"
|
||||
bind:value={subnet.description}
|
||||
oninput={(e) => updateSubnet(subnet.id, 'description', e.target?.value)}
|
||||
class="description-input"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Results -->
|
||||
{#if vlsmResult}
|
||||
<div class="results-section">
|
||||
{#if vlsmResult.success}
|
||||
<!-- Summary -->
|
||||
<div class="info-panel success">
|
||||
<h3>VLSM Calculation Results</h3>
|
||||
<div class="summary-stats">
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Total Subnets</span>
|
||||
<span class="stat-value">{vlsmResult.subnets.length}</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Hosts Requested</span>
|
||||
<span class="stat-value">{vlsmResult.totalHostsRequested.toLocaleString()}</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Hosts Provided</span>
|
||||
<span class="stat-value">{vlsmResult.totalHostsProvided.toLocaleString()}</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Wasted Hosts</span>
|
||||
<span class="stat-value danger">{vlsmResult.totalWastedHosts.toLocaleString()}</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Efficiency</span>
|
||||
<span class="stat-value" style="color: {getEfficiencyColor(vlsmResult.totalWastedHosts, vlsmResult.totalHostsProvided)}">
|
||||
{((1 - vlsmResult.totalWastedHosts / vlsmResult.totalHostsProvided) * 100).toFixed(1)}%
|
||||
</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">Remaining Addresses</span>
|
||||
<span class="stat-value">{vlsmResult.remainingAddresses.toLocaleString()}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Subnets Table -->
|
||||
<div class="subnets-table-container">
|
||||
<h3>Calculated Subnets</h3>
|
||||
<div class="subnets-table">
|
||||
<div class="table-header">
|
||||
<div class="col-name">Subnet</div>
|
||||
<div class="col-network">Network</div>
|
||||
<div class="col-hosts">Hosts</div>
|
||||
<div class="col-mask">Mask</div>
|
||||
<div class="col-efficiency">Efficiency</div>
|
||||
<div class="col-actions">Actions</div>
|
||||
</div>
|
||||
|
||||
{#each vlsmResult.subnets as subnet (subnet.id)}
|
||||
<div class="table-row">
|
||||
<div class="col-name">
|
||||
<div class="subnet-name">{subnet.name}</div>
|
||||
{#if subnet.description}
|
||||
<div class="subnet-description">{subnet.description}</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="col-network">
|
||||
<div class="network-info">
|
||||
<div class="network-address">{subnet.networkAddress}/{subnet.cidr}</div>
|
||||
<div class="address-range">
|
||||
{subnet.firstUsableHost} - {subnet.lastUsableHost}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-hosts">
|
||||
<div class="hosts-info">
|
||||
<div class="hosts-needed">{subnet.hostsNeeded} needed</div>
|
||||
<div class="hosts-provided">{subnet.hostsProvided} provided</div>
|
||||
{#if subnet.wastedHosts > 0}
|
||||
<div class="hosts-wasted">{subnet.wastedHosts} wasted</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-mask">
|
||||
<div class="mask-info">
|
||||
<div class="subnet-mask">{subnet.subnetMask}</div>
|
||||
<div class="wildcard-mask">{subnet.wildcardMask}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-efficiency">
|
||||
<div
|
||||
class="efficiency-indicator"
|
||||
style="color: {getEfficiencyColor(subnet.wastedHosts, subnet.hostsProvided)}"
|
||||
>
|
||||
{((1 - subnet.wastedHosts / subnet.hostsProvided) * 100).toFixed(1)}%
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-ghost"
|
||||
onclick={() => toggleSubnetExpansion(subnet.id)}
|
||||
>
|
||||
<Icon name={expandedSubnets.has(subnet.id) ? 'chevron-up' : 'chevron-down'} size="sm" />
|
||||
</button>
|
||||
<Tooltip text="Copy network info" position="left">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-ghost"
|
||||
onclick={() => copyToClipboard(`${subnet.networkAddress}/${subnet.cidr}`, `copy-${subnet.id}`)}
|
||||
>
|
||||
<Icon name={copiedStates[`copy-${subnet.id}`] ? 'tick' : 'copy'} size="sm" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if expandedSubnets.has(subnet.id)}
|
||||
<div class="subnet-details">
|
||||
<div class="details-grid">
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">Network Address</span>
|
||||
<code class="detail-value">{subnet.networkAddress}</code>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">Broadcast Address</span>
|
||||
<code class="detail-value">{subnet.broadcastAddress}</code>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">First Usable Host</span>
|
||||
<code class="detail-value">{subnet.firstUsableHost}</code>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">Last Usable Host</span>
|
||||
<code class="detail-value">{subnet.lastUsableHost}</code>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">Subnet Mask</span>
|
||||
<code class="detail-value">{subnet.subnetMask}</code>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">Wildcard Mask</span>
|
||||
<code class="detail-value">{subnet.wildcardMask}</code>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">Binary Mask</span>
|
||||
<code class="detail-value binary-mask">{subnet.binaryMask}</code>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">Host Bits</span>
|
||||
<code class="detail-value">{subnet.actualHostBits} bits</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Next Available Network -->
|
||||
{#if vlsmResult.nextAvailableNetwork}
|
||||
<div class="info-panel info">
|
||||
<h4>Next Available Network</h4>
|
||||
<p>
|
||||
The next available network address for additional subnets:
|
||||
<code>{vlsmResult.nextAvailableNetwork}</code>
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{:else}
|
||||
<!-- Error -->
|
||||
<div class="info-panel error">
|
||||
<h3>Calculation Error</h3>
|
||||
<p class="error-message">{vlsmResult.error}</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
.btn {
|
||||
:global(.icon) {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
&.btn-ghost {
|
||||
height: fit-content;
|
||||
}
|
||||
}
|
||||
|
||||
.network-config {
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.cidr-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
|
||||
}
|
||||
|
||||
.cidr-prefix {
|
||||
font-family: var(--font-mono);
|
||||
font-weight: 600;
|
||||
color: var(--color-primary);
|
||||
font-size: var(--font-size-lg);
|
||||
}
|
||||
|
||||
.cidr-slider {
|
||||
flex: 1;
|
||||
margin: 0 var(--spacing-sm);
|
||||
height: 0.5rem;
|
||||
background-color: var(--bg-tertiary);
|
||||
border-radius: var(--radius-lg);
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
|
||||
&::-webkit-slider-thumb {
|
||||
appearance: none;
|
||||
height: 1.25rem;
|
||||
width: 1.25rem;
|
||||
border-radius: 50%;
|
||||
background: var(--color-primary);
|
||||
cursor: pointer;
|
||||
box-shadow: var(--shadow-md);
|
||||
transition: transform var(--transition-fast);
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
&::-moz-range-thumb {
|
||||
height: 1.25rem;
|
||||
width: 1.25rem;
|
||||
border-radius: 50%;
|
||||
background: var(--color-primary);
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
box-shadow: var(--shadow-md);
|
||||
transition: transform var(--transition-fast);
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cidr-number {
|
||||
width: 4rem;
|
||||
text-align: center;
|
||||
|
||||
/* Hide number input arrows */
|
||||
&::-webkit-outer-spin-button,
|
||||
&::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&[type=number] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
}
|
||||
|
||||
.subnet-requirements {
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.requirements-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
|
||||
.requirements-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.requirement-item {
|
||||
padding: var(--spacing-md);
|
||||
background-color: var(--bg-tertiary);
|
||||
border-radius: var(--radius-lg);
|
||||
border: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.requirement-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.requirement-number {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
background-color: var(--color-primary);
|
||||
color: var(--bg-primary);
|
||||
border-radius: 50%;
|
||||
font-weight: 600;
|
||||
font-size: var(--font-size-sm);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.requirement-inputs {
|
||||
display: flex;
|
||||
gap: var(--spacing-md);
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.subnet-name-input {
|
||||
flex: 1;
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.hosts-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.hosts-input label {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.hosts-number-input {
|
||||
width: 6rem;
|
||||
|
||||
/* Hide number input arrows */
|
||||
&::-webkit-outer-spin-button,
|
||||
&::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&[type=number] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
}
|
||||
|
||||
.requirement-description {
|
||||
margin-top: var(--spacing-sm);
|
||||
margin-left: 3rem;
|
||||
}
|
||||
|
||||
.description-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.results-section {
|
||||
margin-top: var(--spacing-xl);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.summary-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
margin-top: var(--spacing-md);
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.stat-value.danger {
|
||||
color: var(--color-danger);
|
||||
}
|
||||
|
||||
.subnets-table-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.subnets-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: var(--bg-secondary);
|
||||
border-radius: var(--radius-lg);
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.table-header {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr 100px 80px;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-md);
|
||||
background-color: var(--bg-tertiary);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
font-weight: 600;
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.table-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr 100px 80px;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-md);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.table-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.subnet-name {
|
||||
font-weight: 600;
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.subnet-description {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
margin-top: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.network-address {
|
||||
font-family: var(--font-mono);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.address-range {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
margin-top: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.hosts-needed {
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.hosts-provided {
|
||||
color: var(--color-success);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.hosts-wasted {
|
||||
color: var(--color-danger);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.subnet-mask {
|
||||
font-family: var(--font-mono);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.wildcard-mask {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
margin-top: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.efficiency-indicator {
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.col-actions {
|
||||
display: flex;
|
||||
gap: var(--spacing-xs);
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.subnet-details {
|
||||
grid-column: 1 / -1;
|
||||
padding: var(--spacing-md);
|
||||
background-color: var(--bg-tertiary);
|
||||
border-top: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.details-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(228px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
font-family: var(--font-mono);
|
||||
background-color: var(--bg-primary);
|
||||
padding: var(--spacing-xs) var(--spacing-sm);
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.binary-mask {
|
||||
font-size: var(--font-size-xs);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: var(--color-danger);
|
||||
font-weight: 500;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.requirement-inputs {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.hosts-input {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.table-header,
|
||||
.table-row {
|
||||
grid-template-columns: 1fr;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.table-header > div,
|
||||
.table-row > div {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.table-header > div::before,
|
||||
.table-row > div::before {
|
||||
content: attr(data-label);
|
||||
font-weight: 600;
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.col-actions {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.summary-stats {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -11,17 +11,10 @@ export type NavGroup = {
|
||||
};
|
||||
|
||||
// Individual standalone pages
|
||||
export const STANDALONE_PAGES: NavItem[] = [
|
||||
{
|
||||
href: '/subnet-calculator',
|
||||
label: 'Subnet Calculator',
|
||||
description: 'Calculate subnet information, network addresses, broadcast addresses, and host ranges with visual network analysis',
|
||||
icon: 'subnet-calculator'
|
||||
}
|
||||
];
|
||||
export const STANDALONE_PAGES: NavItem[] = [];
|
||||
|
||||
export const TOP_NAV: NavItem[] = [
|
||||
{ href: '/subnet-calculator', label: 'Subnet Calc' },
|
||||
{ href: '/subnetting', label: 'Subnetting' },
|
||||
{ href: '/cidr-convertor', label: 'CIDR Convert' },
|
||||
{ href: '/ip-address-convertor', label: 'IP Convert' },
|
||||
{ href: '/ip-reference', label: 'Reference' }
|
||||
@@ -29,6 +22,20 @@ export const TOP_NAV: NavItem[] = [
|
||||
|
||||
// Sections that have sub-pages (drives the conditional SubHeader)
|
||||
export const SUB_NAV: Record<string, NavItem[] | NavGroup[]> = {
|
||||
'/subnetting': [
|
||||
{
|
||||
href: '/subnetting/subnet-calculator',
|
||||
label: 'Subnet Calculator',
|
||||
description: 'Calculate subnet information, network addresses, broadcast addresses, and host ranges with visual network analysis',
|
||||
icon: 'subnet-calculator'
|
||||
},
|
||||
{
|
||||
href: '/subnetting/vlsm-calculator',
|
||||
label: 'VLSM Calculator',
|
||||
description: 'Variable Length Subnet Mask calculator to break networks into multiple smaller subnets with optimal allocation',
|
||||
icon: 'vlsm-calculator'
|
||||
}
|
||||
],
|
||||
'/cidr-convertor': [
|
||||
{
|
||||
href: '/cidr-convertor/cidr-to-subnet-mask',
|
||||
|
||||
@@ -0,0 +1,346 @@
|
||||
/**
|
||||
* VLSM (Variable Length Subnet Mask) Calculation Utilities
|
||||
*/
|
||||
|
||||
export interface SubnetRequirement {
|
||||
id: string;
|
||||
name: string;
|
||||
hostsNeeded: number;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface CalculatedSubnet {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
hostsNeeded: number;
|
||||
hostsProvided: number;
|
||||
subnetMask: string;
|
||||
cidr: number;
|
||||
networkAddress: string;
|
||||
broadcastAddress: string;
|
||||
firstUsableHost: string;
|
||||
lastUsableHost: string;
|
||||
wildcardMask: string;
|
||||
binaryMask: string;
|
||||
actualHostBits: number;
|
||||
wastedHosts: number;
|
||||
}
|
||||
|
||||
export interface VLSMResult {
|
||||
success: boolean;
|
||||
subnets: CalculatedSubnet[];
|
||||
error?: string;
|
||||
originalNetwork: string;
|
||||
originalCIDR: number;
|
||||
totalHostsRequested: number;
|
||||
totalHostsProvided: number;
|
||||
totalWastedHosts: number;
|
||||
remainingAddresses: number;
|
||||
nextAvailableNetwork?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert IP address to 32-bit integer
|
||||
*/
|
||||
function ipToInt(ip: string): number {
|
||||
const parts = ip.split('.').map(Number);
|
||||
return (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8) | parts[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert 32-bit integer to IP address
|
||||
*/
|
||||
function intToIp(int: number): string {
|
||||
return [
|
||||
(int >>> 24) & 0xFF,
|
||||
(int >>> 16) & 0xFF,
|
||||
(int >>> 8) & 0xFF,
|
||||
int & 0xFF
|
||||
].join('.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate subnet mask from CIDR
|
||||
*/
|
||||
function cidrToSubnetMask(cidr: number): string {
|
||||
const mask = 0xFFFFFFFF << (32 - cidr);
|
||||
return intToIp(mask >>> 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate wildcard mask from CIDR
|
||||
*/
|
||||
function cidrToWildcardMask(cidr: number): string {
|
||||
const wildcardInt = (1 << (32 - cidr)) - 1;
|
||||
return intToIp(wildcardInt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert subnet mask to binary representation
|
||||
*/
|
||||
function subnetMaskToBinary(mask: string): string {
|
||||
return mask.split('.').map(octet => {
|
||||
return parseInt(octet).toString(2).padStart(8, '0');
|
||||
}).join('.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the minimum number of host bits needed for a given number of hosts
|
||||
*/
|
||||
function calculateRequiredHostBits(hostsNeeded: number): number {
|
||||
// Need 2 extra addresses (network and broadcast)
|
||||
const totalAddresses = hostsNeeded + 2;
|
||||
return Math.ceil(Math.log2(totalAddresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the number of hosts that can be accommodated with given host bits
|
||||
*/
|
||||
function calculateHostsFromBits(hostBits: number): number {
|
||||
return Math.pow(2, hostBits) - 2; // Subtract network and broadcast addresses
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate IP address format
|
||||
*/
|
||||
function isValidIP(ip: string): boolean {
|
||||
const parts = ip.split('.');
|
||||
if (parts.length !== 4) return false;
|
||||
|
||||
return parts.every(part => {
|
||||
const num = parseInt(part);
|
||||
return !isNaN(num) && num >= 0 && num <= 255;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate CIDR notation
|
||||
*/
|
||||
function isValidCIDR(cidr: number): boolean {
|
||||
return cidr >= 1 && cidr <= 30; // /31 and /32 don't allow host addresses
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort subnet requirements by hosts needed (descending order for optimal allocation)
|
||||
*/
|
||||
function sortSubnetRequirements(requirements: SubnetRequirement[]): SubnetRequirement[] {
|
||||
return [...requirements].sort((a, b) => b.hostsNeeded - a.hostsNeeded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's enough address space in the network
|
||||
*/
|
||||
function validateAddressSpace(networkIP: string, cidr: number, requirements: SubnetRequirement[]): boolean {
|
||||
const totalAvailableHosts = calculateHostsFromBits(32 - cidr);
|
||||
const totalRequiredHosts = requirements.reduce((sum, req) => {
|
||||
const hostBits = calculateRequiredHostBits(req.hostsNeeded);
|
||||
return sum + Math.pow(2, hostBits);
|
||||
}, 0);
|
||||
|
||||
return totalRequiredHosts <= totalAvailableHosts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main VLSM calculation function
|
||||
*/
|
||||
export function calculateVLSM(
|
||||
networkIP: string,
|
||||
cidr: number,
|
||||
requirements: SubnetRequirement[]
|
||||
): VLSMResult {
|
||||
try {
|
||||
// Input validation
|
||||
if (!isValidIP(networkIP)) {
|
||||
return {
|
||||
success: false,
|
||||
subnets: [],
|
||||
error: 'Invalid IP address format',
|
||||
originalNetwork: networkIP,
|
||||
originalCIDR: cidr,
|
||||
totalHostsRequested: 0,
|
||||
totalHostsProvided: 0,
|
||||
totalWastedHosts: 0,
|
||||
remainingAddresses: 0
|
||||
};
|
||||
}
|
||||
|
||||
if (!isValidCIDR(cidr)) {
|
||||
return {
|
||||
success: false,
|
||||
subnets: [],
|
||||
error: 'CIDR must be between /1 and /30',
|
||||
originalNetwork: networkIP,
|
||||
originalCIDR: cidr,
|
||||
totalHostsRequested: 0,
|
||||
totalHostsProvided: 0,
|
||||
totalWastedHosts: 0,
|
||||
remainingAddresses: 0
|
||||
};
|
||||
}
|
||||
|
||||
if (requirements.length === 0) {
|
||||
return {
|
||||
success: false,
|
||||
subnets: [],
|
||||
error: 'No subnet requirements specified',
|
||||
originalNetwork: networkIP,
|
||||
originalCIDR: cidr,
|
||||
totalHostsRequested: 0,
|
||||
totalHostsProvided: 0,
|
||||
totalWastedHosts: 0,
|
||||
remainingAddresses: 0
|
||||
};
|
||||
}
|
||||
|
||||
// Validate unique subnet names
|
||||
const names = requirements.map(req => req.name);
|
||||
const uniqueNames = new Set(names);
|
||||
if (names.length !== uniqueNames.size) {
|
||||
return {
|
||||
success: false,
|
||||
subnets: [],
|
||||
error: 'Subnet names must be unique',
|
||||
originalNetwork: networkIP,
|
||||
originalCIDR: cidr,
|
||||
totalHostsRequested: 0,
|
||||
totalHostsProvided: 0,
|
||||
totalWastedHosts: 0,
|
||||
remainingAddresses: 0
|
||||
};
|
||||
}
|
||||
|
||||
// Check if there's enough address space
|
||||
if (!validateAddressSpace(networkIP, cidr, requirements)) {
|
||||
return {
|
||||
success: false,
|
||||
subnets: [],
|
||||
error: 'Not enough address space in the network for all requirements',
|
||||
originalNetwork: networkIP,
|
||||
originalCIDR: cidr,
|
||||
totalHostsRequested: requirements.reduce((sum, req) => sum + req.hostsNeeded, 0),
|
||||
totalHostsProvided: 0,
|
||||
totalWastedHosts: 0,
|
||||
remainingAddresses: calculateHostsFromBits(32 - cidr)
|
||||
};
|
||||
}
|
||||
|
||||
// Sort requirements by hosts needed (largest first)
|
||||
const sortedRequirements = sortSubnetRequirements(requirements);
|
||||
|
||||
// Calculate subnets
|
||||
const calculatedSubnets: CalculatedSubnet[] = [];
|
||||
let currentNetworkInt = ipToInt(networkIP);
|
||||
const originalNetworkMask = 0xFFFFFFFF << (32 - cidr);
|
||||
|
||||
// Ensure we start with the network address
|
||||
currentNetworkInt = currentNetworkInt & (originalNetworkMask >>> 0);
|
||||
|
||||
let totalHostsRequested = 0;
|
||||
let totalHostsProvided = 0;
|
||||
let totalWastedHosts = 0;
|
||||
|
||||
for (const requirement of sortedRequirements) {
|
||||
const hostBits = calculateRequiredHostBits(requirement.hostsNeeded);
|
||||
const subnetCIDR = 32 - hostBits;
|
||||
const hostsProvided = calculateHostsFromBits(hostBits);
|
||||
const subnetSize = Math.pow(2, hostBits);
|
||||
|
||||
// Calculate addresses
|
||||
const networkAddress = intToIp(currentNetworkInt);
|
||||
const broadcastInt = currentNetworkInt + subnetSize - 1;
|
||||
const broadcastAddress = intToIp(broadcastInt);
|
||||
const firstUsableHost = intToIp(currentNetworkInt + 1);
|
||||
const lastUsableHost = intToIp(broadcastInt - 1);
|
||||
|
||||
// Calculate masks
|
||||
const subnetMask = cidrToSubnetMask(subnetCIDR);
|
||||
const wildcardMask = cidrToWildcardMask(subnetCIDR);
|
||||
const binaryMask = subnetMaskToBinary(subnetMask);
|
||||
|
||||
const wastedHosts = hostsProvided - requirement.hostsNeeded;
|
||||
|
||||
calculatedSubnets.push({
|
||||
id: requirement.id,
|
||||
name: requirement.name,
|
||||
description: requirement.description,
|
||||
hostsNeeded: requirement.hostsNeeded,
|
||||
hostsProvided,
|
||||
subnetMask,
|
||||
cidr: subnetCIDR,
|
||||
networkAddress,
|
||||
broadcastAddress,
|
||||
firstUsableHost,
|
||||
lastUsableHost,
|
||||
wildcardMask,
|
||||
binaryMask,
|
||||
actualHostBits: hostBits,
|
||||
wastedHosts
|
||||
});
|
||||
|
||||
totalHostsRequested += requirement.hostsNeeded;
|
||||
totalHostsProvided += hostsProvided;
|
||||
totalWastedHosts += wastedHosts;
|
||||
|
||||
// Move to next available network address
|
||||
currentNetworkInt += subnetSize;
|
||||
}
|
||||
|
||||
// Calculate remaining address space
|
||||
const totalNetworkSize = Math.pow(2, 32 - cidr);
|
||||
const usedAddresses = currentNetworkInt - ipToInt(networkIP);
|
||||
const remainingAddresses = totalNetworkSize - usedAddresses;
|
||||
const nextAvailableNetwork = remainingAddresses > 0 ? intToIp(currentNetworkInt) : undefined;
|
||||
|
||||
return {
|
||||
success: true,
|
||||
subnets: calculatedSubnets,
|
||||
originalNetwork: networkIP,
|
||||
originalCIDR: cidr,
|
||||
totalHostsRequested,
|
||||
totalHostsProvided,
|
||||
totalWastedHosts,
|
||||
remainingAddresses,
|
||||
nextAvailableNetwork
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
subnets: [],
|
||||
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
||||
originalNetwork: networkIP,
|
||||
originalCIDR: cidr,
|
||||
totalHostsRequested: 0,
|
||||
totalHostsProvided: 0,
|
||||
totalWastedHosts: 0,
|
||||
remainingAddresses: 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a unique ID for subnet requirements
|
||||
*/
|
||||
export function generateSubnetId(): string {
|
||||
return 'subnet_' + Math.random().toString(36).substr(2, 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate subnet requirement
|
||||
*/
|
||||
export function validateSubnetRequirement(requirement: SubnetRequirement): { valid: boolean; error?: string } {
|
||||
if (!requirement.name.trim()) {
|
||||
return { valid: false, error: 'Subnet name is required' };
|
||||
}
|
||||
|
||||
if (requirement.hostsNeeded < 1) {
|
||||
return { valid: false, error: 'Number of hosts must be at least 1' };
|
||||
}
|
||||
|
||||
if (requirement.hostsNeeded > 16777214) { // Max hosts in a /8 network
|
||||
return { valid: false, error: 'Number of hosts too large (max: 16,777,214)' };
|
||||
}
|
||||
|
||||
return { valid: true };
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
<script lang="ts">
|
||||
import SubnetCalculator from '$lib/components/SubnetCalculator.svelte';
|
||||
import { site, pages } from '$lib/constants/site';
|
||||
import '../../styles/pages.scss';
|
||||
import { goto } from '$app/navigation';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
onMount(() => {
|
||||
goto('/subnetting/subnet-calculator', { replaceState: true });
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{pages.subnetCalculator.title}</title>
|
||||
<meta name="description" content="{pages.subnetCalculator.description}" />
|
||||
<meta name="keywords" content="{site.keywords}" />
|
||||
<meta property="og:title" content="{pages.subnetCalculator.title}" />
|
||||
<meta property="og:description" content="{pages.subnetCalculator.description}" />
|
||||
<meta property="og:url" content="{site.url}/subnet-calculator" />
|
||||
<title>Redirecting to Subnet Calculator...</title>
|
||||
<meta http-equiv="refresh" content="0; url=/subnetting/subnet-calculator" />
|
||||
</svelte:head>
|
||||
|
||||
<SubnetCalculator />
|
||||
<div>
|
||||
<p>Redirecting to the new subnet calculator location...</p>
|
||||
<p>If you are not redirected automatically, <a href="/subnetting/subnet-calculator">click here</a>.</p>
|
||||
</div>
|
||||
@@ -0,0 +1,167 @@
|
||||
<script lang="ts">
|
||||
import { site } from '$lib/constants/site';
|
||||
import { SUB_NAV } from '$lib/constants/nav';
|
||||
import Icon from '$lib/components/Icon.svelte';
|
||||
import '../../styles/pages.scss';
|
||||
|
||||
const subnettingTools = SUB_NAV['/subnetting'];
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Subnetting Tools - Subnet & VLSM Calculators | {site.name}</title>
|
||||
<meta name="description" content="Comprehensive subnetting tools including subnet calculator and VLSM calculator for network planning and IP address allocation." />
|
||||
<meta name="keywords" content="{site.keywords}, subnetting, subnet calculator, VLSM, variable length subnet mask, network planning" />
|
||||
<meta property="og:title" content="Subnetting Tools - Subnet & VLSM Calculators" />
|
||||
<meta property="og:description" content="Comprehensive subnetting tools including subnet calculator and VLSM calculator for network planning and IP address allocation." />
|
||||
<meta property="og:url" content="{site.url}/subnetting" />
|
||||
</svelte:head>
|
||||
|
||||
<div class="page-container">
|
||||
<header class="page-header">
|
||||
<h1>Subnetting Tools</h1>
|
||||
<p class="page-description">
|
||||
Comprehensive tools for subnet planning, network design, and IP address allocation.
|
||||
Calculate traditional subnets or use VLSM for optimal address space utilization.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<section class="explainer-card">
|
||||
<h2>About Subnetting</h2>
|
||||
<p>
|
||||
<strong>Subnetting</strong> is the practice of dividing a network into smaller, more manageable sub-networks (subnets).
|
||||
This technique helps improve network performance, security, and organization by creating logical boundaries within your IP address space.
|
||||
</p>
|
||||
|
||||
<h3>Key Benefits</h3>
|
||||
<ul>
|
||||
<li><strong>Improved Security:</strong> Isolate different network segments</li>
|
||||
<li><strong>Reduced Broadcast Traffic:</strong> Smaller broadcast domains</li>
|
||||
<li><strong>Better Organization:</strong> Logical grouping of devices</li>
|
||||
<li><strong>Efficient Address Usage:</strong> Optimal IP allocation with VLSM</li>
|
||||
</ul>
|
||||
|
||||
<h3>Traditional vs VLSM Subnetting</h3>
|
||||
<div class="comparison-grid">
|
||||
<div class="comparison-item">
|
||||
<h4>Traditional Subnetting</h4>
|
||||
<p>All subnets use the same subnet mask, creating equal-sized networks. Simple but may waste IP addresses.</p>
|
||||
</div>
|
||||
<div class="comparison-item">
|
||||
<h4>VLSM (Variable Length Subnet Mask)</h4>
|
||||
<p>Each subnet can have a different mask size, allowing optimal allocation based on actual host requirements.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="tools-grid">
|
||||
{#if Array.isArray(subnettingTools)}
|
||||
{#each subnettingTools as tool}
|
||||
<a href={tool.href} class="tool-card">
|
||||
<div class="tool-icon">
|
||||
{#if tool.icon}
|
||||
<Icon name={tool.icon} size="large" />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="tool-content">
|
||||
<h3>{tool.label}</h3>
|
||||
<p>{tool.description}</p>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.comparison-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
margin-top: var(--spacing-md);
|
||||
}
|
||||
|
||||
.comparison-item {
|
||||
padding: var(--spacing-md);
|
||||
background-color: var(--bg-secondary);
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.comparison-item h4 {
|
||||
color: var(--color-primary);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
font-size: var(--font-size-md);
|
||||
}
|
||||
|
||||
.comparison-item p {
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.tools-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: var(--spacing-lg);
|
||||
margin-top: var(--spacing-xl);
|
||||
}
|
||||
|
||||
.tool-card {
|
||||
display: flex;
|
||||
gap: var(--spacing-md);
|
||||
padding: var(--spacing-lg);
|
||||
background-color: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: all var(--transition-base);
|
||||
}
|
||||
|
||||
.tool-card:hover {
|
||||
border-color: var(--color-primary);
|
||||
background-color: var(--surface-hover);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.tool-icon {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background-color: var(--color-primary-alpha-10);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.tool-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.tool-content h3 {
|
||||
margin: 0 0 var(--spacing-xs) 0;
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.tool-content p {
|
||||
margin: 0;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.5;
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.tool-card {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tool-icon {
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script lang="ts">
|
||||
import SubnetCalculator from '$lib/components/SubnetCalculator.svelte';
|
||||
import { site, pages } from '$lib/constants/site';
|
||||
import '../../../styles/pages.scss';
|
||||
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{pages.subnetCalculator.title}</title>
|
||||
<meta name="description" content="{pages.subnetCalculator.description}" />
|
||||
<meta name="keywords" content="{site.keywords}" />
|
||||
<meta property="og:title" content="{pages.subnetCalculator.title}" />
|
||||
<meta property="og:description" content="{pages.subnetCalculator.description}" />
|
||||
<meta property="og:url" content="{site.url}/subnet-calculator" />
|
||||
</svelte:head>
|
||||
|
||||
<SubnetCalculator />
|
||||
@@ -0,0 +1,16 @@
|
||||
<script lang="ts">
|
||||
import VLSMCalculator from '$lib/components/VLSMCalculator.svelte';
|
||||
import { site, pages } from '$lib/constants/site';
|
||||
import '../../../styles/pages.scss';
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>VLSM Calculator - Variable Length Subnet Mask Tool | {site.name}</title>
|
||||
<meta name="description" content="Calculate VLSM subnets efficiently. Break down networks into multiple smaller subnets with optimal IP address allocation and minimal waste." />
|
||||
<meta name="keywords" content="{site.keywords}, VLSM, variable length subnet mask, subnet planning, network design" />
|
||||
<meta property="og:title" content="VLSM Calculator - Variable Length Subnet Mask Tool" />
|
||||
<meta property="og:description" content="Calculate VLSM subnets efficiently. Break down networks into multiple smaller subnets with optimal IP address allocation and minimal waste." />
|
||||
<meta property="og:url" content="{site.url}/subnetting/vlsm-calculator" />
|
||||
</svelte:head>
|
||||
|
||||
<VLSMCalculator />
|
||||
Reference in new issue
Block a user