yumapro  20.10-14
YumaPro SDK
yangapi.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Andy Bierman, All Rights Reserved.
3  * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4  *
5  * Unless required by applicable law or agreed to in writing,
6  * software distributed under the License is distributed on an
7  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations
10  * under the License.
11  */
12 #ifndef _H_yangapi
13 #define _H_yangapi
14 /* FILE: yangapi.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
26 /*********************************************************************
27 * *
28 * C H A N G E H I S T O R Y *
29 * *
30 *********************************************************************
31 
32 date init comment
33 ----------------------------------------------------------------------
34 11-apr-12 abb Begun.
35 */
36 
37 /* used by the agent for the xmlTextReader interface */
38 #include <xmlreader.h>
39 
40 #ifndef _H_dlq
41 #include "dlq.h"
42 #endif
43 
44 #ifndef _H_ncxtypes
45 #include "ncxtypes.h"
46 #endif
47 
48 #ifndef _H_op
49 #include "op.h"
50 #endif
51 
52 #ifndef _H_obj
53 #include "obj.h"
54 #endif
55 
56 #ifndef _H_val
57 #include "val.h"
58 #endif
59 
60 #ifndef _H_xpath
61 #include "xpath.h"
62 #endif
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
68 
69 /* Header only */
70 
88 /********************************************************************
89 * *
90 * C O N S T A N T S *
91 * *
92 *********************************************************************/
93 
95 #define YANGAPI_RET_OK 200
96 
98 #define YANGAPI_RET_CREATE_OK 201
99 
101 #define YANGAPI_RET_BAD_METHOD 405
102 
103 
104 /********************************************************************
105 * *
106 * T Y P E S *
107 * *
108 *********************************************************************/
109 
111 typedef enum yangapi_method_t_ {
121 
122 
126 typedef enum yangapi_launchpt_t_ {
129 
132 
135 
138 
141 
144 
147 
150 
153 
156 
159 
162 
165 
168 
171 
174 
178 
179 
181 typedef struct yangapi_param_t_ {
183  dlq_hdr_t qhdr;
184 
186  xmlChar *name;
187 
189  xmlChar *value;
191 
192 
194 typedef struct yangapi_accept_t_ {
196  dlq_hdr_t qhdr;
197 
199  xmlChar *media_type;
200 
202  xmlChar *submedia_type;
203 
205  xmlChar *format;
206 
208  xmlChar *qvalue_str;
210 
211 
213 typedef enum restconf_content_t_ {
219 
220 
224 typedef struct yangapi_cb_t_ {
225 
226 /************************* COMMON RCB entries *****************************/
227 
229  dlq_hdr_t qhdr;
230 
232  dlq_hdr_t paramQ;
233 
235  dlq_hdr_t keyvalQ;
236 
238  dlq_hdr_t acceptQ;
239 
241  dlq_hdr_t sorted_acceptQ;
242 
244  xmlChar *accept;
245 
247  xmlChar *request_method;
248 
250  xmlChar *request_uri;
251 
254 
257 
260 
263 
266 
269 
272 
275 
278 
281 
284 
287 
289  yangapi_launchpt_t request_launchpt;
290 
293 
296 
299 
301  boolean query_config;
302 
305 
307  uint32 query_depth;
308 
311 
314 
316  xmlChar *query_point;
317 
319  xmlChar *query_select;
320 
323 
326 
329 
331  xmlChar *query_start;
332 
334  time_t query_tstamp;
335 
337  ncx_etag_t query_etag;
338 
340  xmlChar *query_test;
341 
344 
347 
350 
355  xmlChar *query_persist;
356 
359 
362 
365 
367  xmlChar *content_type;
368 
370  xmlChar *content_length;
371 
374 
377 
379  xmlChar *if_match;
380 
382  xmlChar *if_none_match;
383 
386 
388  yangapi_method_t method;
389 
391  xmlChar *fragment;
392 
394  uint32 pathlen;
395 
397  boolean db_api_patch;
398 
400  boolean get2_read;
401 
403  dlq_hdr_t get2_lookupQ;
404 
406  dlq_hdr_t get2_selectQ;
407 
409  uint32 return_code;
410 
413 
416 
420  boolean skip_read;
421 
425  boolean empty_read;
426 
428  boolean is_delta;
429 
432 
433 /********************** Accept header entries ***************************/
434 
437 
439  boolean norm_header;
440 
441 /************************* RESTCONF entries *****************************/
442 
446  boolean is_restconf;
447 
451  restconf_content_t query_content;
452 
455 
457  xmlChar *query_filter;
458 
464  xmlChar *query_starttime;
465 
467  xmlChar *starttime_utc;
468 
474  xmlChar *query_stoptime;
475 
477  xmlChar *stoptime_utc;
478 
480  boolean futurestop;
481 
484 
488  const xmlChar *query_fields;
489 
491  xmlChar *fields_buff;
492 
495 
497  xmlChar *index_string;
498 
500  boolean empty_edit;
501 
503  boolean is_action;
504 
507 
510 
513 
514 /********************* YANG-PATCH entries *****************************/
515 
517  boolean yang_patch;
518 
520  xmlChar *patch_id;
521 
523  xmlChar *edit_id;
524 
525 /********************* YP-COAP entries *****************************/
526 
528  boolean is_ypcoap;
529 
530  uint16 http_status;
533  uint16 coap_etag_len;
534  xmlChar *coap_etag;
535  xmlChar *http_location;
536  xmlChar *http_etag;
537  xmlChar *coap_data;
538  size_t coap_datalen;
539  boolean coap_save;
540  boolean coap_is_block1;
542  boolean coap_block_m;
543  uint16 coap_block_num;
544 
545 /********************* SNMP entries *****************************/
546 
548  boolean is_snmp;
549 
550 #if defined(WITH_SNMP) && defined(WITH_RESTCONF)
551  netsnmp_variable_list *variables;
552 
568 
571 
579 
583  boolean snmp_key_walk;
584 
590 
591 /********************* SNMP Index entries *****************************/
592 
606 
611  dlq_hdr_t snmp_getnext_listQ;
612 
618  dlq_hdr_t snmp_target_keyvalQ;
619 
622 
628 
631 
632 /********************* SNMP GET2 entries *****************************/
633 
639 
644 
645 #endif
646 
647 
648 /********************* GNMI entries *****************************/
649 
651  boolean is_gnmi;
652 
655 
657  boolean lock_done;
658 
660  boolean gnmi_patch;
661 } yangapi_cb_t;
662 
663 
667 /********************************************************************
668 * *
669 * F U N C T I O N S *
670 * *
671 *********************************************************************/
672 
691 extern yangapi_param_t *
692  yangapi_new_param (const xmlChar *parmname,
693  uint32 parmnamelen,
694  const xmlChar *parmval,
695  uint32 parmvallen);
696 
697 
703 extern void
705 
706 
720 extern yangapi_accept_t *
721  yangapi_new_accept (const xmlChar *mediatype,
722  uint32 media_type_len,
723  const xmlChar *submediatype,
724  uint32 submediatype_len,
725  const xmlChar *acc_format,
726  uint32 acc_format_len,
727  const xmlChar *qvalue,
728  uint32 qvalue_len);
729 
730 
736 extern void
737  yangapi_free_accept (yangapi_accept_t *accept_entry);
738 
739 
747 extern void
749 
750 
757 extern void
759  ses_cb_t *scb);
760 
761 
767 extern void
769 
770 
776 extern yangapi_cb_t *
777  yangapi_new_rcb (void);
778 
779 
785 extern void
787 
788 
794 extern void
796 
797 
804 extern const xmlChar *
805  yangapi_get_method_name (yangapi_method_t method_enum);
806 
807 
814 extern uint8
815  yangapi_cvt_method_coap (yangapi_method_t method_enum);
816 
817 
824 extern restconf_content_t
825  yangapi_get_content_enum (const xmlChar *content);
826 
827 
834 extern const xmlChar *
835  yangapi_get_content_name (restconf_content_t content);
836 
837 
841 #ifdef __cplusplus
842 } /* end extern 'C' */
843 #endif
844 
845 #endif /* _H_yangapi */
uint32 query_select_xpath_result_count
result count for select parameter search
Definition: yangapi.h:328
val_value_t * curnode
curmode being processed
Definition: yangapi.h:415
xmlChar * fragment
back-ptr to fragment if any
Definition: yangapi.h:391
xmlChar * media_type
media type
Definition: yangapi.h:199
XPath expression result.
Definition: xpath.h:619
obj_template_t * request_target_obj_term
final GET2 target
Definition: yangapi.h:286
OPTIONS method.
Definition: yangapi.h:113
Data Object Support.
dlq provides general double-linked list and queue support:
xmlChar * submedia_type
sub-media type
Definition: yangapi.h:202
boolean db_api_patch
TRUE if this is an edit from DB-API.
Definition: yangapi.h:397
/restconf/data launch point
Definition: yangapi.h:134
boolean empty_read
TRUE if there is nothing to read because filters did not produce any output.
Definition: yangapi.h:425
boolean is_restconf
TRUE if RESTCONF method or a NETCONF <get-bulk> is in progress FALSE if a YANG-API method is in progr...
Definition: yangapi.h:446
boolean is_action
RESTCONF Action requested.
Definition: yangapi.h:503
boolean query_config
TRUE for config=true, FALSE for config=false.
Definition: yangapi.h:301
uint32 snmp_index_length
the length of the index, Specifies how many .k1.k2.k3 appended after the base table OID ...
Definition: yangapi.h:627
uint8 yangapi_cvt_method_coap(yangapi_method_t method_enum)
Get the libcoap numeric value for the HTTP method enum.
Definition: yangapi.c:575
yangapi_launchpt_t request_launchpt
request launch point
Definition: yangapi.h:289
boolean snmp_key_walk
TRUE if need to walk all the list entries first in order to process getnext request on tabular instan...
Definition: yangapi.h:583
xmlChar * query_starttime
used to trigger the notification replay feature and indicate that the replay should start at the time...
Definition: yangapi.h:464
/restconf launch point
Definition: yangapi.h:131
events launch point
Definition: yangapi.h:170
yangapi_method_t method
HTTP method enumeration.
Definition: yangapi.h:388
restconf_content_t
RESTCONF content query param enumeration.
Definition: yangapi.h:213
yangapi_accept_t * yangapi_new_accept(const xmlChar *mediatype, uint32 media_type_len, const xmlChar *submediatype, uint32 submediatype_len, const xmlChar *acc_format, uint32 acc_format_len, const xmlChar *qvalue, uint32 qvalue_len)
Create a new YANGAPI paramater.
Definition: yangapi.c:154
Restapi Control Block Used by RESTCONF to hold parse and request processing state.
Definition: yangapi.h:224
ncx_display_mode_t query_format
format query parameter
Definition: yangapi.h:310
not set
Definition: yangapi.h:214
boolean coap_block_m
filled if coap_is_block1
Definition: yangapi.h:542
xmlChar * stoptime_utc
utc converted query_stoptime
Definition: yangapi.h:477
obj_template_t * req_target_reply_obj
backptr inside root_tree->obj
Definition: yangapi.h:277
xmlChar * if_unmodified_since
If-Unmodified-Since parameter.
Definition: yangapi.h:376
xmlChar * request_target_name
malloced VAL_NAME
Definition: yangapi.h:280
val_value_t * snmpget2_match_list
matched list value to use during get2 walking Used to find matching terminal value ...
Definition: yangapi.h:643
boolean query_config_set
TRUE if the config query parameter is present.
Definition: yangapi.h:304
xpath_pcb_t * request_xpath
request URI parsed in XPath control block
Definition: yangapi.h:262
uint32 return_code
HTTP return code to send to client.
Definition: yangapi.h:409
boolean skip_read
TRUE to skip read during response because conditional was not met (e.g., If-Match.
Definition: yangapi.h:420
xmlChar * http_etag
output CoAP ETag (not binary)
Definition: yangapi.h:536
version launch point
Definition: yangapi.h:161
all descendant data nodes
Definition: yangapi.h:217
One YANG data-def-stmt.
Definition: obj.h:1057
yangapi_launchpt_t
describes the type of node indicated by the RequestURI path Used internally in the server to process ...
Definition: yangapi.h:126
GET method.
Definition: yangapi.h:115
yangapi_method_t
HTTP methods used by YANG-API and RESTCONF.
Definition: yangapi.h:111
PATCH method.
Definition: yangapi.h:118
xmlChar * if_match
If-Match parameter.
Definition: yangapi.h:379
xmlChar * query_stoptime
The &#39;stop-time&#39; parameter is used with the replay feature to indicate the newest notifications of int...
Definition: yangapi.h:474
val_value_t * valfilter
filter element to use
Definition: yangapi.h:454
obj_template_t * snmp_target_obj
back pointer to target object (target leaf ONLY obj)
Definition: yangapi.h:570
POST method.
Definition: yangapi.h:116
size_t coap_datalen
output message body len
Definition: yangapi.h:538
yangapi_cb_t * yangapi_new_rcb(void)
Create a new YANG-API control block.
Definition: yangapi.c:317
val_value_t * request_terminal
backptr inside root tree to tarminal val_value_t found
Definition: yangapi.h:298
xmlChar * edit_id
value represents failed edit ID
Definition: yangapi.h:523
restconf_content_t yangapi_get_content_enum(const xmlChar *content)
Get the enum for the content query parameter from the query URI part.
Definition: yangapi.c:611
/restconf/data/foo/new-bar launch point
Definition: yangapi.h:140
boolean query_confirmed
flag that confirm-commit is be completed
Definition: yangapi.h:364
void yangapi_free_param(yangapi_param_t *param)
Free a YANG-API parameter.
Definition: yangapi.c:128
boolean gnmi_patch
gNMI patch request
Definition: yangapi.h:660
xmlChar * content_length
input content length (not always set)
Definition: yangapi.h:370
Schema and data model Xpath search support.
xpath_result_t * query_test_xpath_result
result for test parameter Xpath
Definition: yangapi.h:346
xmlChar * name
query parameter name
Definition: yangapi.h:186
xmlChar * patch_id
value used in the request
Definition: yangapi.h:520
obj_oid_t * snmp_target_index_oid
target index OID
Definition: yangapi.h:605
streams/stream launch point
Definition: yangapi.h:167
boolean is_gnmi
Request is for YP-gNMI.
Definition: yangapi.h:651
Value Node Basic Support.
xmlChar * index_string
index string used to build Location header for list
Definition: yangapi.h:497
streams launch point
Definition: yangapi.h:164
boolean snmpget2_index_match
GET2 boolean TRUE if found matching list entry FALSE, if no entry found.
Definition: yangapi.h:638
/restconf/yang-library-version launch point
Definition: yangapi.h:173
void yangapi_clean_keyvalQ(yangapi_cb_t *rcb)
Clean the key value Q in a request control block.
Definition: yangapi.c:244
boolean netconf_getbulk
RESTCONF get-bulk active, not RESTCONF at all!
Definition: yangapi.h:259
obj_template_t * snmp_table_obj
back pointer to target table object of the target leaf node
Definition: yangapi.h:630
int content_len
actual content length
Definition: yangapi.h:385
/restconf/operations/some-operation launch point
Definition: yangapi.h:152
boolean futurestop
flag if future stop notifications
Definition: yangapi.h:480
val_value_t * request_target
backptr inside root_tree
Definition: yangapi.h:274
uint16 coap_block_num
filled if coap_is_block1
Definition: yangapi.h:543
xmlChar * http_location
if Location-Path needed
Definition: yangapi.h:535
YANG module data structures Many internal representations of YANG module constructs.
not set
Definition: yangapi.h:128
boolean is_snmp
request header used for SNMP
Definition: yangapi.h:548
obj_template_t * request_target_obj
backptr inside schema_tree
Definition: yangapi.h:283
obj_oid_t * snmp_target_oid
Requested OID, for snmpget is the actual requested OID, For snmpgetnext will be the next OID wether n...
Definition: yangapi.h:578
uint8 coap_content_type
CoAP content-type code.
Definition: yangapi.h:532
boolean target_is_config
TRUE if target data is config=true.
Definition: yangapi.h:431
modules launch point
Definition: yangapi.h:143
boolean is_replace_datastore
TRUE if Replace a Datastore Resource.
Definition: yangapi.h:512
action launch point
Definition: yangapi.h:176
op_editop_t
NETCONF edit-config operation types.
Definition: op.h:122
restconf_content_t query_content
Start RESTCONF specific Query parameters entries query_content value // config/nonconfig/all.
Definition: yangapi.h:451
xmlChar * coap_data
output message body or block1 input
Definition: yangapi.h:537
xmlChar * query_filter
URL encoded filter string.
Definition: yangapi.h:457
xmlChar * fields_buff
malloced URL-decoded query_fields
Definition: yangapi.h:491
boolean is_delta
internal is delta flag
Definition: yangapi.h:428
RESTCONF &#39;schema&#39; resource class.
Definition: yangapi.h:158
PUT method.
Definition: yangapi.h:117
xmlChar * request_method
request method
Definition: yangapi.h:247
boolean lock_done
gNMI lock done
Definition: yangapi.h:657
xmlChar * starttime_utc
utc converted query_starttime
Definition: yangapi.h:467
uint8 coap_block_szx
filled if coap_is_block1
Definition: yangapi.h:541
xmlChar * qvalue_str
Q value string.
Definition: yangapi.h:208
YANG-API Query string parameter.
Definition: yangapi.h:181
boolean norm_header
TRUE if header entry is normative.
Definition: yangapi.h:439
one value to match one type
Definition: val.h:860
boolean get2_read
TRUE if a GET2 read needed.
Definition: yangapi.h:400
HEAD method.
Definition: yangapi.h:114
Restapi Accept header string entries.
Definition: yangapi.h:194
xmlChar * query_test
back-ptr into paramQ, test parameter
Definition: yangapi.h:340
not set
Definition: yangapi.h:112
/restconf/operations launch point
Definition: yangapi.h:149
void yangapi_free_accept(yangapi_accept_t *accept_entry)
Free a YANGAPI accept header entries.
Definition: yangapi.c:221
defines the snmp oid value, stored as an array of integers for easier comparision when performing AVL...
Definition: obj.h:1046
boolean request_force_patch_root
forced patch root
Definition: yangapi.h:256
xmlChar * query_point
back-ptr into paramQ to insertion point
Definition: yangapi.h:316
Session Control Block.
Definition: ses.h:542
op_editop_t editop
edit operation
Definition: yangapi.h:412
op_insertop_t query_insert
insert query parameter
Definition: yangapi.h:313
ncx_display_mode_t
enumeration of val_dump_value display modes
Definition: ncxtypes.h:447
status_t
global error return code
Definition: status_enum.h:186
const xmlChar * query_fields
Fields query Parameter entries URL encoded str; backptr to ?
Definition: yangapi.h:488
val_value_t * request_top_data
backptr inside root tree to top of data
Definition: yangapi.h:295
void yangapi_clean_getnext_listQ(yangapi_cb_t *rcb, ses_cb_t *scb)
Free all the snmp getnext list entries.
Definition: yangapi.c:266
/restconf/data/foo launch point
Definition: yangapi.h:137
val_value_t * action_val
backptr inside targroot to action node
Definition: yangapi.h:509
xmlChar * if_none_match
If-None-Match parameter.
Definition: yangapi.h:382
modules/module launch point
Definition: yangapi.h:146
uint32 query_test_xpath_result_count
result count for test parameter Xpath
Definition: yangapi.h:349
uint32 request_xpath_result_count
search result count for request URI
Definition: yangapi.h:268
xmlChar * request_patch_path
request patch path
Definition: yangapi.h:253
ncx_etag_t query_etag
converted etag
Definition: yangapi.h:337
void yangapi_clean_target_keyvalQ(yangapi_cb_t *rcb)
Free all the snmp target keyval entries.
Definition: yangapi.c:296
xpath_result_t * request_xpath_result
search result for request URI
Definition: yangapi.h:265
uint16 coap_etag_len
input CoAP ETag length
Definition: yangapi.h:533
void yangapi_clean_rcb(yangapi_cb_t *rcb)
Clean a YANGAPI/RESTCONF control block.
Definition: yangapi.c:476
xmlChar * coap_etag
input CoAP ETag (binary)
Definition: yangapi.h:534
boolean snmp_return_value_set
TRUE if instance node and value found and set FALSE otherwise.
Definition: yangapi.h:589
uint8 snmp_pdu_code
SNMP PDU command code:
Definition: yangapi.h:567
xmlChar * request_uri
saved request URI
Definition: yangapi.h:250
xmlChar * query_persist_id
persist-id parameter for the confirmed-commit
Definition: yangapi.h:358
ncx_display_mode_t accept_format
accepted output encoding
Definition: yangapi.h:436
xmlChar * accept
saved Accept header string
Definition: yangapi.h:244
op_insertop_t
YANG insert operation types.
Definition: op.h:137
NETCONF protocol operations.
boolean empty_edit
TRUE if request is an empty edit.
Definition: yangapi.h:500
uint16 http_status
HTTP status code.
Definition: yangapi.h:530
only non-configuration data nodes
Definition: yangapi.h:216
XPath parser control block.
Definition: xpath.h:668
xmlChar * content_type
input content type
Definition: yangapi.h:367
return only configuration data nodes
Definition: yangapi.h:215
boolean coap_is_block1
T: request uses Blo0ck1.
Definition: yangapi.h:540
boolean coap_save
T: need to cache coap_data, not free.
Definition: yangapi.h:539
uint32 query_depth
depth query parameter
Definition: yangapi.h:307
void yangapi_free_rcb(yangapi_cb_t *rcb)
Free a YANGAPI control block.
Definition: yangapi.c:351
uint8 coap_accept_type
CoAP accept-type code.
Definition: yangapi.h:531
xmlChar * query_start
back-ptr into request_uri, start parameter
Definition: yangapi.h:331
const xmlChar * yangapi_get_content_name(restconf_content_t content)
Get the keyword for the specified restconf_content_t enumeration.
Definition: yangapi.c:639
boolean request_xpath_result_flat
flag flatten result already done
Definition: yangapi.h:271
xpath_result_t * query_select_xpath_result
result for select parameter search
Definition: yangapi.h:325
val_value_t * action_root
malloced pointer to action root
Definition: yangapi.h:506
boolean yang_patch
TRUE if YANG PATCH is in progress.
Definition: yangapi.h:517
ncx_withdefaults_t
enum for with-defaults enum values
Definition: ncxtypes.h:1010
xpath_pcb_t * query_test_xpath
test parameter parsed as XPath
Definition: yangapi.h:343
xmlChar * value
query parameter value
Definition: yangapi.h:189
val_value_t * snmp_target_list
malloced requested list value that holds all keys
Definition: yangapi.h:621
DELETE method.
Definition: yangapi.h:119
xmlChar * if_modified_since
If-Modified-Since parameter.
Definition: yangapi.h:373
xmlChar * query_select
back-ptr into paramQ to select parameter
Definition: yangapi.h:319
yangapi_param_t * yangapi_new_param(const xmlChar *parmname, uint32 parmnamelen, const xmlChar *parmval, uint32 parmvallen)
Create a new YANGAPI paramater.
Definition: yangapi.c:89
boolean is_ypcoap
request from RESTCONF over CoAP
Definition: yangapi.h:528
uint32 query_confirm_timeout
confirm-timeout parameter for the confirmed-commit
Definition: yangapi.h:361
YANG launch point.
Definition: yangapi.h:155
val_value_t * fields_filter
malloced based on fields_buff
Definition: yangapi.h:494
time_t query_tstamp
converted timestamp
Definition: yangapi.h:334
status_t res
gNMI GET status
Definition: yangapi.h:654
xmlChar * format
format requested
Definition: yangapi.h:205
const xmlChar * yangapi_get_method_name(yangapi_method_t method_enum)
Get the method name from its enum.
Definition: yangapi.c:537
val_value_t * request_launch
backptr inside root tree to launch point
Definition: yangapi.h:292
ncx_withdefaults_t query_withdef
with-defaults default
Definition: yangapi.h:483
uint32 pathlen
len from request_uri of resource path
Definition: yangapi.h:394
xpath_pcb_t * query_select_xpath
select parameter parsed as XPath
Definition: yangapi.h:322
xmlChar * query_persist
start parameters for confirmed-commit extension persist parameter for confirmed-commit back-ptr into ...
Definition: yangapi.h:355