Skip to content

Commit 2798ad3

Browse files
committed
add an overload for AuthenticateAsPanaClientAsync which accepts route-B credentials via the Action<IBufferWriter<byte>> instead of ReadOnlyMemory<byte>
1 parent d0fd0bb commit 2798ad3

File tree

2 files changed

+282
-19
lines changed

2 files changed

+282
-19
lines changed

src/Smdn.Net.SkStackIP/Smdn.Net.SkStackIP/SkStackClient.Functions.PANA.AuthenticateAsPaC.cs

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,31 @@ public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
2323
ReadOnlyMemory<byte> password,
2424
SkStackActiveScanOptions? scanOptions = null,
2525
CancellationToken cancellationToken = default
26+
)
27+
=> AuthenticateAsPanaClientAsync(
28+
writeRBID: CreateActionForWritingRBID(rbid, nameof(rbid)),
29+
writePassword: CreateActionForWritingPassword(password, nameof(password)),
30+
scanOptions: scanOptions,
31+
cancellationToken: cancellationToken
32+
);
33+
34+
/// <inheritdoc cref="AuthenticateAsPanaClientAsyncCore"/>
35+
/// <param name="writeRBID">A delegate to write Route-B ID used for PANA authentication to the <see cref="IBufferWriter{Byte}"/>.</param>
36+
/// <param name="writePassword">A delegate to write password ID used for PANA authentication to the <see cref="IBufferWriter{Byte}"/>.</param>
37+
/// <param name="scanOptions">Options such as scanning behavior when performing active scanning.</param>
38+
/// <param name="cancellationToken">The <see cref="CancellationToken" /> to monitor for cancellation requests.</param>
39+
public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
40+
Action<IBufferWriter<byte>> writeRBID,
41+
Action<IBufferWriter<byte>> writePassword,
42+
SkStackActiveScanOptions? scanOptions = null,
43+
CancellationToken cancellationToken = default
2644
)
2745
{
2846
ThrowIfPanaSessionAlreadyEstablished();
2947

3048
return AuthenticateAsPanaClientAsyncCore(
31-
writeRBID: CreateActionForWritingRBID(rbid, nameof(rbid)),
32-
writePassword: CreateActionForWritingPassword(password, nameof(password)),
49+
writeRBID: writeRBID ?? throw new ArgumentNullException(nameof(writeRBID)),
50+
writePassword: writePassword ?? throw new ArgumentNullException(nameof(writePassword)),
3351
getPaaAddressTask: default,
3452
channel: null,
3553
panId: null,
@@ -54,8 +72,8 @@ public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
5472
CancellationToken cancellationToken = default
5573
)
5674
=> AuthenticateAsPanaClientAsync(
57-
rbid: rbid,
58-
password: password,
75+
writeRBID: CreateActionForWritingRBID(rbid, nameof(rbid)),
76+
writePassword: CreateActionForWritingPassword(password, nameof(password)),
5977
paaAddress: paaAddress,
6078
channel: SkStackChannel.FindByChannelNumber(channelNumber, nameof(channelNumber)),
6179
panId: panId,
@@ -76,6 +94,30 @@ public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
7694
SkStackChannel channel,
7795
int panId,
7896
CancellationToken cancellationToken = default
97+
)
98+
=> AuthenticateAsPanaClientAsync(
99+
writeRBID: CreateActionForWritingRBID(rbid, nameof(rbid)),
100+
writePassword: CreateActionForWritingPassword(password, nameof(password)),
101+
paaAddress: paaAddress,
102+
channel: channel,
103+
panId: panId,
104+
cancellationToken: cancellationToken
105+
);
106+
107+
/// <inheritdoc cref="AuthenticateAsPanaClientAsyncCore"/>
108+
/// <param name="writeRBID">A delegate to write Route-B ID used for PANA authentication to the <see cref="IBufferWriter{Byte}"/>.</param>
109+
/// <param name="writePassword">A delegate to write password ID used for PANA authentication to the <see cref="IBufferWriter{Byte}"/>.</param>
110+
/// <param name="paaAddress">An <see cref="IPAddress"/> representing the IP address of the PANA Authentication Agent (PAA).</param>
111+
/// <param name="channel">A <see cref="SkStackChannel"/> representing the channel to be used for PANA session.</param>
112+
/// <param name="panId">A Personal Area Network (PAN) ID to be used for PANA session.</param>
113+
/// <param name="cancellationToken">The <see cref="CancellationToken" /> to monitor for cancellation requests.</param>
114+
public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
115+
Action<IBufferWriter<byte>> writeRBID,
116+
Action<IBufferWriter<byte>> writePassword,
117+
IPAddress paaAddress,
118+
SkStackChannel channel,
119+
int panId,
120+
CancellationToken cancellationToken = default
79121
)
80122
{
81123
ThrowIfPanaSessionAlreadyEstablished();
@@ -84,8 +126,8 @@ public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
84126
throw new ArgumentException(message: "invalid channel (empty channel)", paramName: nameof(channel));
85127

86128
return AuthenticateAsPanaClientAsyncCore(
87-
writeRBID: CreateActionForWritingRBID(rbid, nameof(rbid)),
88-
writePassword: CreateActionForWritingPassword(password, nameof(password)),
129+
writeRBID: writeRBID ?? throw new ArgumentNullException(nameof(writeRBID)),
130+
writePassword: writePassword ?? throw new ArgumentNullException(nameof(writePassword)),
89131
getPaaAddressTask: new(paaAddress ?? throw new ArgumentNullException(nameof(paaAddress))),
90132
channel: channel,
91133
panId: ValidatePanIdAndThrowIfInvalid(panId, nameof(panId)),
@@ -114,6 +156,26 @@ public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
114156
cancellationToken: cancellationToken
115157
);
116158

159+
/// <inheritdoc cref="AuthenticateAsPanaClientAsyncCore"/>
160+
/// <param name="writeRBID">A delegate to write Route-B ID used for PANA authentication to the <see cref="IBufferWriter{Byte}"/>.</param>
161+
/// <param name="writePassword">A delegate to write password ID used for PANA authentication to the <see cref="IBufferWriter{Byte}"/>.</param>
162+
/// <param name="pan">A <see cref="SkStackPanDescription"/> representing the address of the PANA Authentication Agent (PAA), PAN ID, and channel used for PANA session.</param>
163+
/// <param name="cancellationToken">The <see cref="CancellationToken" /> to monitor for cancellation requests.</param>
164+
public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
165+
Action<IBufferWriter<byte>> writeRBID,
166+
Action<IBufferWriter<byte>> writePassword,
167+
SkStackPanDescription pan,
168+
CancellationToken cancellationToken = default
169+
)
170+
=> AuthenticateAsPanaClientAsync(
171+
writeRBID: writeRBID,
172+
writePassword: writePassword,
173+
paaMacAddress: pan.MacAddress,
174+
channel: pan.Channel,
175+
panId: pan.Id,
176+
cancellationToken: cancellationToken
177+
);
178+
117179
/// <inheritdoc cref="AuthenticateAsPanaClientAsyncCore"/>
118180
/// <param name="rbid">A Route-B ID used for PANA authentication.</param>
119181
/// <param name="password">A password ID used for PANA authentication.</param>
@@ -130,8 +192,8 @@ public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
130192
CancellationToken cancellationToken = default
131193
)
132194
=> AuthenticateAsPanaClientAsync(
133-
rbid: rbid,
134-
password: password,
195+
writeRBID: CreateActionForWritingRBID(rbid, nameof(rbid)),
196+
writePassword: CreateActionForWritingPassword(password, nameof(password)),
135197
paaMacAddress: paaMacAddress,
136198
channel: SkStackChannel.FindByChannelNumber(channelNumber, nameof(channelNumber)),
137199
panId: panId,
@@ -152,13 +214,37 @@ public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
152214
SkStackChannel channel,
153215
int panId,
154216
CancellationToken cancellationToken = default
217+
)
218+
=> AuthenticateAsPanaClientAsync(
219+
writeRBID: CreateActionForWritingRBID(rbid, nameof(rbid)),
220+
writePassword: CreateActionForWritingPassword(password, nameof(password)),
221+
paaMacAddress: paaMacAddress,
222+
channel: channel,
223+
panId: panId,
224+
cancellationToken: cancellationToken
225+
);
226+
227+
/// <inheritdoc cref="AuthenticateAsPanaClientAsyncCore"/>
228+
/// <param name="writeRBID">A delegate to write Route-B ID used for PANA authentication to the <see cref="IBufferWriter{Byte}"/>.</param>
229+
/// <param name="writePassword">A delegate to write password ID used for PANA authentication to the <see cref="IBufferWriter{Byte}"/>.</param>
230+
/// <param name="paaMacAddress">A <see cref="PhysicalAddress"/> representing the MAC address of the PANA Authentication Agent (PAA).</param>
231+
/// <param name="channel">A <see cref="SkStackChannel"/> representing the channel to be used for PANA session.</param>
232+
/// <param name="panId">A Personal Area Network (PAN) ID to be used for PANA session.</param>
233+
/// <param name="cancellationToken">The <see cref="CancellationToken" /> to monitor for cancellation requests.</param>
234+
public ValueTask<SkStackPanaSessionInfo> AuthenticateAsPanaClientAsync(
235+
Action<IBufferWriter<byte>> writeRBID,
236+
Action<IBufferWriter<byte>> writePassword,
237+
PhysicalAddress paaMacAddress,
238+
SkStackChannel channel,
239+
int panId,
240+
CancellationToken cancellationToken = default
155241
)
156242
{
157243
ThrowIfPanaSessionAlreadyEstablished();
158244

159245
return AuthenticateAsPanaClientAsyncCore(
160-
writeRBID: CreateActionForWritingRBID(rbid, nameof(rbid)),
161-
writePassword: CreateActionForWritingPassword(password, nameof(password)),
246+
writeRBID: writeRBID ?? throw new ArgumentNullException(nameof(writeRBID)),
247+
writePassword: writePassword ?? throw new ArgumentNullException(nameof(writePassword)),
162248
#pragma warning disable CA2012, CS8620
163249
getPaaAddressTask: ConvertToIPv6LinkLocalAddressAsync(
164250
paaMacAddress ?? throw new ArgumentNullException(nameof(paaMacAddress)),

0 commit comments

Comments
 (0)