Skip to content

Commit 985f269

Browse files
Added extra SNMP port validation.
1 parent 99fa179 commit 985f269

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

Source/Applications/SIMProx/SIMProx/SnmpHost.cs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ public class SnmpHost : FacileActionAdapterBase
141141
/// <summary>
142142
/// Gets or sets the number of frames per second.
143143
/// </summary>
144-
[ConnectionStringParameter]
145-
[Description("Defines the number of frames per second expected by the adapter.")]
146-
[DefaultValue(DefaultFramesPerSecond)]
147144
[EditorBrowsable(EditorBrowsableState.Never)]
148145
public new int FramesPerSecond // Redeclared to provide a default value since property is not commonly used
149146
{
@@ -154,15 +151,6 @@ public class SnmpHost : FacileActionAdapterBase
154151
/// <summary>
155152
/// Gets or sets the allowed past time deviation tolerance, in seconds (can be sub-second).
156153
/// </summary>
157-
/// <remarks>
158-
/// <para>Defines the time sensitivity to past measurement timestamps.</para>
159-
/// <para>The number of seconds allowed before assuming a measurement timestamp is too old.</para>
160-
/// <para>This becomes the amount of delay introduced by the concentrator to allow time for data to flow into the system.</para>
161-
/// </remarks>
162-
/// <exception cref="ArgumentOutOfRangeException">LagTime must be greater than zero, but it can be less than one.</exception>
163-
[ConnectionStringParameter]
164-
[Description("Defines the allowed past time deviation tolerance, in seconds (can be sub-second).")]
165-
[DefaultValue(DefaultLagTime)]
166154
[EditorBrowsable(EditorBrowsableState.Never)]
167155
public new double LagTime // Redeclared to provide a default value since property is not commonly used
168156
{
@@ -173,15 +161,6 @@ public class SnmpHost : FacileActionAdapterBase
173161
/// <summary>
174162
/// Gets or sets the allowed future time deviation tolerance, in seconds (can be sub-second).
175163
/// </summary>
176-
/// <remarks>
177-
/// <para>Defines the time sensitivity to future measurement timestamps.</para>
178-
/// <para>The number of seconds allowed before assuming a measurement timestamp is too advanced.</para>
179-
/// <para>This becomes the tolerated +/- accuracy of the local clock to real-time.</para>
180-
/// </remarks>
181-
/// <exception cref="ArgumentOutOfRangeException">LeadTime must be greater than zero, but it can be less than one.</exception>
182-
[ConnectionStringParameter]
183-
[Description("Defines the allowed future time deviation tolerance, in seconds (can be sub-second).")]
184-
[DefaultValue(DefaultLeadTime)]
185164
[EditorBrowsable(EditorBrowsableState.Never)]
186165
public new double LeadTime // Redeclared to provide a default value since property is not commonly used
187166
{
@@ -205,7 +184,7 @@ public override IMeasurement[] OutputMeasurements // Redeclared to hide property
205184
[ConnectionStringParameter]
206185
[Description("Defines the SNMP port the proxy host will listen on.")]
207186
[DefaultValue(DefaultSnmpPort)]
208-
public ushort SnmpPort { get; set; } = DefaultSnmpPort;
187+
public int SnmpPort { get; set; } = DefaultSnmpPort;
209188

210189
/// <summary>
211190
/// Gets or sets flag that determines if SNMP forwarding agent is enabled.
@@ -401,6 +380,9 @@ public override void Initialize()
401380
new MD5AuthenticationProvider(new OctetString(ForwardAuthPhrase)));
402381
}
403382

383+
if (SnmpPort < 1 || SnmpPort > ushort.MaxValue)
384+
throw new InvalidOperationException($"Configured SNMP proxy host port \"{SnmpPort}\" port is invalid. Valid possible range is from 1 to {ushort.MaxValue}");
385+
404386
// Setup SNMP host engine
405387
UserRegistry users = new UserRegistry();
406388

0 commit comments

Comments
 (0)