yumapro  20.10-12
YumaPro SDK
subsystem.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 - 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_subsystem
13 #define _H_subsystem
14 
15 /* FILE: subsystem.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
28 /*********************************************************************
29 * *
30 * C H A N G E H I S T O R Y *
31 * *
32 *********************************************************************
33 
34 date init comment
35 ----------------------------------------------------------------------
36 06-oct-12 abb Begun; split from netconf_subsystem.c
37 
38 */
39 
40 #ifndef _H_status_enum
41 #include "status_enum.h"
42 #endif
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /* group header only */
49 
73 /********************************************************************
74 * *
75 * C O N S T A N T S *
76 * *
77 *********************************************************************/
78 
80 #define SUBSYS_BUFFLEN 32000
81 
83 #define SUBSYS_TRACE1(cb, fmt, ...) if (cb->traceLevel && cb->errfile) \
84  { \
85  fprintf(cb->errfile, fmt, ##__VA_ARGS__); \
86  fflush(cb->errfile); \
87  }
88 
90 #define SUBSYS_TRACE2(cb, fmt, ...) if (cb->traceLevel > 1 && cb->errfile) \
91  { \
92  fprintf(cb->errfile, fmt, ##__VA_ARGS__); \
93  fflush(cb->errfile); \
94  }
95 
97 #define SUBSYS_TRACE3(cb, fmt, ...) if (cb->traceLevel > 2 && cb->errfile) \
98  { \
99  fprintf(cb->errfile, fmt, ##__VA_ARGS__); \
100  fflush(cb->errfile); \
101  }
102 
106 #define XML_START_MSG ((const xmlChar *)\
107  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
108 
109 
110 /********************************************************************
111 * *
112 * T Y P E S *
113 * *
114 *********************************************************************/
115 
117 typedef enum proto_id_t_ {
120 
123 
126 
127  /* ypshell */
128  PROTO_ID_CLI,
129 
132 
135 
138 } proto_id_t;
139 
140 
148 typedef status_t
149  (*subsys_stdout_fn_t)(const char *buff,
150  size_t bufflen);
151 
152 
161 typedef ssize_t
162  (*subsys_stdin_fn_t)(char *buff,
163  size_t bufflen);
164 
165 
166 /********************************************************************
167 * *
168 * F U N C T I O N S *
169 * *
170 *********************************************************************/
171 
172 
186 extern int run_subsystem (proto_id_t protocol_id,
187  int trace_level,
188  int argc,
189  char **argv);
190 
191 
212 extern int
213  run_subsystem_ex (proto_id_t protocol_id,
214  int trace_level,
215  int argc,
216  char **argv,
217  char **envp,
218  subsys_stdin_fn_t stdin_fn,
219  subsys_stdout_fn_t stdout_fn,
220  int32 stdin_len);
221 
222 
223 
245 extern int
246  run_subsystem_full (proto_id_t protocol_id,
247  int trace_level,
248  int argc,
249  char **argv,
250  char **envp,
251  subsys_stdin_fn_t stdin_fn,
252  subsys_stdout_fn_t stdout_fn,
253  int32 stdin_len);
254 
255 
271 extern status_t
272  init_subsystem_ycontrol (int trace_level,
273  const char *subsys_id);
274 
275 
294 extern status_t
295  init_subsystem_ycontrol_ha (int trace_level,
296  const char *subsys_id,
297  const char *server_id,
298  const char *server_addr,
299  uint16 server_port);
300 
301 
309 extern status_t
310  connect_subsystem_ycontrol (int *retfd);
311 
312 
318 extern status_t
319  check_subsystem_io (void);
320 
321 
327 extern void
328  cleanup_subsystem_ycontrol (status_t res);
329 
330 
334 #ifdef __cplusplus
335 } /* end extern 'C' */
336 #endif
337 
338 #endif /* _H_subsystem */
SUBSYS_BUFFLEN
#define SUBSYS_BUFFLEN
max length of an <ncx-connect> message
Definition: subsystem.h:80
ERR_NCX_SKIPPED
@ ERR_NCX_SKIPPED
2001
Definition: status_enum.h:551
run_subsystem
int run_subsystem(proto_id_t protocol_id, int trace_level, int argc, char **argv)
Run the subsystem : entry point.
Definition: subsystem.c:1035
start_connection
status_t start_connection(subsys_cb_t *cb)
Start the connection to the server.
Definition: subsys_util.c:482
configure_cli_parms
void configure_cli_parms(subsys_cb_t *cb, int argc, char **argv)
Configure CLI parameters.
Definition: subsys_util.c:624
PROTO_ID_RESTCONF
@ PROTO_ID_RESTCONF
RESTCONF.
Definition: subsystem.h:141
status_enum.h
global error status code enumerations
SUBSYS_TRACE3
#define SUBSYS_TRACE3(cb, fmt,...)
SUBSYS_TRACE Level 3 log debug trace macro.
Definition: subsystem.h:97
ERR_NCX_READ_FAILED
@ ERR_NCX_READ_FAILED
240
Definition: status_enum.h:279
cleanup_subsystem_ycontrol
void cleanup_subsystem_ycontrol(status_t res)
Cleanup the subsystem variables.
Definition: subsystem.c:1295
ncxconst.h
Contains NCX constants.
PROTO_ID_NETCONF
@ PROTO_ID_NETCONF
NETCONF.
Definition: subsystem.h:126
subsys_util.h
Thin client IO handler for YumaPro server (utility functions)
SUBSYS_TRACE2
#define SUBSYS_TRACE2(cb, fmt,...)
SUBSYS_TRACE Level 2 log debug trace macro.
Definition: subsystem.h:90
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
run_subsystem_full
int run_subsystem_full(proto_id_t protocol_id, int trace_level, int argc, char **argv, char **envp, subsys_stdin_fn_t stdin_fn, subsys_stdout_fn_t stdout_fn, int32 stdin_len)
Run the subsystem : entry point (full)
Definition: subsystem.c:1105
init_subsystem_ycontrol
status_t init_subsystem_ycontrol(int trace_level, const char *subsys_id)
@
Definition: subsystem.c:1175
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
NCX_SERVER_VERSION
#define NCX_SERVER_VERSION
ncxserver version
Definition: ncxconst.h:183
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
subsys_stdout_fn_t
status_t(* subsys_stdout_fn_t)(const char *buff, size_t bufflen)
STDOUT FUNCTION TEMPLATE subsys_stdout_fn_t.
Definition: subsystem.h:149
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
proto_id_t_
proto_id_t_
the type of protocol starting the subsystem
Definition: subsystem.h:117
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
subsys_stdin_fn_t
ssize_t(* subsys_stdin_fn_t)(char *buff, size_t bufflen)
STDIN FUNCTION TEMPLATE subsys_stdin_fn_t.
Definition: subsystem.h:162
init_subsystem_ycontrol_ha
status_t init_subsystem_ycontrol_ha(int trace_level, const char *subsys_id, const char *server_id, const char *server_addr, uint16 server_port)
@
Definition: subsystem.c:1203
ERR_NCX_EOF
@ ERR_NCX_EOF
244
Definition: status_enum.h:283
init_subsys_cb
void init_subsys_cb(subsys_cb_t *cb)
Initialize the fields of a subsystem control block.
Definition: subsys_util.c:585
subsystem.h
Thin client IO handler for YumaPro server.
PROTO_ID_NONE
@ PROTO_ID_NONE
not set
Definition: subsystem.h:123
SUBSYS_TRACE1
#define SUBSYS_TRACE1(cb, fmt,...)
SUBSYS_TRACE Level 1 log debug trace macro.
Definition: subsystem.h:83
NC_SSH_END_LEN
#define NC_SSH_END_LEN
Length of NETCONF SSH End of Message Marker.
Definition: ncxconst.h:106
get_ssh_parms
status_t get_ssh_parms(subsys_cb_t *cb)
Get the SSH environment parameters.
Definition: subsys_util.c:395
ERR_BUFF_OVFL
@ ERR_BUFF_OVFL
106
Definition: status_enum.h:218
NC_SSH_END
#define NC_SSH_END
NETCONF SSH End of Message Marker.
Definition: ncxconst.h:103
XML_START_MSG
#define XML_START_MSG
copied from ncx/xml_util.h to avoid inluding that file and all the files it includes
Definition: subsystem.h:106
PROTO_ID_WEBUI
@ PROTO_ID_WEBUI
WebUI.
Definition: subsystem.h:135
send_buff.h
Send buffer utility.
connect_subsystem_ycontrol
status_t connect_subsystem_ycontrol(int *retfd)
Connect the subsystem for YControl.
Definition: subsystem.c:1247
send_buff
status_t send_buff(int fd, const char *buffer, size_t cnt)
Send the buffer to the network peer.
Definition: send_buff.c:94
send_cli_ncxconnect
status_t send_cli_ncxconnect(subsys_cb_t *cb)
Send the <ncx-connect> message to the ncxserver for CLI protocol.
Definition: subsys_util.c:519
check_subsystem_io
status_t check_subsystem_io(void)
Check if any input ready to transfer.
Definition: subsystem.c:1275
PROTO_ID_YCONTROL
@ PROTO_ID_YCONTROL
YControl subsystem.
Definition: subsystem.h:138
clean_subsys_cb
void clean_subsys_cb(subsys_cb_t *cb)
Clean the fields of a subsystem control block.
Definition: subsys_util.c:601
run_subsystem_ex
int run_subsystem_ex(proto_id_t protocol_id, int trace_level, int argc, char **argv, char **envp, subsys_stdin_fn_t stdin_fn, subsys_stdout_fn_t stdout_fn, int32 stdin_len)
Run the subsystem : entry point (extended)
Definition: subsystem.c:1067
NCX_URN
#define NCX_URN
URN for NCX extensions.
Definition: ncxconst.h:196
status.h
Global error messages for status code enumerations.
PROTO_ID_YANGAPI
@ PROTO_ID_YANGAPI
YANG-API.
Definition: subsystem.h:129