Skip to content

Commit a5cb5ac

Browse files
authored
WirelessAPConfiguration.MaxConnections is now validated (#307)
1 parent 537d2a4 commit a5cb5ac

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

nanoFramework.System.Net/NetworkInformation/WirelessAPConfiguration.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ public WirelessAPConfiguration(uint id)
121121
/// <remarks>
122122
/// Checks the length of SSID is 32 or less.
123123
/// Password length is between 8 and 64 if not an open Authentication.
124+
/// Max connections has to be greater than zero.
124125
/// </remarks>
126+
/// <exception cref="ArgumentOutOfRangeException">If <see cref="MaxConnections"/> is less than one.</exception>
127+
/// <exception cref="ArgumentOutOfRangeException">If <see cref="Password"/> is less than 8 character or more than 64 characters and not open <see cref="Authentication"/>.</exception>
128+
/// <exception cref="ArgumentOutOfRangeException">If <see cref="Ssid"/> is longer than <see cref="MaxApSsidLength"/><./exception>
129+
/// <exception cref="ArgumentNullException">If <see cref="Ssid"/> is <see langword="null"/>.</exception>
125130
public void SaveConfiguration()
126131
{
127132
// Before we update validate whether settings conform to right characteristics.
@@ -130,6 +135,13 @@ public void SaveConfiguration()
130135
UpdateConfiguration();
131136
}
132137

138+
/// <summary>
139+
/// Validates the wireless Soft AP configuration information
140+
/// </summary>
141+
/// <exception cref="ArgumentOutOfRangeException">If <see cref="MaxConnections"/> is less than one.</exception>
142+
/// <exception cref="ArgumentOutOfRangeException">If <see cref="Password"/> is less than 8 character or more than 64 characters and not open <see cref="Authentication"/>.</exception>
143+
/// <exception cref="ArgumentOutOfRangeException">If <see cref="Ssid"/> is longer than <see cref="MaxApSsidLength"/><./exception>
144+
/// <exception cref="ArgumentNullException">If <see cref="Ssid"/> is <see langword="null"/>.</exception>
133145
private void ValidateConfiguration()
134146
{
135147
// SSID can't be null
@@ -148,6 +160,14 @@ private void ValidateConfiguration()
148160
#pragma warning restore S3928 // Parameter names used into ArgumentException constructors should match an existing one
149161
}
150162

163+
// At least one MaxConnection is required
164+
if (_apMaxConnections < 1)
165+
{
166+
#pragma warning disable S3928 // OK to not include a meaningful message
167+
throw new ArgumentOutOfRangeException();
168+
#pragma warning restore S3928 // Parameter names used into ArgumentException constructors should match an existing one
169+
}
170+
151171
// If not using an open Auth then check password length
152172
if ( (Authentication != AuthenticationType.Open && Authentication != AuthenticationType.None) &&
153173
( (_apPassword.Length < MinApPasswordLength) || (_apPassword.Length >= MaxApPasswordLength) ) )

0 commit comments

Comments
 (0)