Skip to content

Commit 6933e09

Browse files
schaveytJason LarkeTodd SchaveyRob-Hague
authored
Fix netconf framing protocol (#946)
* Updated NETCONF framing protocol detection to check both client & server capabilities This fixes an issue where the NetConfSession would expect the framing protocol to be used if ServerCapabilities contained 1.1, however the server would actually be using the legacy protocol as the client only advertises support for 1.0. * fix NETCONF to comply with RFC6242 for framing protocol * netcconf client - fix null ptr exception on dispose * netcconf client - provide example usage in xml doc * add comment --------- Co-authored-by: Jason Larke <[email protected]> Co-authored-by: Todd Schavey <[email protected]> Co-authored-by: Robert Hague <[email protected]> Co-authored-by: Rob Hague <[email protected]>
1 parent 0effbd7 commit 6933e09

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Renci.SshNet/NetConfClient.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ public XmlDocument ClientCapabilities
208208
/// <summary>
209209
/// Sends the receive RPC.
210210
/// </summary>
211+
/// <example>
212+
/// <code>
213+
/// var rpcXmlTemplate = "<rpc xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' message-id='1'>{0}</rpc>"'
214+
/// rpc.LoadXml(String.Format(rpcXmlTemplate, "<get-config><source><running/></source></get-config>"));
215+
/// var rpcResponse = client.SendReceiveRpc(rpc);
216+
/// </code>
217+
/// </example>
211218
/// <param name="rpc">The RPC.</param>
212219
/// <returns>
213220
/// Reply message to RPC request.
@@ -226,6 +233,12 @@ public XmlDocument SendReceiveRpc(XmlDocument rpc)
226233
/// <summary>
227234
/// Sends the receive RPC.
228235
/// </summary>
236+
/// <example>
237+
/// <code>
238+
/// var rpcXmlTemplate = "<rpc xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' message-id='1'>{0}</rpc>"'
239+
/// var rpcResponse = client.SendReceiveRpc(String.Format(rpcXmlTemplate, "<get-config><source><running/></source></get-config>"));
240+
/// </code>
241+
/// </example>
229242
/// <param name="xml">The XML.</param>
230243
/// <returns>
231244
/// Reply message to RPC request.

src/Renci.SshNet/Netconf/NetConfSession.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ protected override void OnDataReceived(byte[] data)
152152

153153
const string xpath = "/nc:hello/nc:capabilities/nc:capability[text()='urn:ietf:params:netconf:base:1.1']";
154154

155+
// Per RFC6242 section 4.1, If the :base:1.1 capability is advertised by both
156+
// peers, the chunked transfer mechanism is used for the remainder of the NETCONF
157+
// session. Otherwise, the old end-of-message based mechanism(see Section 4.3) is used.
158+
155159
// This will currently evaluate to false since we (the client) do not advertise 1.1 capability.
156160
// Despite some code existing for the 1.1 framing protocol, it is thought to be incorrect or
157161
// incomplete. The NETCONF code is practically untested at the time of writing.

0 commit comments

Comments
 (0)