/usr/include/yuma/agt/agt_util.h is in libyuma-dev 2.9-1+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 | /*
* Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _H_agt_util
#define _H_agt_util
/* FILE: agt_util.h
*********************************************************************
* *
* P U R P O S E *
* *
*********************************************************************
Utility Functions for NCX Server method routines
*********************************************************************
* *
* C H A N G E H I S T O R Y *
* *
*********************************************************************
date init comment
----------------------------------------------------------------------
24-may-06 abb Begun
*/
#ifndef _H_cfg
#include "cfg.h"
#endif
#ifndef _H_dlq
#include "dlq.h"
#endif
#ifndef _H_getcb
#include "getcb.h"
#endif
#ifndef _H_ncxconst
#include "ncxconst.h"
#endif
#ifndef _H_ncxtypes
#include "ncxtypes.h"
#endif
#ifndef _H_rpc
#include "rpc.h"
#endif
#ifndef _H_ses
#include "ses.h"
#endif
#ifndef _H_status
#include "status.h"
#endif
#ifndef _H_val
#include "val.h"
#endif
#ifndef _H_xml_msg
#include "xml_msg.h"
#endif
#ifndef _H_xml_util
#include "xml_util.h"
#endif
#ifndef _H_xpath
#include "xpath.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/********************************************************************
* *
* F U N C T I O N S *
* *
*********************************************************************/
/********************************************************************
* FUNCTION agt_get_cfg_from_parm
*
* Get the cfg_template_t for the config in the target param
*
* INPUTS:
* parmname == parameter to get from (e.g., target)
* msg == incoming rpc_msg_t in progress
* methnode == XML node for RPC method (for errors)
* retcfg == address of return cfg pointer
*
* OUTPUTS:
* *retcfg is set to the address of the cfg_template_t struct
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_get_cfg_from_parm (const xmlChar *parmname,
rpc_msg_t *msg,
xml_node_t *methnode,
cfg_template_t **retcfg);
/********************************************************************
* FUNCTION agt_get_inline_cfg_from_parm
*
* Get the val_value_t node for the inline config element
*
* INPUTS:
* parmname == parameter to get from (e.g., source)
* msg == incoming rpc_msg_t in progress
* methnode == XML node for RPC method (for errors)
* retval == address of return value node pointer
*
* OUTPUTS:
* *retval is set to the address of the val_value_t struct
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_get_inline_cfg_from_parm (const xmlChar *parmname,
rpc_msg_t *msg,
xml_node_t *methnode,
val_value_t **retval);
/********************************************************************
* FUNCTION agt_get_url_from_parm
*
* Get the URL string for the config in the target param
*
* 1) an edit-content choice for edit-config
* 2) a source or target config-choice option for copy-config
* 3) a target of delete-config
* 4) config-source choice option for validate
*
* INPUTS:
* parmname == parameter to get from (e.g., target)
* msg == incoming rpc_msg_t in progress
* methnode == XML node for RPC method (for errors)
* returl == address of return URL string pointer
* retval == address of value node from input used
* OUTPUTS:
* *returl is set to the address of the URL string
* pointing to the memory inside the found parameter
* *retval is set to parm node found, if return NO_ERR
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_get_url_from_parm (const xmlChar *parmname,
rpc_msg_t *msg,
xml_node_t *methnode,
const xmlChar **returl,
val_value_t **retval);
/********************************************************************
* FUNCTION agt_get_filespec_from_url
*
* Check the URL and get the filespec part out of it
*
* INPUTS:
* urlstr == URL to check
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced URL string; must be freed by caller!!
* NULL if some error
*********************************************************************/
extern xmlChar *
agt_get_filespec_from_url (const xmlChar *urlstr,
status_t *res);
/********************************************************************
* FUNCTION agt_get_parmval
*
* Get the identified val_value_t for a given parameter
* Used for error purposes!
* INPUTS:
* parmname == parameter to get
* msg == incoming rpc_msg_t in progress
*
* RETURNS:
* status
*********************************************************************/
extern const val_value_t *
agt_get_parmval (const xmlChar *parmname,
rpc_msg_t *msg);
/********************************************************************
* FUNCTION agt_record_error
*
* Generate an rpc_err_rec_t and save it in the msg
*
* INPUTS:
* scb == session control block
* == NULL and no stats will be recorded
* msghdr == XML msg header with error Q
* == NULL, no errors will be recorded!
* layer == netconf layer error occured <error-type>
* res == internal error code <error-app-tag>
* xmlnode == XML node causing error <bad-element> <error-path>
* == NULL if not available
* parmtyp == type of node in 'error_info'
* error_info == error data, specific to 'res' <error-info>
* == NULL if not available (then nodetyp ignored)
* nodetyp == type of node in 'error_path'
* error_path == internal data node with the error <error-path>
* == NULL if not available or not used
* OUTPUTS:
* errQ has error message added if no malloc errors
* scb->stats may be updated if scb non-NULL
*
* RETURNS:
* none
*********************************************************************/
extern void
agt_record_error (ses_cb_t *scb,
xml_msg_hdr_t *msghdr,
ncx_layer_t layer,
status_t res,
const xml_node_t *xmlnode,
ncx_node_t parmtyp,
const void *error_info,
ncx_node_t nodetyp,
void *error_path);
/********************************************************************
* FUNCTION agt_record_error_errinfo
*
* Generate an rpc_err_rec_t and save it in the msg
* Use the provided error info record for <rpc-error> fields
*
* INPUTS:
* scb == session control block
* == NULL and no stats will be recorded
* msghdr == XML msg header with error Q
* == NULL, no errors will be recorded!
* layer == netconf layer error occured <error-type>
* res == internal error code <error-app-tag>
* xmlnode == XML node causing error <bad-element> <error-path>
* == NULL if not available
* parmtyp == type of node in 'error_info'
* error_info == error data, specific to 'res' <error-info>
* == NULL if not available (then nodetyp ignored)
* nodetyp == type of node in 'error_path'
* error_path == internal data node with the error <error-path>
* == NULL if not available or not used
* errinfo == error info record to use
*
* OUTPUTS:
* errQ has error message added if no malloc errors
* scb->stats may be updated if scb non-NULL
* RETURNS:
* none
*********************************************************************/
extern void
agt_record_error_errinfo (ses_cb_t *scb,
xml_msg_hdr_t *msghdr,
ncx_layer_t layer,
status_t res,
const xml_node_t *xmlnode,
ncx_node_t parmtyp,
const void *error_parm,
ncx_node_t nodetyp,
void *error_path,
const ncx_errinfo_t *errinfo);
/********************************************************************
* FUNCTION agt_record_attr_error
*
* Generate an rpc_err_rec_t and save it in the msg
*
* INPUTS:
* scb == session control block
* msghdr == XML msg header with error Q
* == NULL, no errors will be recorded!
* layer == netconf layer error occured
* res == internal error code
* xmlattr == XML attribute node causing error
* (NULL if not available)
* xmlnode == XML node containing the attr
* badns == bad namespace string value
* nodetyp == type of node in 'errnode'
* errnode == internal data node with the error
* == NULL if not used
*
* OUTPUTS:
* errQ has error message added if no malloc errors
*
* RETURNS:
* none
*********************************************************************/
extern void
agt_record_attr_error (ses_cb_t *scb,
xml_msg_hdr_t *msghdr,
ncx_layer_t layer,
status_t res,
const xml_attr_t *xmlattr,
const xml_node_t *xmlnode,
const xmlChar *badns,
ncx_node_t nodetyp,
const void *errnode);
/********************************************************************
* FUNCTION agt_record_insert_error
*
* Generate an rpc_err_rec_t and save it in the msg
* Use the provided error info record for <rpc-error> fields
*
* For YANG 'missing-instance' error-app-tag
*
* INPUTS:
* scb == session control block
* == NULL and no stats will be recorded
* msghdr == XML msg header with error Q
* == NULL, no errors will be recorded!
* res == internal error code <error-app-tag>
* errval == value node generating the insert error
*
* OUTPUTS:
* errQ has error message added if no malloc errors
* scb->stats may be updated if scb non-NULL
* RETURNS:
* none
*********************************************************************/
extern void
agt_record_insert_error (ses_cb_t *scb,
xml_msg_hdr_t *msghdr,
status_t res,
val_value_t *errval);
/********************************************************************
* FUNCTION agt_record_unique_error
*
* Generate an rpc_err_rec_t and save it in the msg
* Use the provided error info record for <rpc-error> fields
*
* For YANG 'data-not-unique' error-app-tag
*
* INPUTS:
* scb == session control block
* == NULL and no stats will be recorded
* msghdr == XML msg header with error Q
* == NULL, no errors will be recorded!
* errval == list value node that contains the unique-stmt
* valuniqueQ == Q of val_unique_t structs for error-info
*
* OUTPUTS:
* errQ has error message added if no malloc errors
* scb->stats may be updated if scb non-NULL
* RETURNS:
* none
*********************************************************************/
extern void
agt_record_unique_error (ses_cb_t *scb,
xml_msg_hdr_t *msghdr,
val_value_t *errval,
dlq_hdr_t *valuniqueQ);
/********************************************************************
* FUNCTION agt_validate_filter
*
* Validate the <filter> parameter if present
*
* INPUTS:
* scb == session control block
* msg == rpc_msg_t in progress
*
* OUTPUTS:
* msg->rpc_filter is filled in if NO_ERR; type could be NONE
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_validate_filter (ses_cb_t *scb,
rpc_msg_t *msg);
/********************************************************************
* FUNCTION agt_validate_filter_ex
*
* Validate the <filter> parameter if present
*
* INPUTS:
* scb == session control block
* msg == rpc_msg_t in progress
* filter == filter element to use
* OUTPUTS:
* msg->rpc_filter is filled in if NO_ERR; type could be NONE
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_validate_filter_ex (ses_cb_t *scb,
rpc_msg_t *msg,
val_value_t *filter);
/********************************************************************
* FUNCTION agt_check_config
*
* val_nodetest_fn_t callback
*
* Used by the <get-config> operation to return any type of
* configuration data
*
* INPUTS:
* see ncx/val_util.h (val_nodetest_fn_t)
*
* RETURNS:
* TRUE if config; FALSE if non-config
*********************************************************************/
extern boolean
agt_check_config (ncx_withdefaults_t withdef,
boolean realtest,
val_value_t *node);
/********************************************************************
* FUNCTION agt_check_default
*
* val_nodetest_fn_t callback
*
* Used by the <get*> operation to return only values
* not set to the default
*
* INPUTS:
* see ncx/val_util.h (val_nodetest_fn_t)
*
* RETURNS:
* status
*********************************************************************/
extern boolean
agt_check_default (ncx_withdefaults_t withdef,
boolean realtest,
val_value_t *node);
/********************************************************************
* FUNCTION agt_check_save
*
* val_nodetest_fn_t callback
*
* Used by agt_ncx_cfg_save function to filter just what
* is supposed to be saved in the <startup> config file
*
* INPUTS:
* see ncx/val_util.h (val_nodetest_fn_t)
*
* RETURNS:
* status
*********************************************************************/
extern boolean
agt_check_save (ncx_withdefaults_t withdef,
boolean realtest,
val_value_t *node);
/********************************************************************
* FUNCTION agt_output_filter
*
* output the proper data for the get or get-config operation
* generate the data that matched the subtree or XPath filter
*
* INPUTS:
* see rpc/agt_rpc.h (agt_rpc_data_cb_t)
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_output_filter (ses_cb_t *scb,
rpc_msg_t *msg,
int32 indent);
/********************************************************************
* FUNCTION agt_output_schema
*
* generate the YANG file contents for the get-schema operation
*
* INPUTS:
* see rpc/agt_rpc.h (agt_rpc_data_cb_t)
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_output_schema (ses_cb_t *scb,
rpc_msg_t *msg,
int32 indent);
/********************************************************************
* FUNCTION agt_output_empty
*
* output no data for the get or get-config operation
* because the if-modified-since fileter did not pass
*
* INPUTS:
* see rpc/agt_rpc.h (agt_rpc_data_cb_t)
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_output_empty (ses_cb_t *scb,
rpc_msg_t *msg,
int32 indent);
/********************************************************************
* FUNCTION agt_check_max_access
*
* Check if the max-access for a parameter is exceeded
*
* INPUTS:
* newval == value node from PDU to check
* cur_exists == TRUE if the corresponding node in the target exists
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_check_max_access (val_value_t *newval,
boolean cur_exists);
/********************************************************************
* FUNCTION agt_check_editop
*
* Check if the edit operation is okay
*
* INPUTS:
* pop == parent edit operation in affect
* Starting at the data root, the parent edit-op
* is derived from the default-operation parameter
* cop == address of child operation (MAY BE ADJUSTED ON EXIT!!!)
* This is the edit-op field in the new node corresponding
* to the curnode position in the data model
* newnode == pointer to new node in the edit-config PDU
* curnode == pointer to the current node in the data model
* being affected by this operation, if any.
* == NULL if no current node exists
* iqual == effective instance qualifier for this value
* proto == protocol in use
*
* OUTPUTS:
* *cop may be adjusted to simplify further processing,
* based on the following reduction algorithm:
*
* create, replace, and delete operations are 'sticky'.
* Once set, any nested edit-ops must be valid
* within the context of the fixed operation (create or delete)
* and the child operation gets changed to the sticky parent edit-op
*
* if the parent is create or delete, and the child
* is merge or replace, then the child can be ignored
* and will be changed to the parent, since the create
* or delete must be carried through all the way to the leaves
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_check_editop (op_editop_t pop,
op_editop_t *cop,
val_value_t *newnode,
val_value_t *curnode,
ncx_iqual_t iqual,
ncx_protocol_t proto);
/********************************************************************
* FUNCTION agt_enable_feature
*
* Enable a YANG feature in the server
* This will not be detected by any sessions in progress!!!
* It will take affect the next time a <hello> message
* is sent by the server
*
* INPUTS:
* modname == module name containing the feature
* featurename == feature name to enable
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_enable_feature (const xmlChar *modname,
const xmlChar *featurename);
/********************************************************************
* FUNCTION agt_disable_feature
*
* Disable a YANG feature in the server
* This will not be detected by any sessions in progress!!!
* It will take affect the next time a <hello> message
* is sent by the server
*
* INPUTS:
* modname == module name containing the feature
* featurename == feature name to disable
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_disable_feature (const xmlChar *modname,
const xmlChar *featurename);
extern status_t
agt_check_feature (const xmlChar *modname,
const xmlChar *featurename,
int* enabled/*output*/);
/********************************************************************
* FUNCTION agt_make_leaf
*
* make a val_value_t struct for a specified leaf or leaf-list
*
INPUTS:
* parentobj == parent object to find child leaf object
* leafname == name of leaf to find (namespace hardwired)
* leafstrval == string version of value to set for leaf
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced value struct or NULL if some error
*********************************************************************/
extern val_value_t *
agt_make_leaf (obj_template_t *parentobj,
const xmlChar *leafname,
const xmlChar *leafstrval,
status_t *res);
/********************************************************************
* FUNCTION agt_make_uint_leaf
*
* make a val_value_t struct for a specified leaf or leaf-list
*
INPUTS:
* parentobj == parent object to find child leaf object
* leafname == name of leaf to find (namespace hardwired)
* leafval == number value for leaf
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced value struct or NULL if some error
*********************************************************************/
extern val_value_t *
agt_make_uint_leaf (obj_template_t *parentobj,
const xmlChar *leafname,
uint32 leafval,
status_t *res);
/********************************************************************
* FUNCTION agt_make_int_leaf
*
* make a val_value_t struct for a specified leaf or leaf-list
*
INPUTS:
* parentobj == parent object to find child leaf object
* leafname == name of leaf to find (namespace hardwired)
* leafval == integer number value for leaf
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced value struct or NULL if some error
*********************************************************************/
extern val_value_t *
agt_make_int_leaf (obj_template_t *parentobj,
const xmlChar *leafname,
int32 leafval,
status_t *res);
/********************************************************************
* FUNCTION agt_make_uint64_leaf
*
* make a val_value_t struct for a specified leaf or leaf-list
*
INPUTS:
* parentobj == parent object to find child leaf object
* leafname == name of leaf to find (namespace hardwired)
* leafval == number value for leaf
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced value struct or NULL if some error
*********************************************************************/
extern val_value_t *
agt_make_uint64_leaf (obj_template_t *parentobj,
const xmlChar *leafname,
uint64 leafval,
status_t *res);
/********************************************************************
* FUNCTION agt_make_int64_leaf
*
* make a val_value_t struct for a specified leaf or leaf-list
*
INPUTS:
* parentobj == parent object to find child leaf object
* leafname == name of leaf to find (namespace hardwired)
* leafval == integer number value for leaf
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced value struct or NULL if some error
*********************************************************************/
extern val_value_t *
agt_make_int64_leaf (obj_template_t *parentobj,
const xmlChar *leafname,
int64 leafval,
status_t *res);
/********************************************************************
* FUNCTION agt_make_idref_leaf
*
* make a val_value_t struct for a specified leaf or leaf-list
*
INPUTS:
* parentobj == parent object to find child leaf object
* leafname == name of leaf to find (namespace hardwired)
* leafval == identityref value for leaf
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced value struct or NULL if some error
*********************************************************************/
extern val_value_t *
agt_make_idref_leaf (obj_template_t *parentobj,
const xmlChar *leafname,
const val_idref_t *leafval,
status_t *res);
/********************************************************************
* FUNCTION agt_make_list
*
* make a val_value_t struct for a specified list
*
INPUTS:
* parentobj == parent object to find child leaf object
* listname == name of list object to find (namespace hardwired)
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced value struct for the list or NULL if some error
*********************************************************************/
extern val_value_t *
agt_make_list (obj_template_t *parentobj,
const xmlChar *listname,
status_t *res);
/********************************************************************
* FUNCTION agt_make_object
*
* make a val_value_t struct for a specified node
*
INPUTS:
* parentobj == parent object to find child leaf object
* objname == name of the object to find (namespace hardwired)
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced value struct for the list or NULL if some error
*********************************************************************/
extern val_value_t *
agt_make_object (obj_template_t *parentobj,
const xmlChar *objname,
status_t *res);
/********************************************************************
* FUNCTION agt_make_virtual_leaf
*
* make a val_value_t struct for a specified virtual
* leaf or leaf-list
*
INPUTS:
* parentobj == parent object to find child leaf object
* leafname == name of leaf to find (namespace hardwired)
* callbackfn == get callback function to install
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced value struct or NULL if some error
*********************************************************************/
extern val_value_t *
agt_make_virtual_leaf (obj_template_t *parentobj,
const xmlChar *leafname,
getcb_fn_t callbackfn,
status_t *res);
/********************************************************************
* FUNCTION agt_add_top_virtual
*
* make a val_value_t struct for a specified virtual
* top-level data node
*
INPUTS:
* obj == object node of the virtual data node to create
* callbackfn == get callback function to install
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_add_top_virtual (obj_template_t *obj,
getcb_fn_t callbackfn);
/********************************************************************
* FUNCTION agt_add_top_container
*
* make a val_value_t struct for a specified
* top-level container data node. This is used
* by SIL functions to create a top-level container
* which may have virtual nodes within in it
*
* TBD: fine-control over SIL C code generation to
* allow mix of container virtual callback plus
* child node virtual node callbacks
*
INPUTS:
* obj == object node of the container data node to create
* val == address of return val pointer
*
* OUTPUTS:
* *val == pointer to node created in the database
* this is not live memory! It will be freed
* by the database management code
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_add_top_container (obj_template_t *obj,
val_value_t **val);
/********************************************************************
* FUNCTION agt_add_container
*
* make a val_value_t struct for a specified
* nested container data node. This is used
* by SIL functions to create a nested container
* which may have virtual nodes within it
*
* TBD: fine-control over SIL C code generation to
* allow mix of container virtual callback plus
* child node virtual node callbacks
*
INPUTS:
* modname == module name defining objname
* objname == name of object node to create
* parentval == parent value node to add container to
* val == address of return val pointer
*
* OUTPUTS:
* *val == pointer to node created in the database
* this is not live memory! It will be freed
* by the database management code
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_add_container (const xmlChar *modname,
const xmlChar *objname,
val_value_t *parentval,
val_value_t **val);
/********************************************************************
* FUNCTION agt_init_cache
*
* init a cache pointer during the init2 callback
*
* INPUTS:
* modname == name of module defining the top-level object
* objname == name of the top-level database object
* res == address of return status
*
* OUTPUTS:
* *res is set to the return status
*
* RETURNS:
* pointer to object value node from running config,
* or NULL if error or not found
*********************************************************************/
extern val_value_t *
agt_init_cache (const xmlChar *modname,
const xmlChar *objname,
status_t *res);
/********************************************************************
* FUNCTION agt_check_cache
*
* check if a cache pointer needs to be changed or NULLed out
*
INPUTS:
* cacheptr == address of pointer to cache value node
* newval == newval from the callback function
* curval == curval from the callback function
* editop == editop from the callback function
*
* OUTPUTS:
* *cacheptr may be changed, depending on the operation
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_check_cache (val_value_t **cacheptr,
val_value_t *newval,
val_value_t *curval,
op_editop_t editop);
/********************************************************************
* FUNCTION agt_new_xpath_pcb
*
* Get a new XPath parser control block and
* set up the server variable bindings
*
* INPUTS:
* scb == session evaluating the XPath expression
* expr == expression string to use (may be NULL)
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced and initialied xpath_pcb_t structure
* NULL if some error
*********************************************************************/
extern xpath_pcb_t *
agt_new_xpath_pcb (ses_cb_t *scb,
const xmlChar *expr,
status_t *res);
/********************************************************************
* FUNCTION agt_get_startup_filespec
*
* Figure out where to store the startup file
*
* INPUTS:
* res == address of return status
*
* OUTPUTS:
* *res == return status
* RETURNS:
* malloced and filled in filespec string; must be freed by caller
* NULL if malloc error
*********************************************************************/
extern xmlChar *
agt_get_startup_filespec (status_t *res);
/********************************************************************
* FUNCTION agt_get_target_filespec
*
* Figure out where to store the URL target file
*
* INPUTS:
* target_url == target url spec to use; this is
* treated as a relative pathspec, and
* the appropriate data directory is used
* to create this file
* res == address of return status
*
* OUTPUTS:
* *res == return status
*
* RETURNS:
* malloced and filled in filespec string; must be freed by caller
* NULL if some error
*********************************************************************/
extern xmlChar *
agt_get_target_filespec (const xmlChar *target_url,
status_t *res);
/********************************************************************
* FUNCTION agt_set_mod_defaults
*
* Check for any top-level config leafs that have a default
* value, and add them to the running configuration.
*
* INPUTS:
* mod == module that was just added and should be used
* to check for top-level database leafs with a default
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_set_mod_defaults (ncx_module_t *mod);
/********************************************************************
* FUNCTION agt_set_with_defaults
*
* Check if the <with-defaults> parameter is set
* in the request message, and if so, is it
* one of the server's supported values
*
* If not, then record an error
* If so, then set the msg->mhdr.withdef enum
*
* INPUTS:
* scb == session control block to use
* msg == rpc message in progress
* methnode == XML node for the method name
*
* OUTPUTS:
* msg->mhdr.withdef set if NO_ERR
* rpc-error recorded if any error detected
*
* RETURNS:
* status
*********************************************************************/
extern status_t
agt_set_with_defaults (ses_cb_t *scb,
rpc_msg_t *msg,
xml_node_t *methnode);
/********************************************************************
* FUNCTION agt_get_key_value
*
* Get the next expected key value in the ancestor chain
* Used in Yuma SIL code to invoke User SIL callbacks with key values
*
* INPUTS:
* startval == value node to start from
* lastkey == address of last key leaf found in ancestor chain
* caller maintains this state-var as the anscestor
* keys are traversed
* *lastkey == NULL to get the first key
*
* OUTPUTS:
* *lastkey updated with the return value if key found
*
* RETURNS:
* value node to use (do not free!!!)
* NULL if some bad error like no next key found
*********************************************************************/
extern val_value_t *
agt_get_key_value (val_value_t *startval,
val_value_t **lastkey);
/********************************************************************
* FUNCTION agt_add_top_node_if_missing
*
* SIL Phase 2 init: Check the running config to see if
* the specified node is there; if not create one
* return the node either way
* INPUTS:
* mod == module containing object
* objname == object name
* added == address of return added flag
* res == address of return status
*
* OUTPUTS:
* *added == TRUE if new node was added
* *res == return status, return NULL unless NO_ERR
*
* RETURNS:
* if *res==NO_ERR,
* pointer to new or existing node for modname:objname
* this is added to running config and does not have to
* be deleted.
* !!!! No MRO nodes or default nodes have been added !!!!
*********************************************************************/
extern val_value_t *
agt_add_top_node_if_missing (ncx_module_t *mod,
const xmlChar *objname,
boolean *added,
status_t *res);
/********************************************************************
* FUNCTION agt_any_operations_set
*
* Check the new node and all descendants
* for any operation attibutes prsent
*
* INPUTS:
* val == value node to check
*
* RETURNS:
* TRUE if any operation attributes found
* FALSE if no operation attributes found
*/
extern boolean
agt_any_operations_set (val_value_t *val);
/********************************************************************
* FUNCTION agt_apply_this_node
*
* Check if the write operation applies to the current node
*
* INPUTS:
* editop == edit operation value
* newnode == pointer to new node (if any)
* curnode == pointer to current value node (if any)
* (just used to check if non-NULL or compare leaf)
*
* RETURNS:
* TRUE if the current node needs the write operation applied
* FALSE if this is a NO=OP node (either explicit or special merge)
*********************************************************************/
extern boolean
agt_apply_this_node (op_editop_t editop,
const val_value_t *newnode,
const val_value_t *curnode);
#ifdef __cplusplus
} /* end extern 'C' */
#endif
#endif /* _H_agt_util */
|