📄 xsupconfwrite.c
字号:
#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; }/******************************************************************** * * Write the configuration information for EAP-AKA * ********************************************************************/int xsupconfwrite_eap_aka(FILE *fileid, struct config_eap_method *cur, int phase){ struct config_eap_aka *eapaka; 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; } eapaka = (struct config_eap_aka *)cur->method_data; if (!eapaka) {#ifdef DEBUG printf("The EAP-AKA structure is NULL!\n");#endif return XSUPCONFWRITE_NOEAPDATA; } if (phase ==2) { if (fprintf(fileid, "\t") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (fprintf(fileid, "\teap-aka\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (phase ==2) { if (fprintf(fileid, "\t") < 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 (eapaka->username) { if (phase ==2) { if (fprintf(fileid, "\t") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (fprintf(fileid, "\t\tusername = \"%s\"\n", eapaka->username) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapaka->password) { if (phase ==2) { if (fprintf(fileid, "\t") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (fprintf(fileid, "\t\tpassword = \"%s\"\n", eapaka->password) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (eapaka->auto_realm == TRUE) { if (phase ==2) { if (fprintf(fileid, "\t") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (fprintf(fileid, "\t\tauto_realm = true\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (phase ==2) { if (fprintf(fileid, "\t") < 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; }/******************************************************************* * * Write phase 2 data for PAP * *******************************************************************/int xsupconfwrite_ttls_phase2_pap(FILE *fileid, void *cur){ struct config_pap *pap; 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_BADTTLSPHASE2), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_BADTTLSPHASE2; } pap = (struct config_pap *)cur; if (!pap) return XSUPCONFWRITE_BADTTLSPHASE2; if (fprintf(fileid, "\t\tpap\n\t\t{\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (pap->username) { if (fprintf(fileid, "\t\t\tusername = \"%s\"\n", pap->username) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (pap->password) { if (fprintf(fileid, "\t\t\tpassword = \"%s\"\n", pap->password) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (fprintf(fileid, "\t\t}\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } return XSUPCONFWRITE_ERRNONE;}/****************************************************************** * * Write phase 2 data for CHAP. * ******************************************************************/int xsupconfwrite_ttls_phase2_chap(FILE *fileid, void *cur){ struct config_chap *chap; 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_BADTTLSPHASE2), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_BADTTLSPHASE2; } chap = (struct config_chap *)cur; if (!chap) return XSUPCONFWRITE_BADTTLSPHASE2; if (fprintf(fileid, "\t\tchap\n\t\t{\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (chap->username) { if (fprintf(fileid, "\t\t\tusername = \"%s\"\n", chap->username) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (chap->password) { if (fprintf(fileid, "\t\t\tpassword = \"%s\"\n", chap->password) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (fprintf(fileid, "\t\t}\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } return XSUPCONFWRITE_ERRNONE;}/****************************************************************** * * Write phase 2 data for MS-CHAP * ******************************************************************/int xsupconfwrite_ttls_phase2_mschap(FILE *fileid, void *cur){ struct config_mschap *mschap; 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_BADTTLSPHASE2), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_BADTTLSPHASE2; } mschap = (struct config_mschap *)cur; if (!mschap) return XSUPCONFWRITE_BADTTLSPHASE2; if (fprintf(fileid, "\t\tmschap\n\t\t{\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (mschap->username) { if (fprintf(fileid, "\t\t\tusername = \"%s\"\n", mschap->username) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (mschap->password) { if (fprintf(fileid, "\t\t\tpassword = \"%s\"\n", mschap->password) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (fprintf(fileid, "\t\t}\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } return XSUPCONFWRITE_ERRNONE;}/***************************************************************** * * Write phase 2 data for MS-CHAPv2 * *****************************************************************/int xsupconfwrite_ttls_phase2_mschapv2(FILE *fileid, void *cur){ struct config_mschapv2 *mschapv2; 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_BADTTLSPHASE2), __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_BADTTLSPHASE2; } mschapv2 = (struct config_mschapv2 *)cur; if (!mschapv2) return XSUPCONFWRITE_BADTTLSPHASE2; if (fprintf(fileid, "\t\tmschapv2\n\t\t{\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } if (mschapv2->username) { if (fprintf(fileid, "\t\t\tusername = \"%s\"\n", mschapv2->username) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (mschapv2->password) { if (fprintf(fileid, "\t\t\tpassword = \"%s\"\n", mschapv2->password) < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } } if (fprintf(fileid, "\t\t}\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } return XSUPCONFWRITE_ERRNONE;}/******************************************************************* * * Write the phase 2 configuration for EAP-TTLS * *******************************************************************/int xsupconfwrite_eap_ttls_phase2(FILE *fileid, struct config_eap_ttls *cur){ struct config_ttls_phase2 *p2type; struct config_eap_method data; 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; } switch (cur->phase2_type) { case TTLS_PHASE2_PAP: if (fprintf(fileid, "\t\tphase2_type = pap\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } break; case TTLS_PHASE2_CHAP: if (fprintf(fileid, "\t\tphase2_type = chap\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } break; case TTLS_PHASE2_MSCHAP: if (fprintf(fileid, "\t\tphase2_type = mschap\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; } break; case TTLS_PHASE2_MSCHAPV2: if (fprintf(fileid, "\t\tphase2_type = mschapv2\n") < 0) {#ifdef DEBUG printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif return XSUPCONFWRITE_GENIOERR; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -