s32 ws__SocketApiOpen(WS_ENV * ws_env,s32 * ret) { s32 vrfid; s32 res ; s8 bgp_websrv_path[64]={0}; s8 path[sizeof(CONPLAT_SESSION_PATH)+SID_LENGTH+32]; CONFIG * cfg; char * sid = web_session_id(); if( sock > 0 ) return WS_OK ; sprintf(path, CONPLAT_SESSION_PATH "/_%s", sid); cfg = config_load(path); vrfid = config_getint(cfg, "vrfid", 0); config_free(cfg); CJFDEBUG("vrfid %d",vrfid); sprintf(bgp_websrv_path, "%s%u", WEB_BGP_API_UNIX_PATH, vrfid); res= socket_api_open( bgp_websrv_path, NULL, NULL) ; if( res<= 0 && vrfid != 0 && g_vrfid < 0 ) { vrfid = 0 ; sprintf(bgp_websrv_path, "%s%u", WEB_BGP_API_UNIX_PATH, vrfid); cfg = config_load(path); config_setint(cfg, "vrfid", 0); config_store(cfg,path); config_free(cfg); res= socket_api_open( bgp_websrv_path, NULL, NULL) ; } if( res <= 0 ) { return ws_send_soap_error(ws_env,"connecting daemon error !") ; } socket_api_reset(); return WS_OK; }
/******************************************************************************* 函数名称 : ws__setDomainListenConfig 功能描述 : 保存域监听的相关配置 输入参数 : WS_ENV * ws_env web services环境 int domainListenSwitch 域监听开关 int agedTime 老化时间 输出参数 : int *ret 设置结果 返 回 值 : WS_OK 成功 -------------------------------------------------------------------------------- 最近一次修改记录 : 修改作者 : 张岳 修改目的 : 新函数 修改日期 : 2013年1月6日 *******************************************************************************/ s32 ws__setDomainListenConfig(WS_ENV* ws_env, int domainListenSwitch, int agedTime, int *ret) { CONFIG *cfg = NULL; domain_listen_cfg listen_cfg; u32 res = ERROR_SUCCESS; cfg = config_load(DOMAIN_LISTEN_CFG_PATH); if (NULL == cfg) { return ERROR_FAIL; } /*域监听设置写入配置文件中*/ cfg = config_setint(cfg, "switch", domainListenSwitch); cfg = config_setint(cfg, "aged_time", agedTime); config_store(cfg, DOMAIN_LISTEN_CFG_PATH); config_free(cfg); listen_cfg.domain_listen_switch = domainListenSwitch; listen_cfg.aged_time = agedTime; /*下发到数据面*/ res = webauth_syscall_set_domain_listen_config(listen_cfg); if(ERROR_SUCCESS != res) { return ws_new_soap_fault(ws_env, ERROR_SYSTEM); } *ret = 0; return WS_OK; }
/******************************************************************************* 函数名称 : set_web_listen_global_conf 功能描述 : 设置web监听全局配置 输入参数 : global_conf 全局配置项 输出参数 : 无 返 回 值 : ERROR_SUCCESS 成功 ERROR_FAIL 失败 -------------------------------------------------------------------------------- 最近一次修改记录 : 修改作者 : 仇俊杰 修改目的 : 新添加函数 修改日期 : 2011-1-8 *******************************************************************************/ u32 set_web_listen_global_conf (web_listen_global_cfg * global_conf) { CONFIG * cfg = NULL; s8 user_group_str[USER_GROUP_STRING_LEN] = {0}; cfg = config_load(WEB_LISTEN_CFG_PATH); if (NULL == cfg) { return ERROR_FAIL; } strncpy(user_group_str, config_get(cfg, "user_group_string","1"), USER_GROUP_STRING_LEN - 1); user_group_str[USER_GROUP_STRING_LEN - 1] = 0; obj_quote_handle(user_group_str, NETADDR_DEL_REFER); cfg = config_setint(cfg, "set_enable", global_conf->enable); cfg = config_set(cfg, "user_group_string", global_conf->user_group); cfg = config_setint(cfg, "aged_time", global_conf->aged_time); cfg = config_set(cfg, "popwnd_url", global_conf->popwnd_url); cfg = config_setint(cfg, "pf_time", global_conf->pf_time); obj_quote_handle(global_conf->user_group, NETADDR_ADD_REFER); config_store(cfg, WEB_LISTEN_CFG_PATH); config_free(cfg); return ERROR_SUCCESS; }
/******************************************************************************* 函数名称 : portal_auth_set_basic_cfg 功能描述 : 设置portal认证基本配置 输入参数 : global_conf ---- portal认证基本配置 输出参数 : 无 返 回 值 : PORTAL_SUCCESS: 成功 -------------------------------------------------------------------------------- 最近一次修改记录 : 修改作者 : 仇俊杰 修改目的 : 新添加函数 修改日期 : 2011-5-10 *****************************************************************************/ u32 portal_set_basic_cfg (portal_basic_cfg_s * global_conf) { CONFIG * cfg = NULL; cfg = config_load(PORTAL_AUTH_CFG_PATH); if (NULL == cfg) { return PORTAL_OPEN_FILE_FAIL; } cfg = config_setint(cfg, "webauth_switch", global_conf->webauth_switch); cfg = config_setint(cfg, "client_switch", global_conf->client_switch); cfg = config_setint(cfg, "aged_time", global_conf->aged_time); cfg = config_setint(cfg, "auth_method", global_conf->auth_method); cfg = config_setint(cfg, "unique_auth", global_conf->every_auth); cfg = config_setint(cfg, "q_offline", global_conf->q_offline); cfg = config_setint(cfg, "radius_acct", global_conf->radius_acct); cfg = config_setint(cfg, "heartbeat_time", global_conf->heartbeat_time); /*将基本配置写入文件*/ config_store(cfg, PORTAL_AUTH_CFG_PATH); config_free(cfg); /*写入pam默认配置文件*/ if (WEBAUTH_ENABLE == global_conf->webauth_switch || PORTAL_CLIENT_AUTH_ENABLE == global_conf->client_switch) { webauth_set_pam_config(global_conf->auth_method); } return PORTAL_SUCCESS; }
/***************************************************************************** 函 数 名 : ws__setDnsmasq 功能描述 : 防火墙设备:配置Dnsmasq 输入参数 : ws_env ---- web service执行环境 dnsmasq ---- 是否启用DNS代理:dnsmasq 输出参数 : result ---- 返回结果 返 回 值 : ERR_OK ---- 执行成功 ws_new_soap_fault---- 执行失败 ----------------------------------------------------------------------------- 最近一次修改记录: 修改作者: zhangjiefeng 修改目的: 生成新函数 修改日期: 2010年01月19日 *****************************************************************************/ int ws__setDnsmasq(WS_ENV* ws_env, xsd__int dnsmasq, xsd__int* ret) { s32 result = ERROR_SUCCESS; s8 *value = NULL; CONFIG * cfg = NULL; if(1 == dnsmasq) { result = startdnsmasq(); value = "enable"; if(ERROR_SUCCESS != result) return ws_send_soap_error(ws_env, "Start dnsmasq failed."); } else if(0 == dnsmasq) { result = stopdnsmasq(); value = "disable"; if(ERROR_SUCCESS != result) return ws_send_soap_error(ws_env, "Stop dnsmasq failed."); } cfg = config_load(CFG_DNS_PATH); if(NULL == cfg) { return ws_send_soap_error(ws_env, "Open dns config file failed."); } cfg = config_setint(cfg, "dnsmasq_switch", dnsmasq); config_store(cfg, CFG_DNS_PATH); config_free(cfg); *ret = 0; return WS_OK; }
/***************************************************************************** 函 数 名 : ws__setLocalUserInfoSync 功能描述 : 本地用户远程同步 输入参数 : soap ---- web service执行环境 输出参数 : ret ---- 返回结果 返 回 值 : WS_OK ---- 执行成功 ---------------------------------------------------------------------------- ---- 最近一次修改记录 : 修改作者 : 仇俊杰 修改目的 : 新添加函数 修改日期 : 2011-2-22 *****************************************************************************/ int ws__setLocalUserInfoSync(WS_ENV * ws_env, char * umcIp, int umcPort, char * userInfo, int * ret) { CONFIG *cfg; s8 *delim = "?"; s8 send_umc[LOCAL_USER_SEND_UMC_LENGTH]; s8 *user_info = NULL; s8 *user_info_tmp = NULL; cfg = config_load(LOCAL_USER_CFG_PATH); if(NULL == cfg) { return ws_send_soap_error (ws_env, "Open file failed!"); } cfg = config_set(cfg, "umc_ip", umcIp); cfg = config_setint(cfg, "umc_port", umcPort); config_store(cfg, LOCAL_USER_CFG_PATH); config_free(cfg); sprintf(send_umc, " curl http://%s:%d/UMC/sys/sub/OrgManageDevcieadd.action? --data-urlencode \"user=%s\"" , umcIp, umcPort, strtok(userInfo, delim)); user_info = ws_malloc(ws_env, LOCAL_USER_INFO_LEN); user_info_tmp = ws_malloc(ws_env, LOCAL_USER_INFO_LEN); while((user_info = strtok(NULL, delim))) { sprintf(user_info_tmp, " --data-urlencode \"user=%s\"", user_info); strcat(send_umc, user_info_tmp); } system(send_umc); return WS_OK; }
int ws__setSrvLogConfig(WS_ENV* soap, int maxDeleteInterval, int resumeFlag, int camFlag, int camstoreFlag, int *ret) { int ws_err; CONFIG * cfg; sqlite3 *db; char buf[200]; s32 s_type = web_get_slot_type(); s32 count = 0; sqlite3_res res; if (WS_OK != (ws_err = ws_check_int(soap, M_SRVLOG_DELINTERVAL_MIN, M_SRVLOG_DELINTERVAL_MAX, maxDeleteInterval, "maxDeleteInterval"))) { return ws_err; } cfg = config_load(CONPLAT_CONF "/log_conf.conf"); config_setint(cfg, "attack_del_period", maxDeleteInterval); config_store(cfg, CONPLAT_CONF "/log_conf.conf"); if ( NULL == (db = sqlite3_open_ex(1, "/config/db/cam_cfg.db"))) { return SQLITE_FAILD_OPEN; } sqlite3_exec_query_ex(db, "SELECT count(*) as count FROM tb_switch_log_cfg;", &res); sqlite3_get_s32_ex(res, 0, "count", &count); sqlite3_res_free_ex(res); res = NULL; if(count == 0) { snprintf(buf, sizeof(buf), "INSERT INTO tb_switch_log_cfg (resumelog, camlog, camlog_store)VALUES(0,0,0);"); if (WS_OK != (ws_err = sqlite3_exec_ex(db, buf))) { sqlite3_close_ex(db); return ws_err; } } snprintf (buf, sizeof (buf), "UPDATE tb_switch_log_cfg SET resumelog=%d, camlog=%d, camlog_store=%d;", resumeFlag, camFlag, camstoreFlag); if (WS_OK != (ws_err = sqlite3_exec_ex(db, buf))) { sqlite3_close_ex(db); return ws_err; } sqlite3_close_ex(db); if(WS_OK != (ws_err = srvlog_camlog_localsave_download(s_type))) { return ws_err; } *ret = 0; return WS_OK; }
s32 setVrfHcPid(s32 pid,u32 vrfid) { CONFIG * cfg = NULL; s8 path[128]={0}; snprintf(path,sizeof(path),"/config/sys/hc_%d.conf",vrfid); cfg = config_load(path); cfg = config_setint(cfg, "pid", pid); config_store(cfg, path); config_free(cfg); return ERROR_SUCCESS; }
/******************************************************************************* 函数名称 : ws__setFreeArpLearn 功能描述 : 开启或关闭免费ARP学习功能 输入参数 : flag 输出参数 : ERROR_SUCCESS: 成功 其他: 错误码 返 回 值 : ret -------------------------------------------------------------------------------- 最近一次修改记录: 修改作者 : Mengwenli 修改目的 : 新添加函数 修改日期 : 2010-05-08 *******************************************************************************/ s32 ws__setFreeArpLearn(WS_ENV *soap, s32 arpflag, s32 *ret) { s8 cmd[256]; CONFIG *cfg = NULL; (void)soap; cfg = config_load(FREE_ARP_LEARN_CONF_FILE); cfg = config_setint(cfg, "free_Arp_Learn_Flag", arpflag); config_store (cfg, FREE_ARP_LEARN_CONF_FILE); config_free(cfg); snprintf(cmd, sizeof(cmd), "/sbin/sysctl -w net.ipv4.conf.all.arp_accept=%d > >/dev/null 2>&1", arpflag); system(cmd); *ret = 0; return WS_OK; }
s32 dns_alg_lib_disable(void) { s32 ret = 0,buf; CONFIG * cfg; ret |= conplat_syscall(MODULEID_DNS_ALG, DNS_ALG_DISABLE, (void *)&buf, sizeof(buf), &ret); if (0 == ret) { cfg = config_load(DNS_ALG_CONF); if (NULL == cfg) { return -1; } cfg = config_setint(cfg, CONFIG_NAME, 0); config_store(cfg, DNS_ALG_CONF); config_free(cfg); } return ret; }
s32 ws__SetVrfSelection(WS_ENV * env, s32 vrfid, s32 *ret) { char path[sizeof(CONPLAT_SESSION_PATH)+SID_LENGTH+32]; CONFIG * cfg; CJFDEBUG("vrfid %d",vrfid); if( vrfid <0 || vrfid > 4096 ) return WS_OK ; g_vrfid= vrfid ; sprintf(path, CONPLAT_SESSION_PATH "/_%s", web_session_id()); cfg = config_load(path); config_setint(cfg,"vrfid",vrfid); config_store(cfg,path); config_free(cfg); return WS_OK; }
/***************************************************************************** 函 数 名 : ws__setDiskThreshold 功能描述 : web service实现函数 输入参数 : soap ---- web service执行环境 输出参数 : ret ---- 返回结果 返 回 值 : WS_OK ---- 执行成功 soapFault ---- 执行失败 调用函数 : 被调函数 : ============================================================================ 修改历史 : 1.日 期 : 2008年8月8日 修改内容 : 新生成函数 *****************************************************************************/ int ws__setDiskThreshold(WS_ENV* ws_env, int diskThreshold, int *ret) { CONFIG * cfg = NULL; int ws_err; if (WS_OK != (ws_err = ws_check_int(ws_env, 20, 80, diskThreshold, "diskThreshold"))) { return ws_err; } /*Modified by Fuzhiqing for Bug377 on 02/25/2009 Remove the LocalStorage page. Set diskThreshold to 90 unchangeable. cfg = config_setint(cfg, "disk_threshold", diskThreshold);*/ cfg = config_setint(cfg, "disk_threshold", 90); config_store(cfg, LOG_CONF_FILE); config_free(cfg); /*record sucess operate log*/ WEB_SEND_EX_OPERLOG_QUICK(ERROR_SUCCESS," Modified local hard disk usage limit: [%d].",90); *ret = 0; return WS_OK; }
s32 ws__setIpv6RapidEnable(WS_ENV* ws_env, s32 enable, s32 *ret) { CONFIG * cfg = NULL; s32 flag = enable; s32 sys_ret = ERROR_SUCCESS; s32 ws_ret = ERROR_SUCCESS; cfg = config_load(IPV6_RAPID_FILE); cfg = config_setint(cfg, "ipv6_rapid_enable", enable); config_store(cfg, IPV6_RAPID_FILE); config_free(cfg); ws_ret = conplat_syscall(MODULEID_TRANS_TECH, IP6_6RD_SYSCALL_ENABLE, &flag, sizeof(s32), &sys_ret); /*FW业务版*/ ws_ret = conplat_syscall(FW_MODULEID_TRANS_TECH | FW_BOARD, IP6_6RD_SYSCALL_ENABLE, &flag, sizeof(s32), &sys_ret); if ( ws_ret != ERROR_SUCCESS || sys_ret != ERROR_SUCCESS) { return ERR_TRANS_TECH_SYSCALL; } return WS_OK; }
/** * tilda_term_config_defaults () * * Read and set all of the defaults for this terminal from the current configuration. * * Success: return 0 * Failure: return non-zero */ static gint tilda_term_config_defaults (tilda_term *tt) { DEBUG_FUNCTION ("tilda_term_config_defaults"); DEBUG_ASSERT (tt != NULL); gdouble transparency_level = 0.0; GdkRGBA fg, bg, cc; gchar* word_chars; gint i; gint cursor_shape; /** Colors & Palette **/ bg.red = GUINT16_TO_FLOAT(config_getint ("back_red")); bg.green = GUINT16_TO_FLOAT(config_getint ("back_green")); bg.blue = GUINT16_TO_FLOAT(config_getint ("back_blue")); bg.alpha = 1.0; fg.red = GUINT16_TO_FLOAT(config_getint ("text_red")); fg.green = GUINT16_TO_FLOAT(config_getint ("text_green")); fg.blue = GUINT16_TO_FLOAT(config_getint ("text_blue")); fg.alpha = 1.0; cc.red = GUINT16_TO_FLOAT(config_getint ("cursor_red")); cc.green = GUINT16_TO_FLOAT(config_getint ("cursor_green")); cc.blue = GUINT16_TO_FLOAT(config_getint ("cursor_blue")); cc.alpha = 1.0; for(i = 0;i < TERMINAL_PALETTE_SIZE; i++) { current_palette[i].red = GUINT16_TO_FLOAT(config_getnint ("palette", i*3)); current_palette[i].green = GUINT16_TO_FLOAT(config_getnint ("palette", i*3+1)); current_palette[i].blue = GUINT16_TO_FLOAT(config_getnint ("palette", i*3+2)); current_palette[i].alpha = 1.0; } vte_terminal_set_colors_rgba (VTE_TERMINAL(tt->vte_term), &fg, &bg, current_palette, TERMINAL_PALETTE_SIZE); /** Bells **/ vte_terminal_set_audible_bell (VTE_TERMINAL(tt->vte_term), config_getbool ("bell")); vte_terminal_set_visible_bell (VTE_TERMINAL(tt->vte_term), config_getbool ("bell")); /** Cursor **/ vte_terminal_set_cursor_blink_mode (VTE_TERMINAL(tt->vte_term), (config_getbool ("blinks"))?VTE_CURSOR_BLINK_ON:VTE_CURSOR_BLINK_OFF); vte_terminal_set_color_cursor_rgba (VTE_TERMINAL(tt->vte_term), &cc); cursor_shape = config_getint("cursor_shape"); if (cursor_shape < 0 || cursor_shape > 2) { config_setint("cursor_shape", 0); cursor_shape = 0; } vte_terminal_set_cursor_shape(VTE_TERMINAL(tt->vte_term), (VteTerminalCursorShape)cursor_shape); /** Scrolling **/ vte_terminal_set_scroll_background (VTE_TERMINAL(tt->vte_term), config_getbool ("scroll_background")); vte_terminal_set_scroll_on_output (VTE_TERMINAL(tt->vte_term), config_getbool ("scroll_on_output")); vte_terminal_set_scroll_on_keystroke (VTE_TERMINAL(tt->vte_term), config_getbool ("scroll_on_key")); /** Mouse **/ vte_terminal_set_mouse_autohide (VTE_TERMINAL(tt->vte_term), FALSE); /* TODO: make this configurable */ /** Text Properties **/ vte_terminal_set_allow_bold (VTE_TERMINAL(tt->vte_term), config_getbool ("bold")); gtk_widget_set_double_buffered (tt->vte_term, config_getbool("double_buffer")); PangoFontDescription *description = pango_font_description_from_string (config_getstr ("font")); vte_terminal_set_font (VTE_TERMINAL (tt->vte_term), description); /** Scrollback **/ vte_terminal_set_scrollback_lines (VTE_TERMINAL(tt->vte_term), config_getbool("scroll_history_infinite") ? -1 : config_getint ("lines")); /** Keys **/ switch (config_getint ("backspace_key")) { case ASCII_DELETE: vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_DELETE); break; case DELETE_SEQUENCE: vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_DELETE_SEQUENCE); break; case ASCII_BACKSPACE: vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_BACKSPACE); break; case AUTO: default: vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_AUTO); break; } switch (config_getint ("delete_key")) { case ASCII_DELETE: vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_DELETE); break; case DELETE_SEQUENCE: vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_DELETE_SEQUENCE); break; case ASCII_BACKSPACE: vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_BACKSPACE); break; case AUTO: default: vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_AUTO); break; } /** Word chars **/ word_chars = config_getstr ("word_chars"); if (NULL == word_chars || '\0' == *word_chars) { word_chars = DEFAULT_WORD_CHARS; } vte_terminal_set_word_chars (VTE_TERMINAL(tt->vte_term), word_chars); /** Background **/ if (config_getbool ("use_image")) vte_terminal_set_background_image_file (VTE_TERMINAL(tt->vte_term), config_getstr ("image")); else vte_terminal_set_background_image_file (VTE_TERMINAL(tt->vte_term), NULL); transparency_level = ((gdouble) config_getint ("transparency"))/100; if (config_getbool ("enable_transparency") && transparency_level > 0) { vte_terminal_set_background_saturation (VTE_TERMINAL (tt->vte_term), transparency_level); vte_terminal_set_opacity (VTE_TERMINAL (tt->vte_term), (1.0 - transparency_level) * 0xffff); vte_terminal_set_background_transparent (VTE_TERMINAL(tt->vte_term), !tt->tw->have_argb_visual); } return 0; }