-
Notifications
You must be signed in to change notification settings - Fork 809
Expand file tree
/
Copy pathSNMP.cs
More file actions
68 lines (59 loc) · 2.18 KB
/
SNMP.cs
File metadata and controls
68 lines (59 loc) · 2.18 KB
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
using NETworkManager.Models.Network;
using NETworkManager.Settings;
namespace NETworkManager.Profiles.Application;
public static class SNMP
{
public static SNMPSessionInfo CreateSessionInfo()
{
return new SNMPSessionInfo
{
Mode = SettingsManager.Current.SNMP_Mode,
Version = SettingsManager.Current.SNMP_Version,
Security = SettingsManager.Current.SNMP_Security,
AuthenticationProvider = SettingsManager.Current.SNMP_AuthenticationProvider,
PrivacyProvider = SettingsManager.Current.SNMP_PrivacyProvider
};
}
public static SNMPSessionInfo CreateSessionInfo(ProfileInfo profile)
{
SNMPSessionInfo info = new();
// Get group info
var group = ProfileManager.GetGroupByName(profile.Group);
info.Host = profile.SNMP_Host;
// OID and Mode
if (profile.SNMP_OverrideOIDAndMode)
{
info.Mode = profile.SNMP_Mode;
info.OID = profile.SNMP_OID;
}
else if (group.SNMP_OverrideOIDAndMode)
{
info.Mode = group.SNMP_Mode;
info.OID = group.SNMP_OID;
}
// Version and Auth
if (profile.SNMP_OverrideVersionAndAuth)
{
info.Version = profile.SNMP_Version;
info.Community = profile.SNMP_Community;
info.Security = profile.SNMP_Security;
info.Username = profile.SNMP_Username;
info.AuthenticationProvider = profile.SNMP_AuthenticationProvider;
info.Auth = profile.SNMP_Auth;
info.PrivacyProvider = profile.SNMP_PrivacyProvider;
info.Priv = profile.SNMP_Priv;
}
else if (group.SNMP_OverrideVersionAndAuth)
{
info.Version = group.SNMP_Version;
info.Community = group.SNMP_Community;
info.Security = group.SNMP_Security;
info.Username = group.SNMP_Username;
info.AuthenticationProvider = group.SNMP_AuthenticationProvider;
info.Auth = group.SNMP_Auth;
info.PrivacyProvider = group.SNMP_PrivacyProvider;
info.Priv = group.SNMP_Priv;
}
return info;
}
}