This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
110 lines (107 loc) · 5.57 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//LIBRERIE STANDARD
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
//FILE HEADER AGGIUNTIVI (Funzioni)
#include "input_ip.h"
#include "output_ip.h"
#include "conversione_decimale_binario_ip.h"
#include "conversione_binario_decimale.h"
#include "controllo_tipo_ip.h"
#include "creatore_sottoreti_flsm_file.h"
#include "creatore_sottoreti_vlsm_file.h"
#include "controllo_stessa_subnet.h"
#include "supernetting_vlsm_file.h"
#include "clearscreen.h"
int main(){
int ip_bin[32];
int ip_dec[4];
int scelta;
int scelta_file;
int fine;
int tipo;
char banner[479] = {0x27, 0x23, 0x23, 0x23, 0x23, 0x3a, 0x27, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x3a, 0x3a, 0x27, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x3a, 0x3a, 0x27, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x3a, 0x3a, 0x3a, 0x27, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x3a, 0x3a, 0x27, 0x23, 0x23, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x0a, 0x2e, 0x20, 0x23, 0x23, 0x3a, 0x3a, 0x20, 0x23, 0x23, 0x2e, 0x2e, 0x2e, 0x2e, 0x20, 0x23, 0x23, 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 0x3a, 0x3a, 0x3a, 0x3a, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x3a, 0x3a, 0x3a, 0x3a, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x3a, 0x3a, 0x3a, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x3a, 0x3a}; //Banner
fine = 0;
puts(banner);
sleep(2);
printf("\n\tUn programma creato da Yuna Rossetti\n");
sleep(2);
clearscreen(); //Pulizia schermo
do{
printf("1) Inserisci un indirizzo ipv4 e calcolane la sua classe e il suo corrispettivo ip in binario\n2) Crea un numero di sottoreti a tua scelta con la FLSM\n3) Crea un numero di sottoreti a tua scelta con la VLSM\n4) Crea un numero di sottoreti a tua scelta con il supernetting\n5) Verifica se 2 indirizzi appartengono alla stessa subnet\n6) Fine\nFai la tua scelta: ");
scanf("%d", &scelta);
switch(scelta){
case 1:
input_ip(ip_dec);
printf("L'indirizzo inserito e' il seguente: ");
output_ip_dec(ip_dec);
printf("\n");
controllo_tipo_ip(ip_dec);
conversione_decimale_binario(ip_dec, ip_bin);
printf("\nL'indirizzo ip in binario e' il seguente: \n");
output_ip_bin(ip_bin);
break;
case 2:
input_ip(ip_dec);
tipo = controllo_tipo_ip_sottorete(ip_dec);
switch(tipo){
case 0:
creatore_sottoreti_a_file(ip_dec);
break;
case 1:
creatore_sottoreti_b_file(ip_dec);
break;
case 2:
creatore_sottoreti_c_file(ip_dec);
break;
}
break;
case 3:
input_ip(ip_dec);
tipo = controllo_tipo_ip_sottorete(ip_dec);
switch(tipo){
case 0:
creatore_sottoreti_a_variabile_file(ip_dec);
break;
case 1:
creatore_sottoreti_b_variabile_file(ip_dec);
break;
case 2:
creatore_sottoreti_c_variabile_file(ip_dec);
break;
}
break;
case 4:
input_ip(ip_dec);
tipo = controllo_tipo_ip_sottorete(ip_dec);
switch(tipo){
case 0:
creatore_sottoreti_supernetting_a_file(ip_dec);
break;
case 1:
creatore_sottoreti_supernetting_b_file(ip_dec);
break;
case 2:
creatore_sottoreti_supernetting_c_file(ip_dec);
break;
}
break;
case 5:
controllo_stessa_subnet();
break;
case 6:
printf("Fine\n");
fine = 1;
break;
default:
printf("Input non valido\n");
break;
}
getchar();
printf("Premi un tasto per continuare...\n");
getchar();
clearscreen(); //Pulizia schermo
}while(fine == 0);
return 0;
}