Skip to content

Fix netconf framing protocol #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 16, 2024
13 changes: 13 additions & 0 deletions src/Renci.SshNet/NetConfClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ public XmlDocument ClientCapabilities
/// <summary>
/// Sends the receive RPC.
/// </summary>
/// <example>
/// <code>
/// var rpcXmlTemplate = "<rpc xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' message-id='1'>{0}</rpc>"'
/// rpc.LoadXml(String.Format(rpcXmlTemplate, "<get-config><source><running/></source></get-config>"));
/// var rpcResponse = client.SendReceiveRpc(rpc);
/// </code>
/// </example>
/// <param name="rpc">The RPC.</param>
/// <returns>
/// Reply message to RPC request.
Expand All @@ -226,6 +233,12 @@ public XmlDocument SendReceiveRpc(XmlDocument rpc)
/// <summary>
/// Sends the receive RPC.
/// </summary>
/// <example>
/// <code>
/// var rpcXmlTemplate = "<rpc xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' message-id='1'>{0}</rpc>"'
/// var rpcResponse = client.SendReceiveRpc(String.Format(rpcXmlTemplate, "<get-config><source><running/></source></get-config>"));
/// </code>
/// </example>
/// <param name="xml">The XML.</param>
/// <returns>
/// Reply message to RPC request.
Expand Down
4 changes: 4 additions & 0 deletions src/Renci.SshNet/Netconf/NetConfSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ protected override void OnDataReceived(byte[] data)

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

// Per RFC6242 section 4.1, If the :base:1.1 capability is advertised by both
// peers, the chunked transfer mechanism is used for the remainder of the NETCONF
// session. Otherwise, the old end-of-message based mechanism(see Section 4.3) is used.

// This will currently evaluate to false since we (the client) do not advertise 1.1 capability.
// Despite some code existing for the 1.1 framing protocol, it is thought to be incorrect or
// incomplete. The NETCONF code is practically untested at the time of writing.
Expand Down