30.08.2022

This commit is contained in:
marcusferl@weifer.de 2022-08-30 12:36:33 +02:00
parent 2cbeb0e212
commit ccf0890453

View File

@ -6,10 +6,80 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./output.component.scss'] styleUrls: ['./output.component.scss']
}) })
export class OutputComponent implements OnInit { 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 { ngOnInit(): void {
} }
} }
class Berechnung {
binArr = new Array<string>;
decArr = new Array<string>;
// 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;
}
}