struct arglist * store_fetch_required_udp_ports(struct arglist * desc) { char * fname = _plug_get_fname(desc); static struct plugin p; struct arglist * ret; store_get_plugin(&p, fname); ret = str2arglist(p.required_udp_ports); return ret; }
struct arglist * store_fetch_excluded_keys(struct arglist * desc) { char * fname = _plug_get_fname(desc); static struct plugin p; struct arglist * ret; store_get_plugin(&p, fname); ret = str2arglist(p.excluded_keys); return ret; }
struct arglist * store_fetch_dependencies(struct arglist * desc) { char * fname = _plug_get_fname(desc); static struct plugin p; struct arglist * ret; store_get_plugin(&p, fname); ret = str2arglist(p.dependencies); return ret; }
//------------------------------------------------------------------------------ // FUNCTION // void RT_staticrt_parse(void) // // DESCRIPTION // get static route string from CFG and set into routing table // string format: <destination IP>;<netmask>;<gateway>;[metric];[if];[enable] // // PARAMETERS // NONE // // RETURN // NONE // //------------------------------------------------------------------------------ static int RT_staticrt_parse ( char *rtent, struct in_addr *dst, struct in_addr *mask, struct in_addr *gw, int *metric ) { int argc; char *arglists[8]; argc = str2arglist(rtent, arglists, ';', 8); switch (argc) { case 3: *metric = 2; break; case 4: *metric = atoi(arglists[3]); break; case 6: /* Check if the rule is enabled */ if (strcmp("1", arglists[5]) != 0) return -1; if (arglists[3][0] != 0) *metric = atoi(arglists[3]); else *metric = 2; break; default: return -1; } // Do range check if(Check_IP(arglists[0])<0) return -1; if(Check_MASK(arglists[1])<0) return -1; if(Check_IP(arglists[2])<0) return -1; dst->s_addr = inet_addr(arglists[0]); mask->s_addr = inet_addr(arglists[1]); gw->s_addr = inet_addr(arglists[2]); return 0; }
struct arglist * store_load_plugin(char * dir, char * file, struct arglist * prefs) { char desc_file[PATH_MAX+1]; char plug_file[PATH_MAX+1]; char * str; char store_dir[PATH_MAX+1]; struct plugin p; struct pprefs pp[MAX_PREFS]; struct arglist * ret; int i; struct stat st1, st2; struct arglist * al; bzero(pp, sizeof(pp)); snprintf(desc_file, sizeof(desc_file), "%s/.desc/%s", dir, file); str = strrchr(desc_file, '.'); if( str != NULL ) { str[0] = '\0'; if( strlen(desc_file) + 6 < sizeof(desc_file) ) strcat(desc_file, ".desc"); } snprintf(plug_file, sizeof(plug_file), "%s/%s", dir, file); if ( stat(plug_file, &st1) < 0 || stat(desc_file, &st2) < 0 ) return NULL; /* * Look if the plugin is newer, and if that's the case also make sure that * the plugin mtime is not in the future... */ if ( st1.st_mtime > st2.st_mtime && st1.st_mtime <= time(NULL) ) return NULL; snprintf(store_dir, sizeof(store_dir), "%s/.desc", dir); if(store_get_plugin_f(&p, pp, store_dir, file) < 0) return NULL; if(p.magic != MAGIC) return NULL; if(p.id <= 0) return NULL; ret = emalloc(sizeof(struct arglist)); plug_set_id(ret, p.id); plug_set_category(ret, p.category); plug_set_fname(ret, file); plug_set_path(ret, p.path); plug_set_family(ret, p.family, NULL); al = str2arglist(p.required_ports); if ( al != NULL ) arg_add_value(ret, "required_ports", ARG_ARGLIST, -1, al); al = str2arglist(p.required_keys); if ( al != NULL ) arg_add_value(ret, "required_keys", ARG_ARGLIST, -1, al); al = str2arglist(p.required_udp_ports); if ( al != NULL ) arg_add_value(ret, "required_udp_ports", ARG_ARGLIST, -1, al) ; al = str2arglist(p.excluded_keys); if ( al != NULL ) arg_add_value(ret, "excluded_keys", ARG_ARGLIST, -1, al); al = str2arglist(p.dependencies); if ( al != NULL ) arg_add_value(ret, "DEPENDENCIES", ARG_ARGLIST, -1, al); if ( p.timeout != 0 ) arg_add_value(ret, "TIMEOUT", ARG_INT, -1, (void*)p.timeout); arg_add_value(ret, "NAME", ARG_STRING, strlen(p.name), estrdup(p.name)); arg_add_value(ret, "preferences", ARG_ARGLIST, -1, prefs); if(p.has_prefs) { for(i=0;pp[i].type[0] != '\0';i++) { _add_plugin_preference(prefs, p.name, pp[i].name, pp[i].type, pp[i].dfl); } } return ret; }