int process_psia_request(request *req) { int status; node_t *root = NULL; /* initialize the device interface */ status = iface_init(req); if(status != R_REQUEST_OK) return 1; /* set up the response buffer */ status = xadd_init(req); if(status != R_REQUEST_OK) return 1; /* set up the parser */ status = xml_init(req); if(status != R_REQUEST_OK) return 1; /* create the root node */ root = add_node(NULL, "/PSIA", M_NULL, NODE_SERVICE, NULL, NULL); desc_get_function(root, "Root service"); add_std_resources(root, &process_index, &process_indexr, &process_description, NULL); status = process_root(req, root); return 0; }
int main (int __argc, char **__argv) { /* Hook signals */ signals_hook (); i18n_init (); if (iface_init ()) { /* To uninitialize all stuff, which */ /* has been initialized */ iface_done (); i18n_release (); return EXIT_FAILURE; } tcllib_init (); iface_mainloop (); iface_done (); i18n_release (); return EXIT_SUCCESS; }
static void restart(void) { mroute4_disable(0); mroute6_disable(0); mcgroup4_disable(); mcgroup6_disable(); /* No need to close the IPC, only at cleanup. */ /* Update list of interfaces and create new virtual interface mappings in kernel. */ iface_init(); mroute4_enable(do_vifs, table_id, cache_tmo); mroute6_enable(do_vifs, table_id); }
int iface_conf_read(struct iface_rec *iface) { struct iface_rec *def_iface; int rc, retry = 0; def_iface = iface_match_default(iface); if (def_iface) { /* * older tools allowed default to have different * transport_names so we do not want to overwrite * it. */ if (!strcmp(def_iface->name, DEFAULT_IFACENAME)) { if (!strlen(iface->name)) strcpy(iface->name, def_iface->name); if (!strlen(iface->netdev)) strcpy(iface->netdev, def_iface->netdev); if (!strlen(iface->hwaddress)) strcpy(iface->hwaddress, def_iface->hwaddress); if (!strlen(iface->transport_name)) strcpy(iface->transport_name, def_iface->transport_name); if (!strlen(iface->iname)) strcpy(iface->iname, def_iface->iname); } else { iface_init(iface); iface_copy(iface, def_iface); } return 0; } retry_read: rc = idbm_lock(); if (rc) return rc; rc = __iface_conf_read(iface); idbm_unlock(); /* * cmd was run before running -m iface, so force def bindings * creation to see if that was the one requested */ if (retry < 1 && rc == ISCSI_ERR_IDBM) { iface_setup_host_bindings(); retry++; goto retry_read; } return rc; }
static int __iface_conf_read(struct iface_rec *iface) { char *iface_conf; recinfo_t *info; FILE *f; int rc = 0; iface_conf = calloc(1, PATH_MAX); if (!iface_conf) return ISCSI_ERR_NOMEM; info = idbm_recinfo_alloc(MAX_KEYS); if (!info) { rc = ISCSI_ERR_NOMEM; goto free_conf; } snprintf(iface_conf, PATH_MAX, "%s/%s", IFACE_CONFIG_DIR, iface->name); log_debug(5, "looking for iface conf %s", iface_conf); f = fopen(iface_conf, "r"); if (!f) { /* * if someone passes in default but has not defined * a iface with default then we do it for them */ if (!strcmp(iface->name, DEFAULT_IFACENAME)) { iface_setup_defaults(iface); rc = 0; } else rc = ISCSI_ERR_IDBM; goto free_info; } iface_init(iface); idbm_recinfo_iface(iface, info); idbm_recinfo_config(info, f); fclose(f); free_info: free(info); free_conf: free(iface_conf); return rc; }
/* Init everything before forking, so we can fail and return an * error code in the parent and the initscript will fail */ static void start_server(int background) { int sd, api = 0; if (background && daemonize()) return; smclog(LOG_NOTICE, 0, "%s", version_info); /* Build list of multicast-capable physical interfaces that * are currently assigned an IP address. */ iface_init(); if (!mroute4_enable()) api++; if (!mroute6_enable()) api++; /* At least one API (IPv4 or IPv6) must have initialized successfully * otherwise we abort the server initialization. */ if (!api) { smclog(LOG_INIT, ENOPROTOOPT, "Kernel does not support multicast routing"); exit(1); } sd = ipc_server_init(); if (sd < 0) smclog(LOG_WARNING, errno, "Failed setting up IPC socket, client communication disabled"); atexit(clean); signal_init(); read_conf_file(conf_file); /* Everything setup, notify any clients by creating the pidfile */ if (pidfile(NULL)) smclog(LOG_WARNING, errno, "Failed creating pidfile"); server_loop(sd); }
int iface_conf_read(struct iface_rec *iface) { struct iface_rec *def_iface; int rc; def_iface = iface_match_default(iface); if (def_iface) { /* * older tools allowed default to have different * transport_names so we do not want to overwrite * it. */ if (!strcmp(def_iface->name, DEFAULT_IFACENAME)) { if (!strlen(iface->name)) strcpy(iface->name, def_iface->name); if (!strlen(iface->netdev)) strcpy(iface->netdev, def_iface->netdev); if (!strlen(iface->hwaddress)) strcpy(iface->hwaddress, def_iface->hwaddress); if (!strlen(iface->transport_name)) strcpy(iface->transport_name, def_iface->transport_name); if (!strlen(iface->iname)) strcpy(iface->iname, def_iface->iname); } else { iface_init(iface); iface_copy(iface, def_iface); } return 0; } rc = idbm_lock(); if (rc) return rc; rc = __iface_conf_read(iface); idbm_unlock(); return rc; }
/* Init everything before forking, so we can fail and return an * error code in the parent and the initscript will fail */ static int start_server(void) { int api = 2, busy = 0; if (geteuid() != 0) { smclog(LOG_ERR, "Need root privileges to start %s", prognm); return 1; } if (background) { if (daemon(0, 0) < 0) { smclog(LOG_ERR, "Failed daemonizing: %s", strerror(errno)); return 1; } } /* Hello world! */ smclog(LOG_NOTICE, "%s", version_info); if (startup_delay > 0) { smclog(LOG_INFO, "Startup delay requested, waiting %d sec before continuing.", startup_delay); sleep(startup_delay); } /* * Timer API needs to be initilized before mroute4_enable() */ timer_init(); /* * Build list of multicast-capable physical interfaces */ iface_init(); if (mroute4_enable(do_vifs, table_id, cache_tmo)) { if (errno == EADDRINUSE) busy++; api--; } if (mroute6_enable(do_vifs, table_id)) { if (errno == EADDRINUSE) busy++; api--; } /* At least one API (IPv4 or IPv6) must have initialized successfully * otherwise we abort the server initialization. */ if (!api) { if (busy) smclog(LOG_ERR, "Another multicast routing application is already running."); else smclog(LOG_ERR, "Kernel does not support multicast routing."); exit(1); } atexit(clean); signal_init(); ipc_init(); conf_read(conf_file, do_vifs); /* Everything setup, notify any clients waiting for us */ notify_ready(pid_file, uid, gid); /* Drop root privileges before entering the server loop */ cap_drop_root(uid, gid); return server_loop(); }
/* * default is to use tcp through whatever the network layer * selects for us with the /etc/iscsi/initiatorname.iscsi iname. */ void iface_setup_defaults(struct iface_rec *iface) { sprintf(iface->transport_name, DEFAULT_TRANSPORT); iface_init(iface); }