📄 xsupconfig.c
字号:
*tmp_static_wep = (struct config_static_wep *)malloc(sizeof(struct config_static_wep)); if (*tmp_static_wep) memset(*tmp_static_wep, 0, sizeof(struct config_static_wep));}void dump_config_static_wep(struct config_static_wep *tmp_static_wep, int initial){ int i; if (!tmp_static_wep) return; if (initial) { printf("\t------------initial wep-------------\n"); } else { printf("\t-------------static-wep-------------\n"); } printf("\t TX Key : %d\n", tmp_static_wep->tx_key); for (i=1;i<5;i++) { if (tmp_static_wep->key[i]) printf("\t Static Key %d : %s\n", i, tmp_static_wep->key[i]); } printf("\t------------------------------------\n");} /*******************/ /* CONFIG_WPA_PSK *//*******************/void delete_config_wpa_psk(struct config_wpa_psk **tmp_wpa_psk){ if (*tmp_wpa_psk == NULL) return; FREE_STRING((*tmp_wpa_psk)->key); FREE_STRING((*tmp_wpa_psk)->hex_key); free(*tmp_wpa_psk); *tmp_wpa_psk = NULL;}void initialize_config_wpa_psk(struct config_wpa_psk **tmp_wpa_psk){ if (*tmp_wpa_psk != NULL) { delete_config_wpa_psk(tmp_wpa_psk); } *tmp_wpa_psk = (struct config_wpa_psk *)malloc(sizeof(struct config_wpa_psk)); if (*tmp_wpa_psk) memset(*tmp_wpa_psk, 0, sizeof(struct config_wpa_psk));}void dump_config_wpa_psk(struct config_wpa_psk *tmp_wpa_psk){ if (!tmp_wpa_psk) return; printf("\t---------------wpa-psk--------------\n"); printf("\t ASCII key: \"%s\"\n", tmp_wpa_psk->key); printf("\t HEX key: \"%s\"\n", tmp_wpa_psk->hex_key); printf("\t------------------------------------\n");} /*******************/ /* CONFIG_TLS *//*******************//* take a pointer to a config_eap_tls and cleanly delete the structure then make it NULL */void delete_config_eap_tls(struct config_eap_tls **tmp_tls){ if (*tmp_tls == NULL) return; FREE_STRING((*tmp_tls)->user_cert); FREE_STRING((*tmp_tls)->root_cert); FREE_STRING((*tmp_tls)->root_dir); FREE_STRING((*tmp_tls)->crl_dir); FREE_STRING((*tmp_tls)->user_key); FREE_STRING((*tmp_tls)->user_key_pass); FREE_STRING((*tmp_tls)->random_file); FREE_STRING((*tmp_tls)->sc.engine_id); FREE_STRING((*tmp_tls)->sc.opensc_so_path); FREE_STRING((*tmp_tls)->sc.key_id); free (*tmp_tls); *tmp_tls = NULL;}/* take a pointer to a config_eap_tls and put a blank one there */void initialize_config_eap_tls(struct config_eap_tls **tmp_tls){ if (*tmp_tls != NULL) { delete_config_eap_tls(tmp_tls); } *tmp_tls = (struct config_eap_tls *)malloc(sizeof(struct config_eap_tls)); if (*tmp_tls) { memset(*tmp_tls, 0, sizeof(struct config_eap_tls)); bzero(&(*tmp_tls)->sc, sizeof((*tmp_tls)->sc)); }}void dump_config_eap_tls(struct config_eap_tls *tls){ if (!tls) return; printf("\t---------------eap-tls--------------\n"); printf("\t TLS Cert: \"%s\"\n", tls->user_cert); printf("\t TLS Root Cert: \"%s\"\n", tls->root_cert); printf("\t TLS Root Dir: \"%s\"\n", tls->root_dir); printf("\t TLS CRL Dir: \"%s\"\n", tls->crl_dir); printf("\t TLS Key: \"%s\"\n", tls->user_key); printf("\t TLS Key Pass: \"%s\"\n", tls->user_key_pass); printf("\t TLS Chunk Size: %d\n", tls->chunk_size); printf("\t TLS Random Source: \"%s\"\n", tls->random_file); printf("\t TLS Session Resumption: "); switch (tls->session_resume) { case RES_UNSET: printf("UNSET\n"); break; case RES_YES: printf("YES\n"); break; case RES_NO: printf("NO\n"); break; } printf("\t Using Smartcard:\n"); printf("\t\tEngine : \"%s\"\n", tls->sc.engine_id); printf("\t\tOpensc SO_PATH: \"%s\"\n", tls->sc.opensc_so_path); printf("\t\tKey ID : \"%s\"\n", tls->sc.key_id); //printf("\t\tCertificate ID: \"%s\"", tls.sc->cert_id); //printf("\t\tRoot Cert ID : \"%s\"", tls.sc->root_id); printf("\t------------------------------------\n");} /*******************/ /* CONFIG_MD5 *//*******************/void delete_config_eap_md5(struct config_eap_md5 **tmp_md5){ if (*tmp_md5 == NULL) return; FREE_STRING((*tmp_md5)->username); FREE_STRING((*tmp_md5)->password); free (*tmp_md5); *tmp_md5 = NULL;}void initialize_config_eap_md5(struct config_eap_md5 **tmp_md5){ if (*tmp_md5 != NULL) { delete_config_eap_md5(tmp_md5); } *tmp_md5 = (struct config_eap_md5 *)malloc(sizeof(struct config_eap_md5)); if (*tmp_md5) memset(*tmp_md5, 0, sizeof(struct config_eap_md5));}void dump_config_eap_md5(struct config_eap_md5 *md5, int level){ if (!md5) return; if (level == 0) { printf("\t---------------eap-md5--------------\n"); printf("\t MD5 User: \"%s\"\n", md5->username); printf("\t MD5 Pass: \"%s\"\n", md5->password); printf("\t------------------------------------\n"); }else { printf("\t\t^ ^ ^ eap-md5 ^ ^ ^\n"); printf("\t\t MD5 User: \"%s\"\n", md5->username); printf("\t\t MD5 Pass: \"%s\"\n", md5->password); printf("\t\t^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^\n"); } } /*******************/ /* CONFIG_TTLS *//*******************///--------// PAP//--------void delete_config_pap(struct config_pap **tmp_pap){ if (*tmp_pap == NULL) return; FREE_STRING((*tmp_pap)->username); FREE_STRING((*tmp_pap)->password); free (*tmp_pap); *tmp_pap = NULL;}void initialize_config_pap(struct config_pap **tmp_pap){ if (*tmp_pap != NULL) { delete_config_pap(tmp_pap); } *tmp_pap = (struct config_pap *)malloc(sizeof(struct config_pap)); if (*tmp_pap) memset(*tmp_pap, 0, sizeof(struct config_pap));}void dump_config_pap(struct config_pap *pap){ if (!pap) return; printf("\t\t^ ^ ^ pap ^ ^ ^\n"); printf("\t\t PAP User: \"%s\"\n", pap->username); printf("\t\t PAP Pass: \"%s\"\n", pap->password); printf("\t\t^ ^ ^ ^ ^ ^ ^ ^ ^\n");}//--------// CHAP//--------void delete_config_chap(struct config_chap **tmp_chap){ if (*tmp_chap == NULL) return; FREE_STRING((*tmp_chap)->username); FREE_STRING((*tmp_chap)->password); free (*tmp_chap); *tmp_chap = NULL;}void initialize_config_chap(struct config_chap **tmp_chap){ if (*tmp_chap != NULL) { delete_config_chap(tmp_chap); } *tmp_chap = (struct config_chap *)malloc(sizeof(struct config_chap)); if (*tmp_chap) memset(*tmp_chap, 0, sizeof(struct config_chap));}void dump_config_chap(struct config_chap *chap){ if (!chap) return; printf("\t\t^ ^ ^ chap ^ ^ ^\n"); printf("\t\t CHAP User: \"%s\"\n", chap->username); printf("\t\t CHAP Pass: \"%s\"\n", chap->password); printf("\t\t^ ^ ^ ^ ^ ^ ^ ^ ^\n");}//--------// MSCHAP//--------void delete_config_mschap(struct config_mschap **tmp_mschap){ if (*tmp_mschap == NULL) return; FREE_STRING((*tmp_mschap)->username); FREE_STRING((*tmp_mschap)->password); free (*tmp_mschap); *tmp_mschap = NULL;}void initialize_config_mschap(struct config_mschap **tmp_mschap){ if (*tmp_mschap != NULL) { delete_config_mschap(tmp_mschap); } *tmp_mschap = (struct config_mschap *)malloc(sizeof(struct config_mschap)); if (*tmp_mschap) memset(*tmp_mschap, 0, sizeof(struct config_mschap));}void dump_config_mschap(struct config_mschap *mschap){ if (!mschap) return; printf("\t\t^ ^ ^ mschap ^ ^ ^\n"); printf("\t\t MSCHAP User: \"%s\"\n", mschap->username); printf("\t\t MSCHAP Pass: \"%s\"\n", mschap->password); printf("\t\t^ ^ ^ ^ ^ ^ ^ ^ ^\n");}//--------// MSCHAPV2//--------void delete_config_mschapv2(struct config_mschapv2 **tmp_mschapv2){ if (*tmp_mschapv2 == NULL) return; FREE_STRING((*tmp_mschapv2)->username); FREE_STRING((*tmp_mschapv2)->password); free (*tmp_mschapv2); *tmp_mschapv2 = NULL;}void initialize_config_mschapv2(struct config_mschapv2 **tmp_mschapv2){ if (*tmp_mschapv2 != NULL) { delete_config_mschapv2(tmp_mschapv2); } *tmp_mschapv2 = (struct config_mschapv2 *)malloc(sizeof(struct config_mschapv2)); if (*tmp_mschapv2) memset(*tmp_mschapv2, 0, sizeof(struct config_mschapv2));}void dump_config_mschapv2(struct config_mschapv2 *mschapv2){ if (!mschapv2) return; printf("\t\t^ ^ ^ mschapv2 ^ ^ ^\n"); printf("\t\t MSCHAPv2 User : \"%s\"\n", mschapv2->username); printf("\t\t MSCHAPv2 Pass : \"%s\"\n", mschapv2->password); printf("\t\t^ ^ ^ ^ ^ ^ ^ ^ ^\n");}//-------------// TTLS_PHASE2//------------// Be SURE to call config_ttls_phase2_contains_phase2 BEFORE adding.// no such check will be done here.void add_config_ttls_phase2(struct config_ttls_phase2 **phase2, ttls_phase2_type phase2_type, void *phase2_data){ struct config_ttls_phase2 *tmp, *newphase2; if (!phase2_data) return; newphase2 = (struct config_ttls_phase2 *)malloc(sizeof(struct config_ttls_phase2)); if (newphase2 == NULL) return; memset(newphase2, 0, sizeof(struct config_ttls_phase2)); newphase2->phase2_type = phase2_type; newphase2->phase2_data = phase2_data; if (*phase2 == NULL) { *phase2 = newphase2; return; } tmp = *phase2; while (tmp->next != NULL) { tmp = tmp->next; } tmp->next = newphase2;}int config_ttls_phase2_contains_phase2(struct config_ttls_phase2 *phase2, ttls_phase2_type new_type){ struct config_ttls_phase2 *tmp; if (!phase2) return 0; tmp = phase2; while (tmp) { if (tmp->phase2_type == new_type) return 1; tmp = tmp->next; } return 0;}void delete_config_ttls_phase2 (struct config_ttls_phase2 **phase2){ struct config_ttls_phase2 *temp; if (*phase2 == NULL) return; switch ((*phase2)->phase2_type) { case TTLS_PHASE2_PAP: delete_config_pap((struct config_pap **)&(*phase2)->phase2_data); break; case TTLS_PHASE2_CHAP: delete_config_chap((struct config_chap **)&(*phase2)->phase2_data); break; case TTLS_PHASE2_MSCHAP: delete_config_mschap((struct config_mschap **)&(*phase2)->phase2_data); break; case TTLS_PHASE2_MSCHAPV2: delete_config_mschapv2((struct config_mschapv2 **)&(*phase2)->phase2_data); break; case TTLS_PHASE2_EAP_MD5: delete_config_eap_md5((struct config_eap_md5 **)&(*phase2)->phase2_data); break; default: printf("AAAH! Trying to delete an undefined config" " type.\nNotify developers. Type: 0x%x\n", (*phase2)->phase2_type); } temp = (*phase2)->next; free((*phase2)); if (temp) delete_config_ttls_phase2(&temp);}void dump_config_ttls_phase2(struct config_ttls_phase2 *phase2) { if (phase2 == NULL) return; switch ((phase2)->phase2_type) { case TTLS_PHASE2_PAP: dump_config_pap((struct config_pap *)(phase2)->phase2_data); break; case TTLS_PHASE2_CHAP: dump_config_chap((struct config_chap *)(phase2)->phase2_data); break; case TTLS_PHASE2_MSCHAP: dump_config_mschap((struct config_mschap *)(phase2)->phase2_data); break; case TTLS_PHASE2_MSCHAPV2: dump_config_mschapv2((struct config_mschapv2 *)(phase2)->phase2_data); break; case TTLS_PHASE2_EAP_MD5: dump_config_eap_md5((struct config_eap_md5 *)(phase2)->phase2_data, 1); break; default: printf("AAAH! Trying to dump an undefined config" " type.\nNotify developers. Type: 0x%x\n", (phase2)->phase2_type); } if ((phase2)->next) dump_config_ttls_phase2((phase2)->next);}void delete_config_eap_ttls(struct config_eap_ttls **tmp_ttls){ if (*tmp_ttls == NULL) return; FREE_STRING((*tmp_ttls)->user_cert); FREE_STRING((*tmp_ttls)->root_cert); FREE_STRING((*tmp_ttls)->root_dir); FREE_STRING((*tmp_ttls)->crl_dir); FREE_STRING((*tmp_ttls)->user_key); FREE_STRING((*tmp_ttls)->user_key_pass); FREE_STRING((*tmp_ttls)->random_file); FREE_STRING((*tmp_ttls)->cncheck); if ((*tmp_ttls)->phase2) delete_config_ttls_phase2(&(*tmp_ttls)->phase2); free (*tmp_ttls); *tmp_ttls = NULL;}void initialize_config_eap_ttls(struct config_eap_ttls **tmp_ttls){ if (*tmp_ttls != NULL) { delete_config_eap_ttls(tmp_ttls); } *tmp_ttls = (struct config_eap_ttls *)malloc(sizeof(struct config_eap_ttls)); if (*tmp_ttls == NULL) return; memset(*tmp_ttls, 0, sizeof(struct config_eap_ttls)); (*tmp_ttls)->phase2_type = TTLS_PHASE2_UNDEFINED;}void dump_config_eap_ttls(struct config_eap_ttls *ttls)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -