首页 > 解决方案 > 如何使用 libnetconf2 的 nc_recv_reply 获取回复数据

问题描述

我正在尝试使用 nc_recv_reply 获取配置。所以基本上我正在做的是:

struct nc_reply_data* reply = NULL;

std::cout << "======Calling nc_recv_reply======" << std::endl;
type = nc_recv_reply(session, rpc, msgid, 300, 0, (struct nc_reply**)&reply);
std::cout << "======Finished calling nc_recv_reply======" << std::endl;

if(reply && type == NC_MSG_REPLY)
  if(reply->type == NC_RPL_DATA)
  {
    if(reply->data)
      std::cout<< "======Got data======"<<std::endl;
    else
      std::cout<< "======Couldn't get data======"<<std::endl;
  }
  else
    std::cout<< "======Failure======"<<std::endl;

得到的是

======调用nc_recv_reply======

我应该收到的消息

======调用完nc_recv_reply======

======无法获取数据======

所以我的问题是如何获得我期待的 lyd_node*?

提前致谢 :)

标签: c++netconf

解决方案


推荐阅读