Juniper / netconf-java

Java library for NETCONF
Other
76 stars 63 forks source link

Library does not cope with nc: namespace prefix #49

Closed GregDThomas closed 3 years ago

GregDThomas commented 3 years ago

When the rfc-compliant statement is configured on the device, the NETCONF server does not define a default namespace in its replies. Instead, the server includes a namespace declaration for the NETCONF namespace, which is bound to the nc prefix, and qualifies all NETCONF tags in its replies with the prefix.

(see https://www.juniper.net/documentation/us/en/software/junos/netconf/topics/concept/netconf-session-rfc-compliant.html)

The upshot of this is that the response of a hello packet may look something like:

<nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
  <nc:capabilities>
    <nc:capability>urn:ietf:params:netconf:base:1.0</nc:capability>
    ...
  </nc:capabilities>
  <nc:session-id>27703</nc:session-id>
</nc:hello>

The current library relies on searching responses for <session-id>, <ok>, <rpc_error>, etc. so fails to find these tags if the nc: namespace prefix is present.

The only work-around is to disable the rfc-compliant setting on the device, as described at the above link.

GregDThomas commented 3 years ago

Note; I am working on a fix (by using the namespace aware parsing capabilities of the W3C library already used by netconf-java) but as it's a background task it may take some time before I can submit a PR.

GregDThomas commented 3 years ago

Fixed by https://github.com/Juniper/netconf-java/pull/50 - <hello> https://github.com/Juniper/netconf-java/pull/51 - <rpc-reply> In the next release