-
Notifications
You must be signed in to change notification settings - Fork 0
/
firewall.cs
162 lines (137 loc) · 5.13 KB
/
firewall.cs
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
using System;
using System.Net.Mail;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Project.Opp.Cys
{
public partial class firewall : Form
{
// crearing obj of form1 to access variable
Form1 obj3;
// firewall objf;
//Manager objm;
// Form1 objm1;
protected string fire_name;
protected string fire_ip;
protected string fire_modelno;
protected string fire_snmp;
protected string fire_vpnenable;
protected string fire_loggingenable;
protected string fire_community_string;
//store value of form1
protected string _ip2;
protected string _snmp2;
protected string _community2;
//storing value of form1
protected string _ip3;
protected string _snmp3;
protected string _community3;
protected string device_name3;
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void label10_Click(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
//initializing form1 object in constructor
public firewall(Form1 obj3e)
{
obj3 = obj3e;
InitializeComponent();
// this.objm = objm1;
}
private void label7_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
//storing value of text box and combo box in variable
fire_name = comboBox4.Text;
if (string.IsNullOrEmpty(fire_name))
{
MessageBox.Show("Select device name");
}
fire_ip = textBox1.Text;
if (string.IsNullOrEmpty(fire_ip))
{
MessageBox.Show("Enter ip of Firewall");
}
fire_modelno = textBox2.Text;
if (string.IsNullOrEmpty(fire_modelno))
{
MessageBox.Show("Enter firewall model");
}
fire_snmp = comboBox1.Text;
if (string.IsNullOrEmpty(fire_snmp))
{
MessageBox.Show("Select SNMP version");
}
fire_vpnenable = checkBox1.Text;
if (string.IsNullOrEmpty(fire_vpnenable))
{
MessageBox.Show("VPN is disable");
}
fire_loggingenable = checkBox2.Text;
if (string.IsNullOrEmpty(fire_loggingenable))
{
MessageBox.Show("loging is currently disable");
}
fire_community_string = textBox3.Text;
if (string.IsNullOrEmpty(fire_community_string))
{
MessageBox.Show("Enter community string");
}
if (!string.IsNullOrEmpty(fire_name) && !string.IsNullOrEmpty(fire_ip) && !string.IsNullOrEmpty(fire_modelno) && !string.IsNullOrEmpty(fire_snmp) && !string.IsNullOrEmpty(fire_vpnenable) && !string.IsNullOrEmpty(fire_loggingenable) && !string.IsNullOrEmpty(fire_community_string))
{
//passing values to store (and show them in main menu form1 by press show button)
obj3.assign_firewall_value(fire_name, fire_ip, fire_modelno, fire_snmp, fire_vpnenable, fire_loggingenable, fire_community_string);
MessageBox.Show("Saved.");
}
}
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void firewall_Load(object sender, EventArgs e)
{
}
private async void button1_Click(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e)
{
_ip2 = obj3.get_manager_ip();
_snmp2 = obj3.get_manager_snmp();
_community2 = obj3.get_manager_community();
_ip3 = obj3.get_fr_ip();
_community3 = obj3.get_fr_community();
_snmp3 = obj3.get_fr_snmp();
device_name3 = obj3.get_manager_name();
MessageBox.Show(device_name3+"\n"+_ip2+" "+_ip3+"\n"+_snmp2+" "+_snmp3+"\n"+_community2+" "+_community3);
// Create an instance of the 'trap' form
if (device_name3 == "firewall")
{
if (_ip2 == _ip3 && _snmp2 == _snmp3 && _community2 == _community3)
{
trap obj = new trap();
obj.Show();
obj.StartPrinting();
}
else
{
MessageBox.Show("To send a trap device must be configured correctly");
}
}
else
{
MessageBox.Show("To send a trap device must be configured correctly");
}
}
}
}