/* * ***** BEGIN LICENSE BLOCK ***** Copyright (C) 2009-2019 Olof Hagsand Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC(Netgate) This file is part of CLIXON. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 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. Alternatively, the contents of this file may be used under the terms of the GNU General Public License Version 3 or later (the "GPL"), in which case the provisions of the GPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of the GPL, and not to allow others to use your version of this file under the terms of Apache License version 2, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the Apache License version 2 or the GPL. ***** END LICENSE BLOCK ***** */ /* XXX temp constant should go away, */ #undef _EVHTP_NYI #ifdef HAVE_CONFIG_H #include "clixon_config.h" /* generated by config & autoconf */ #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* chmod */ /* evhtp */ #include #include /* cligen */ #include /* clicon */ #include /* restconf */ #include "restconf_lib.h" #if 0 /* These are all dependent on FCGX */ #include "restconf_methods.h" #include "restconf_methods_get.h" #include "restconf_methods_post.h" #include "restconf_stream.h" #endif /* Command line options to be passed to getopt(3) */ #define RESTCONF_OPTS "hD:f:l:p:d:y:a:u:o:P:c:k:" /* Need global variable to for signal handler XXX */ static clicon_handle _CLICON_HANDLE = NULL; /*! Signall terminates process */ static void restconf_sig_term(int arg) { static int i=0; if (i++ == 0) clicon_log(LOG_NOTICE, "%s: %s: pid: %u Signal %d", __PROGRAM__, __FUNCTION__, getpid(), arg); else exit(-1); if (_CLICON_HANDLE){ #ifdef _EVHTP_NYI stream_child_freeall(_CLICON_HANDLE); #endif restconf_terminate(_CLICON_HANDLE); } clicon_exit_set(); /* checked in event_loop() */ exit(-1); } static void restconf_sig_child(int arg) { int status; int pid; if ((pid = waitpid(-1, &status, 0)) != -1 && WIFEXITED(status)){ #ifdef _EVHTP_NYI ; #endif } } /*! Generic callback called if no other callbacks are matched */ static void cx_generic_callback(evhtp_request_t *req, void *arg) { evhtp_connection_t * conn; fprintf(stderr, "%s\n", __FUNCTION__); if (req == NULL){ errno = EINVAL; return; } if ((conn = evhtp_request_get_connection(req)) == NULL) return; htp_sslutil_add_xheaders( req->headers_out, conn->ssl, HTP_SSLUTILS_XHDR_ALL); return evhtp_send_reply(req, EVHTP_RES_OK); } /*! Usage help routine * @param[in] argv0 command line * @param[in] h Clicon handle */ static void usage(clicon_handle h, char *argv0) { fprintf(stderr, "usage:%s [options]\n" "where options are\n" "\t-h \t\t Help\n" "\t-D \t Debug level\n" "\t-f \t Configuration file (mandatory)\n" "\t-l > \t Log on (s)yslog, (f)ile (syslog is default)\n" "\t-p \t Yang directory path (see CLICON_YANG_DIR)\n" "\t-d \t Specify restconf plugin directory dir (default: %s)\n" "\t-y \t Load yang spec file (override yang main module)\n" "\t-a UNIX|IPv4|IPv6 Internal backend socket family\n" "\t-u \t Internal socket domain path or IP addr (see -a)\n" "\t-o \"