📄 xsupconfwrite.c
字号:
break; case TTLS_PHASE2_EAP_MD5: if (fprintf(fileid, "\t\tphase2_type = eap_md5\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } break; case TTLS_PHASE2_UNDEFINED: default:#ifdef DEBUG printf("Either the TTLS phase 2 method was undefined, or is something " "that is not allowed!\n");#endif return XSUPCONFWRITE_BADTTLSPHASE2; break; } p2type = cur->phase2; while (p2type) { switch (p2type->phase2_type) { case TTLS_PHASE2_PAP: retval = xsupconfwrite_ttls_phase2_pap(fileid, p2type->phase2_data); if (retval != XSUPCONFWRITE_ERRNONE) return retval; break; case TTLS_PHASE2_CHAP: retval = xsupconfwrite_ttls_phase2_chap(fileid, p2type->phase2_data); if (retval != XSUPCONFWRITE_ERRNONE) return retval; break; case TTLS_PHASE2_MSCHAP: retval = xsupconfwrite_ttls_phase2_mschap(fileid, p2type->phase2_data); if (retval != XSUPCONFWRITE_ERRNONE) return retval; break; case TTLS_PHASE2_MSCHAPV2: retval = xsupconfwrite_ttls_phase2_mschapv2(fileid, p2type->phase2_data); if (retval != XSUPCONFWRITE_ERRNONE) return retval; break; case TTLS_PHASE2_EAP_MD5: data.method_data = p2type->phase2_data; retval = xsupconfwrite_eap_md5(fileid, &data, 2); if (retval != XSUPCONFWRITE_ERRNONE) return retval; break; default:#ifdef DEBUG printf("%s\n", xsupconfwrite_strerr(XSUPCONFWRITE_BADTTLSPHASE2));#endif return XSUPCONFWRITE_BADTTLSPHASE2; break; } p2type = p2type->next; } return XSUPCONFWRITE_ERRNONE;}/******************************************************************* * * Write the configuration information for EAP-TTLS. * *******************************************************************/int xsupconfwrite_eap_ttls(FILE *fileid, struct config_eap_method *cur){ struct config_eap_ttls *eapttls; int retval; if (!fileid) {#ifdef DEBUG printf("Error : %s, at %s():%d!\n", xsupconfwrite_strerr(XSUPCONFWRITE_NOFILEHANDLE), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_NOFILEHANDLE; } if (!cur) {#ifdef DEBUG printf("Error : %s, at %s():%d!\n", xsupconfwrite_strerr(XSUPCONFWRITE_NOEAPDATA), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_NOEAPDATA; } eapttls = (struct config_eap_ttls *)cur->method_data; if (!eapttls) {#ifdef DEBUG printf("Error : The EAP-TTLS structure was missing useful data!\n");#endif return XSUPCONFWRITE_NOEAPDATA; } if (fprintf(fileid, "\teap-ttls\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (fprintf(fileid, "\t{\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (eapttls->user_cert) { if (fprintf(fileid, "\t\tuser_cert = \"%s\"\n", eapttls->user_cert) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapttls->root_cert) { if (fprintf(fileid, "\t\troot_cert = \"%s\"\n", eapttls->root_cert) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapttls->root_dir) { if (fprintf(fileid, "\t\troot_dir = \"%s\"\n", eapttls->root_dir) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapttls->crl_dir) { if (fprintf(fileid, "\t\tcrl_dir = %s\n", eapttls->crl_dir) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapttls->user_key) { if (fprintf(fileid, "\t\tuser_key = \"%s\"\n", eapttls->user_key) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapttls->user_key_pass) { if (fprintf(fileid, "\t\tuser_key_pass = \"%s\"\n", eapttls->user_key_pass) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapttls->session_resume == RES_YES) { if (fprintf(fileid, "\t\tsession_resume = yes\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } // XXX TODO : Move this to a #defined value in xsupconfig.h if ((eapttls->chunk_size != 1398) && (eapttls->chunk_size != 0)) { if (fprintf(fileid, "\t\tchunk_size = %d\n", eapttls->chunk_size) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapttls->random_file) { if (fprintf(fileid, "\t\trandom_file = \"%s\"\n", eapttls->random_file) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapttls->cncheck) { if (fprintf(fileid, "\t\tcncheck = %s\n", eapttls->cncheck) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapttls->cnexact == TRUE) { if (fprintf(fileid, "\t\tcnexact = yes\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } retval = xsupconfwrite_eap_ttls_phase2(fileid, eapttls); if (retval != XSUPCONFWRITE_ERRNONE) return retval; if (fprintf(fileid, "\t}\n\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } return XSUPCONFWRITE_ERRNONE;}/******************************************************************* * * Write the configuration information for EAP-TLS. * *******************************************************************/int xsupconfwrite_eap_tls(FILE *fileid, struct config_eap_method *cur){ struct config_eap_tls *eaptls; int retval; if (!fileid) {#ifdef DEBUG printf("Error : %s, at %s():%d!\n", xsupconfwrite_strerr(XSUPCONFWRITE_NOFILEHANDLE), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_NOFILEHANDLE; } if (!cur) {#ifdef DEBUG printf("Error : %s, at %s():%d!\n", xsupconfwrite_strerr(XSUPCONFWRITE_NOEAPDATA), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_NOEAPDATA; } eaptls = (struct config_eap_tls *)cur->method_data; if (!eaptls) {#ifdef DEBUG printf("Error : The EAP-TLS structure was missing useful data!\n");#endif return XSUPCONFWRITE_NOEAPDATA; } if (fprintf(fileid, "\teap-tls\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (fprintf(fileid, "\t{\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (eaptls->user_cert) { if (fprintf(fileid, "\t\tuser_cert = \"%s\"\n", eaptls->user_cert) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eaptls->root_cert) { if (fprintf(fileid, "\t\troot_cert = \"%s\"\n", eaptls->root_cert) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eaptls->root_dir) { if (fprintf(fileid, "\t\troot_dir = \"%s\"\n", eaptls->root_dir) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eaptls->crl_dir) { if (fprintf(fileid, "\t\tcrl_dir = %s\n", eaptls->crl_dir) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eaptls->user_key) { if (fprintf(fileid, "\t\tuser_key = \"%s\"\n", eaptls->user_key) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eaptls->user_key_pass) { if (fprintf(fileid, "\t\tuser_key_pass = \"%s\"\n", eaptls->user_key_pass) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eaptls->session_resume == RES_YES) { if (fprintf(fileid, "\t\tsession_resume = yes\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } // XXX TODO : Move this to a #defined value in xsupconfig.h if ((eaptls->chunk_size != 1398) && (eaptls->chunk_size != 0)) { if (fprintf(fileid, "\t\tchunk_size = %d\n", eaptls->chunk_size) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eaptls->random_file) { if (fprintf(fileid, "\t\trandom_file = \"%s\"\n", eaptls->random_file) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } retval = xsupconfwrite_write_tls_smartcard(fileid, eaptls); if (retval != XSUPCONFWRITE_ERRNONE) return retval; if (fprintf(fileid, "\t}\n\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } return XSUPCONFWRITE_ERRNONE;}/******************************************************************* * * Write the configuration information for WPA-PSK * *******************************************************************/int xsupconfwrite_wpa_psk(FILE *fileid, struct config_eap_method *cur){ struct config_wpa_psk *wpapsk; if (!fileid) {#ifdef DEBUG printf("Error : %s, at %s():%d!\n", xsupconfwrite_strerr(XSUPCONFWRITE_NOFILEHANDLE), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_NOFILEHANDLE; } if (!cur) {#ifdef DEBUG printf("Error : %s, at %s():%d!\n", xsupconfwrite_strerr(XSUPCONFWRITE_NOEAPDATA), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_NOEAPDATA; } wpapsk = (struct config_wpa_psk *)cur->method_data; if (!wpapsk) {#ifdef DEBUG printf("Error : The WPA-PSK structure was missing useful data!\n");#endif return XSUPCONFWRITE_NOEAPDATA; } if (fprintf(fileid, "\twpa-psk\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (fprintf(fileid, "\t{\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (wpapsk->key) { if (fprintf(fileid, "\t\tkey = \"%s\"\n", wpapsk->key) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (wpapsk->hex_key) { if (fprintf(fileid, "\t\thex_key = \"%s\"\n", wpapsk->hex_key) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (fprintf(fileid, "\t}\n\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } return XSUPCONFWRITE_ERRNONE;}/******************************************************************** * * This function is generic to both the static and initial wep methods. * Both use the AVPs, but need some slightly different calls for things * not included in this function. * ********************************************************************/int xsupconfwrite_write_wepkeys(FILE *fileid, struct config_static_wep *staticwep){ int i; if (!fileid) {#ifdef DEBUG printf("Error : %s, at %s():%d!\n", xsupconfwrite_strerr(XSUPCONFWRITE_NOFILEHANDLE), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_NOFILEHANDLE; } if (!staticwep) {#ifdef DEBUG printf("Error : The WEP structure was missing useful data!\n");#endif return XSUPCONFWRITE_NOEAPDATA; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -