yumapro  24.10-11
YumaPro SDK
Loading...
Searching...
No Matches
subsys_util.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3 * Copyright (c) 2012 - 2025, 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_subsys_util
13#define _H_subsys_util
14
15/* FILE: subsys_util.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
34date init comment
35----------------------------------------------------------------------
3624-oct-12 abb Begun; split from subsystem.c
37
38*/
39
40#ifndef _H_subsystem
41#include "subsystem.h"
42#endif
43
44#ifndef _H_status
45#include "status.h"
46#endif
47
48#ifndef _H_subsys_magic
49#include "subsys_magic.h"
50#endif
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56/********************************************************************
57* *
58* C O N S T A N T S *
59* *
60*********************************************************************/
61
62
77#define SERVER_MAP_FILE_LINELEN 1024
78
80#define SERVER_MAP_WILDCARD "*"
81
83#define SERVER_MAP_ID_MAXLEN 64
84
85
86/********************************************************************
87* *
88* T Y P E S *
89* *
90*********************************************************************/
91
92
94typedef struct subsys_cb_t_ {
95
97 const char *request_uri;
98
100 const char *request_method;
101
103 const char *content_type;
104
106 const char *content_length;
107
109 const char *modified_since;
110
112 const char *unmodified_since;
113
115 const char *match;
116
118 const char *none_match;
119
121 const char *http_accept;
122
124 const char *message_id;
125
127 const char *user;
128
130 const char *ha_server_id;
131
141 char **envp;
142
149 const char *ha_server_addr;
150
156
159
162
165
168
171
174
177
179 char *port;
180
183
186
188 boolean ncxconnect;
189
191 boolean nonblocking;
192
195
197 boolean no_connect;
198
200 boolean yp_ha_mode;
201
203 boolean extern_mode;
204
207
209 const char *subsys_id;
210
213
215 FILE *errfile;
216
218 fd_set fds;
219
221 char msgbuff[SUBSYS_BUFFLEN];
222
223 /* flag indicating signal handler installed */
224 boolean signal_init_done;
225
226 /* flag indicating program termination requested */
227 boolean shutdown_requested;
228
229 /* flag indicating this is a RESTCONF session is SSE mode */
230 boolean restconf_sse_mode;
231
232 /* SSE_KEEPALIVE env parameter */
233 const char *sse_keepalive;
234
235 /* timeout value for select function to use for SSE keepalives
236 * default=0; no timeout;
237 * causes an SSE comment to be sent to the client
238 */
239 uint16 restconf_sse_timeout;
240
242
243
244/********************************************************************
245* *
246* F U N C T I O N S *
247* *
248*********************************************************************/
249
250
257extern status_t
259
260
269extern status_t
271
272
279extern status_t
281
282
289extern status_t
291
292
298extern void
300
301
307extern void
309
310
323extern void
325 int argc,
326 char **argv);
327
328
340extern status_t
341 start_subsys_ypshell (int *retfd);
342
343
356extern status_t
357 start_subsys_tcp_ncx (int *retfd,
358 const char *user);
359
360
376extern status_t
377 start_subsys_extern_tcp_ncx (int *retfd,
378 const char *user,
379 const char *addr,
380 unsigned int portnum);
381
382
386#ifdef __cplusplus
387} /* end extern 'C' */
388#endif
389
390#endif /* _H_subsys_util */
status_t
global error return code
Definition: status_enum.h:219
proto_id_t
the type of protocol starting the subsystem
Definition: subsystem.h:117
#define SUBSYS_BUFFLEN
max length of an <ncx-connect> message
Definition: subsystem.h:80
status_t(* subsys_stdout_fn_t)(const char *buff, size_t bufflen)
STDOUT FUNCTION TEMPLATE subsys_stdout_fn_t.
Definition: subsystem.h:149
ssize_t(* subsys_stdin_fn_t)(char *buff, size_t bufflen)
STDIN FUNCTION TEMPLATE subsys_stdin_fn_t.
Definition: subsystem.h:162
void clean_subsys_cb(subsys_cb_t *cb)
Clean the fields of a subsystem control block.
Definition: subsys_util.c:1018
void init_subsys_cb(subsys_cb_t *cb)
Initialize the fields of a subsystem control block.
Definition: subsys_util.c:1002
void configure_cli_parms(subsys_cb_t *cb, int argc, char **argv)
Configure CLI parameters.
Definition: subsys_util.c:1056
status_t start_subsys_tcp_ncx(int *retfd, const char *user)
Start the subsystem for a tcp-ncx transport connection.
Definition: subsys_util.c:1200
status_t start_subsys_extern_tcp_ncx(int *retfd, const char *user, const char *addr, unsigned int portnum)
Start the subsystem to connect to an external tcp-ncx socket.
Definition: subsys_util.c:1280
status_t get_ssh_parms(subsys_cb_t *cb)
Get the SSH environment parameters.
Definition: subsys_util.c:724
status_t start_subsys_ypshell(int *retfd)
Start the subsystem for yp-shell.
Definition: subsys_util.c:1138
status_t start_connection(subsys_cb_t *cb)
Start the connection to the server.
Definition: subsys_util.c:882
status_t get_server_root_mapfile(subsys_cb_t *cb)
Get the name of the server root mapfile set.
Definition: subsys_util.c:834
status_t send_cli_ncxconnect(subsys_cb_t *cb)
Send the <ncx-connect> message to the ncxserver for CLI protocol.
Definition: subsys_util.c:934
Global error messages for status code enumerations.
one subsystem control block for session
Definition: subsys_util.h:94
const char * content_length
Content-Length if a RESTCONF session.
Definition: subsys_util.h:106
char ** envp
Environment pointer poassed tp main The fastcgi wrapper on lighttpd replaces the environment variable...
Definition: subsys_util.h:141
boolean nonblocking_set_ok
Flag non-blocking failed.
Definition: subsys_util.h:194
const char * http_accept
Accept a RESTCONF session.
Definition: subsys_util.h:121
char * server_root_mapfile
server root ID string
Definition: subsys_util.h:167
const char * ha_server_id
The HA server-id.
Definition: subsys_util.h:130
int ncxsock
socket number
Definition: subsys_util.h:185
boolean yp_ha_mode
flag YP-HA mode
Definition: subsys_util.h:200
subsys_stdout_fn_t stdout_fn
override STDOUT function
Definition: subsys_util.h:161
const char * match
Match if a RESTCONF session.
Definition: subsys_util.h:115
int32 content_len
content length
Definition: subsys_util.h:164
const char * user
User ID for the session.
Definition: subsys_util.h:127
const char * message_id
Message-ID if a RESTCONF session.
Definition: subsys_util.h:124
const char * subsys_id
subsystem ID to use
Definition: subsys_util.h:209
const char * modified_since
Modified-Since if a RESTCONF session.
Definition: subsys_util.h:109
boolean extern_mode
flag external mode
Definition: subsys_util.h:203
proto_id_t proto_id
protocol in use
Definition: subsys_util.h:206
boolean nonblocking
Use non-blocking.
Definition: subsys_util.h:191
subsys_stdin_fn_t stdin_fn
override STDIN function
Definition: subsys_util.h:158
const char * request_uri
request URI if a RESTCONF session
Definition: subsys_util.h:97
char * server_addr
server address from SSH_CONNECTION
Definition: subsys_util.h:182
const char * ha_server_addr
YP-HA support; this address will override the AF_LOCAL or the TCP socket file read by subsys_info_rea...
Definition: subsys_util.h:149
char * server_root
server root ID string
Definition: subsys_util.h:170
boolean ncxconnect
Use ncxconnect.
Definition: subsys_util.h:188
char * client_addr
client address
Definition: subsys_util.h:176
FILE * errfile
error file
Definition: subsys_util.h:215
const char * request_method
request method if a RESTCONF session
Definition: subsys_util.h:100
const char * none_match
None-Match if a RESTCONF session.
Definition: subsys_util.h:118
const char * content_type
content-type if a RESTCONF session
Definition: subsys_util.h:103
const char * unmodified_since
Unmodified-Since if a RESTCONF session.
Definition: subsys_util.h:112
char * port
server port
Definition: subsys_util.h:179
boolean server_root_from_env
server root from ENV
Definition: subsys_util.h:173
int traceLevel
debug trace level set (0 - 3)
Definition: subsys_util.h:212
boolean no_connect
flag no connection
Definition: subsys_util.h:197
fd_set fds
file descriptors
Definition: subsys_util.h:218
uint16 ha_server_port
HA server port number The ha_server_port is also used by the extern tcp-ncx mode (extern_mode == TRUE...
Definition: subsys_util.h:155
Define magic string value for <ncx-connect> messages.
Thin client IO handler for YumaPro server.