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; + } + +} +