@@ -310,6 +310,15 @@ struct clb_data_s {
310310 int has_get_schema ;
311311};
312312
313+ /**
314+ * @brief Retrieve YANG schema content from a local file.
315+ *
316+ * @param[in] name Schema name.
317+ * @param[in] rev Schema revision.
318+ * @param[in] clb_data get-schema callback data.
319+ * @param[out] format Schema format.
320+ * @return Schema content.
321+ */
313322static char *
314323retrieve_schema_data_localfile (const char * name , const char * rev , struct clb_data_s * clb_data ,
315324 LYS_INFORMAT * format )
@@ -362,6 +371,15 @@ retrieve_schema_data_localfile(const char *name, const char *rev, struct clb_dat
362371 return model_data ;
363372}
364373
374+ /**
375+ * @brief Retrieve YANG schema content from a reply to get-schema RPC.
376+ *
377+ * @param[in] name Schema name.
378+ * @param[in] rev Schema revision.
379+ * @param[in] clb_data get-schema callback data.
380+ * @param[out] format Schema format.
381+ * @return Schema content.
382+ */
365383static char *
366384retrieve_schema_data_getschema (const char * name , const char * rev , struct clb_data_s * clb_data ,
367385 LYS_INFORMAT * format )
@@ -458,6 +476,19 @@ free_with_user_data(void *data, void *user_data)
458476 (void )user_data ;
459477}
460478
479+ /**
480+ * @brief Retrieve YANG schema content.
481+ *
482+ * @param[in] mod_name Schema name.
483+ * @param[in] mod_rev Schema revision.
484+ * @param[in] submod_name Optional submodule name.
485+ * @param[in] sub_rev Submodule revision.
486+ * @param[in] user_data get-schema callback data.
487+ * @param[out] format Schema format.
488+ * @param[out] module_data Schema content.
489+ * @param[out] free_module_data Callback for freeing @p module_data.
490+ * @return LY_ERR value.
491+ */
461492static LY_ERR
462493retrieve_schema_data (const char * mod_name , const char * mod_rev , const char * submod_name , const char * sub_rev ,
463494 void * user_data , LYS_INFORMAT * format , const char * * module_data ,
@@ -557,6 +588,20 @@ retrieve_schema_data(const char *mod_name, const char *mod_rev, const char *subm
557588 return * module_data ? LY_SUCCESS : LY_ENOTFOUND ;
558589}
559590
591+ /**
592+ * @brief Load a YANG schema into context.
593+ *
594+ * @param[in] session NC session.
595+ * @param[in] name Schema name.
596+ * @param[in] revision Schema revision.
597+ * @param[in] schemas Server schema info built from capabilities.
598+ * @param[in] user_clb User callback for retireving schema data.
599+ * @param[in] user_data User data for @p user_clb.
600+ * @param[in] has_get_schema Whether the server supports get-schema.
601+ * @param[out] mod Loaded module.
602+ * @return 0 on success.
603+ * @return -1 on error.
604+ */
560605static int
561606nc_ctx_load_module (struct nc_session * session , const char * name , const char * revision , struct schema_info * schemas ,
562607 ly_module_imp_clb user_clb , void * user_data , int has_get_schema , struct lys_module * * mod )
@@ -660,6 +705,15 @@ free_schema_info(struct schema_info *list)
660705 free (list );
661706}
662707
708+ /**
709+ * @brief Build server schema info from ietf-yang-library data.
710+ *
711+ * @param[in] session NC session.
712+ * @param[in] has_get_data Whether get-data RPC is available or only get.
713+ * @param[out] result Server schemas.
714+ * @return 0 on success.
715+ * @return -1 on error.
716+ */
663717static int
664718build_schema_info_yl (struct nc_session * session , int has_get_data , struct schema_info * * result )
665719{
@@ -818,12 +872,20 @@ build_schema_info_yl(struct nc_session *session, int has_get_data, struct schema
818872 if (session -> status != NC_STATUS_RUNNING ) {
819873 /* something bad happened, discard the session */
820874 ERR (session , "Invalid session, discarding." );
821- ret = EXIT_FAILURE ;
875+ ret = -1 ;
822876 }
823877
824878 return ret ;
825879}
826880
881+ /**
882+ * @brief Build server schema info from received capabilities.
883+ *
884+ * @param[in] cpblts Server capabilities.
885+ * @param[out] result Server schemas.
886+ * @return 0 on success.
887+ * @return -1 on error.
888+ */
827889static int
828890build_schema_info_cpblts (char * * cpblts , struct schema_info * * result )
829891{
@@ -893,6 +955,17 @@ build_schema_info_cpblts(char **cpblts, struct schema_info **result)
893955 return 0 ;
894956}
895957
958+ /**
959+ * @brief Fill client context based on server schema info.
960+ *
961+ * @param[in] session NC session with the context to modify.
962+ * @param[in] modules Server schema info.
963+ * @param[in] user_clb User callback for retrieving specific schemas.
964+ * @param[in] user_data User data for @p user_clb.
965+ * @param[in] has_get_schema Whether server supports get-schema RPC.
966+ * @return 0 on success.
967+ * @return -1 on error.
968+ */
896969static int
897970nc_ctx_fill (struct nc_session * session , struct schema_info * modules , ly_module_imp_clb user_clb , void * user_data ,
898971 int has_get_schema )
@@ -934,6 +1007,17 @@ nc_ctx_fill(struct nc_session *session, struct schema_info *modules, ly_module_i
9341007 return ret ;
9351008}
9361009
1010+ /**
1011+ * @brief Fill client context with ietf-netconf schema.
1012+ *
1013+ * @param[in] session NC session with the context to modify.
1014+ * @param[in] modules Server schema info.
1015+ * @param[in] user_clb User callback for retrieving specific schemas.
1016+ * @param[in] user_data User data for @p user_clb.
1017+ * @param[in] has_get_schema Whether server supports get-schema RPC.
1018+ * @return 0 on success.
1019+ * @return -1 on error.
1020+ */
9371021static int
9381022nc_ctx_fill_ietf_netconf (struct nc_session * session , struct schema_info * modules , ly_module_imp_clb user_clb ,
9391023 void * user_data , int has_get_schema )
0 commit comments