From ccf08904532ee3d798f49cb1446194cbd2d18004 Mon Sep 17 00:00:00 2001 From: "marcusferl@weifer.de" Date: Tue, 30 Aug 2022 12:36:33 +0200 Subject: [PATCH] 30.08.2022 --- src/app/output/output.component.ts | 72 +++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/app/output/output.component.ts b/src/app/output/output.component.ts index c04a1ec..78f98e7 100644 --- a/src/app/output/output.component.ts +++ b/src/app/output/output.component.ts @@ -6,10 +6,80 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./output.component.scss'] }) export class OutputComponent implements OnInit { + ipv4_dec = "192.168.0.1"; + ipv4_bin = "11000000.10101000.00000000.00000001"; + subnet_dec = ""; + subnet_bin = ""; + broadcast_dec = ""; + broadcast_bin = ""; + netID_de = ""; + netID_bin = ""; + firstIP_dec = ""; + firstIP_bin = ""; + lastIP_dec = ""; + lastIP_bin = ""; - constructor() { } + out = ["IPv4", "Subnetmask:", "Broadcast:", "Net-ID:", "First Ip:", "Last Ip:"] + constructor() { + + + var arr = this.ipv4_dec.split("."); + + arr.forEach(element => { + console.log(element) + }); + var bb = new Berechnung(); + bb.decToBin("192.168.0.1") + + + } ngOnInit(): void { + } } +class Berechnung { + + binArr = new Array; + decArr = new Array; + + // Convert dec Numbers to Binary + decToBin(number: string) { + this.decArr = number.split(".") + this.decArr.forEach(element => { + let tmp = (Number(element)).toString(2) + if (tmp.length < 8) { + let slicer = (8 - tmp.length); + tmp = "0".repeat(slicer) + tmp + console.log(element) + } + this.binArr.push(tmp); + }); + return this.binArr.join(".") + } + + subNetMask(prefix: number) { + let mask = "" + return mask; + } + + broadCast(arr: any[]) { + + } + + netId(mask: string) { + let netId; + return netId; + } + + minIp() { + return null; + } + + max() { + return null; + } + +} +