📄 xsupconfig.c
字号:
return 0; tmp = method; while (tmp) { if (tmp->method_num == new_num) return 1; tmp = tmp->next; } return 0;} /*******************/ /* CONFIG_NETWORK *//*******************/void delete_config_single_network(struct config_network **tmp_network){ if (*tmp_network == NULL) return; FREE_STRING((*tmp_network)->name); FREE_STRING((*tmp_network)->ssid); FREE_STRING((*tmp_network)->identity); if ((*tmp_network)->initial_wep) delete_config_static_wep(&(*tmp_network)->initial_wep); if ((*tmp_network)->methods) delete_config_eap_method(&(*tmp_network)->methods); free ((*tmp_network)); (*tmp_network) = NULL;}void delete_config_network(struct config_network **tmp_network){ struct config_network *next, *cur; if (*tmp_network == NULL) return; cur = (*tmp_network); next = (*tmp_network)->next; while (cur) { delete_config_single_network(&cur); cur = next; if (next) { next = next->next; } } *tmp_network = NULL;}void initialize_config_network(struct config_network **tmp_network){ if (*tmp_network != NULL) { delete_config_network(tmp_network); } *tmp_network = (struct config_network *)malloc(sizeof(struct config_network)); if (*tmp_network) memset(*tmp_network, 0, sizeof(struct config_network)); (*tmp_network)->priority = DEFAULT_PRIORITY; SET_FLAG((*tmp_network)->flags, CONFIG_NET_USE_TNC);}int config_network_contains_net(struct config_network *net, char *netname){ while (net != NULL) { if (strcmp(net->name, netname) == 0) return TRUE; net = net->next; } return FALSE;}void config_network_add_net(struct config_network **list, struct config_network *toadd){ struct config_network **current = list; while (*current != NULL) { if (strcmp((*current)->name, toadd->name) == 0) { return; } current = &(*current)->next; } (*current) = toadd;}void dump_config_network_wpa(uint8_t crypt){ switch (crypt) { case CRYPT_WEP40: printf("WEP40\n"); return; case CRYPT_TKIP: printf("TKIP\n"); return; case CRYPT_WRAP: printf("WRAP\n"); return; case CRYPT_CCMP: printf("CCMP\n"); return; case CRYPT_WEP104: printf("WEP104\n"); return; default: printf("NONE\n"); return; }}void dump_config_network(struct config_network *net){ if (!net) return; printf("+-+-+-+-+ Network Name: \"%s\" +-+-+-+-+\n", net->name); if (net->initial_wep) dump_config_static_wep(net->initial_wep, TRUE); if (net->type == UNSET) printf(" Type: UNSET\n"); else if (net->type == WIRED) printf(" Type: WIRED\n"); else printf(" Type: WIRELESS\n"); switch (net->force_eapol_ver) { case 1: printf(" Forced EAPOL Version : 1\n"); break; case 2: printf(" Forced EAPOL Version : 2\n"); break; default: printf(" Forced EAPOL Version : Default\n"); break; } if (net->wireless_ctrl == CTL_UNSET) printf(" Wireless Control: UNSET\n"); else if (net->wireless_ctrl == CTL_YES) printf(" Wireless Control: YES\n"); else printf(" Wireless Control: NO\n"); printf(" WPA Group Crypt : "); dump_config_network_wpa(net->wpa_group_crypt); printf(" WPA Pairwise Crypt : "); dump_config_network_wpa(net->wpa_pairwise_crypt); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_WPA_PSK)) printf(" Allow Type: WPA-PSK\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_TLS)) printf(" Allow Type: TLS\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_MD5)) printf(" Allow Type: MD5\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_TTLS)) printf(" Allow Type: TTLS\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_LEAP)) printf(" Allow Type: LEAP\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_MSCV2)) printf(" Allow Type: MSCHAPv2\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_PEAP)) printf(" Allow Type: PEAP\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_SIM)) printf(" Allow Type: SIM\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_AKA)) printf(" Allow Type: AKA\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_GTC)) printf(" Allow Type: GTC\n"); if (TEST_FLAG(net->flags, CONFIG_NET_ALLOW_OTP)) printf(" Allow Type: OTP\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_WPA_PSK)) printf(" Prefer Type: WPA-PSK\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_TLS)) printf(" Prefer Type: TLS\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_MD5)) printf(" Prefer Type: MD5\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_TTLS)) printf(" Prefer Type: TTLS\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_LEAP)) printf(" Prefer Type: LEAP\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_MSCV2)) printf(" Prefer Type: MSCHAPv2\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_PEAP)) printf(" Prefer Type: PEAP\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_SIM)) printf(" Prefer Type: SIM\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_AKA)) printf(" Prefer Type: AKA\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_GTC)) printf(" Prefer Type: GTC\n"); if (TEST_FLAG(net->flags, CONFIG_NET_PREFER_OTP)) printf(" Prefer Type: OTP\n"); printf(" SSID: \"%s\"\n", net->ssid); printf(" Identity: \"%s\"\n", net->identity); if (TEST_FLAG(net->flags, CONFIG_NET_USE_TNC)) { printf(" Use TNC support : Yes\n"); } else { printf(" Use TNC support : No\n"); } if (TEST_FLAG(net->flags, CONFIG_NET_DEST_MAC)) printf(" DEST MAC: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", net->dest_mac[0], net->dest_mac[1], net->dest_mac[2], net->dest_mac[3], net->dest_mac[4], net->dest_mac[5]); dump_config_eap_method(net->methods, 0); if (net->next) dump_config_network(net->next); } /*****************************/ /* CONFIG_STRING_LIST *//*****************************/void delete_config_string_list(struct config_string_list **tmp_string_list){ if (*tmp_string_list == NULL) return; free (*tmp_string_list); *tmp_string_list = NULL;}void initialize_config_string_list(struct config_string_list **tmp_string_list){ if (*tmp_string_list != NULL) { delete_config_string_list(tmp_string_list); } *tmp_string_list = (struct config_string_list *)malloc(sizeof(struct config_string_list)); if (*tmp_string_list) memset(*tmp_string_list, 0, sizeof(struct config_string_list));}int config_string_list_contains_string(struct config_string_list *net_list, char *netname){ // if there is a list, we need to search for the net while (net_list != NULL) { if (strcmp(net_list->name, netname) == 0) return TRUE; net_list = net_list->next; } return FALSE;}void config_string_list_add_string(struct config_string_list **net_list, char *netname){ struct config_string_list **current = net_list; while (*current != NULL) { if (strcmp((*current)->name, netname) == 0) return; current = &(*current)->next; } initialize_config_string_list(current); (*current)->name = netname;}void dump_config_string_list(struct config_string_list *stringlist, char *title){ if (!stringlist) { return; } printf("%s: \"%s\"\n", title, stringlist->name); if (stringlist->next) dump_config_string_list(stringlist->next, title);} /*******************/ /* CONFIG_GLOBALS *//*******************/void delete_config_globals(struct config_globals **tmp_globals){ if (*tmp_globals == NULL) return; if ((*tmp_globals)->default_net) free((*tmp_globals)->default_net); if ((*tmp_globals)->allowed_nets) delete_config_string_list(&(*tmp_globals)->allowed_nets); FREE_STRING((*tmp_globals)->logfile); FREE_STRING((*tmp_globals)->ipc_group_name); FREE_STRING((*tmp_globals)->log_facility); FREE_STRING((*tmp_globals)->default_int); free (*tmp_globals); *tmp_globals = NULL;}void initialize_config_globals(struct config_globals **tmp_globals){ if (*tmp_globals != NULL) { delete_config_globals(tmp_globals); } *tmp_globals = (struct config_globals *)malloc(sizeof(struct config_globals)); if (*tmp_globals) memset(*tmp_globals, 0, sizeof(struct config_globals)); // We want to set allmulti to have a default of 1. SET_FLAG((*tmp_globals)->flags, CONFIG_GLOBALS_ALLMULTI); SET_FLAG((*tmp_globals)->flags, CONFIG_GLOBALS_FIRMWARE_ROAM); // Auto associate. (*tmp_globals)->flags |= CONFIG_GLOBALS_ASSOC_AUTO; // Passive scanning. XXX Removed for 1.2.4 release. // (*tmp_globals)->flags |= CONFIG_GLOBALS_PASSIVE_SCAN; (*tmp_globals)->stale_key_timeout = STALE_KEY_WARN_TIMEOUT; (*tmp_globals)->assoc_timeout = ASSOCIATION_TIMEOUT; (*tmp_globals)->passive_timeout = PASSIVE_TIMEOUT; (*tmp_globals)->active_timeout = RESCAN_TIMEOUT;}void dump_config_globals(struct config_globals *globals){ if (!globals) { printf("No Globals\n"); return; } printf("Default Net: \"%s\"\n", globals->default_net); if (globals->allowed_nets) dump_config_string_list(globals->allowed_nets, "Network Allowed"); else printf("Allowed Nets: ALL\n"); if (globals->logfile) printf("Logfile: '%s'\n", globals->logfile); if (globals->log_facility) printf("Log Facility: '%s'\n", globals->log_facility); if (globals->ipc_group_name) printf("IPC Group Name : '%s' \n", globals->ipc_group_name); if (globals->default_int) printf("Default Interface : '%s' \n", globals->default_int); if (TEST_FLAG(globals->flags, CONFIG_GLOBALS_AUTH_PER)) printf("Auth Period: %d\n", globals->auth_period); if (TEST_FLAG(globals->flags, CONFIG_GLOBALS_HELD_PER)) printf("Held Period: %d\n", globals->held_period); if (TEST_FLAG(globals->flags, CONFIG_GLOBALS_MAX_STARTS)) printf("Max Starts: %d\n", globals->max_starts); if (!TEST_FLAG(globals->flags, CONFIG_GLOBALS_NO_FRIENDLY_WARNINGS)) { printf("Friendly Warnings : Yes\n"); } else { printf("Friendly Warnings : No\n"); } if (TEST_FLAG(globals->flags, CONFIG_GLOBALS_ASSOC_AUTO)) { printf("Auto Association : Yes\n"); } else { printf("Auto Association : No\n"); } if (TEST_FLAG(globals->flags, CONFIG_GLOBALS_FIRMWARE_ROAM)) { printf("Roaming : Firmware\n"); } else { printf("Roaming : Xsupplicant\n"); } if (TEST_FLAG(globals->flags, CONFIG_GLOBALS_PASSIVE_SCAN)) { printf("Passive Scanning : Yes\n"); } else { printf("Passive Scanning : No\n"); } printf("Passive Scan Timeout : %d\n", globals->passive_timeout); printf("Association Timeout : %d\n", globals->assoc_timeout); if (TEST_FLAG(globals->flags, CONFIG_GLOBALS_ALLMULTI)) printf("ALLMULTI is enabled!\n"); else printf("ALLMULTI is disabled!\n"); printf("Destination: "); switch (globals->destination) { case DEST_AUTO: printf("Auto\n"); break; case DEST_BSSID: printf("BSSID\n"); break; case DEST_MULTICAST: printf("Multicast\n"); break; case DEST_SOURCE: printf("Source\n"); break; }} /*******************/ /* CONFIG_DATA *//*******************/void delete_config_data(struct config_data **tmp_data){ if (*tmp_data == NULL) return; if ((*tmp_data)->config_fname) free((*tmp_data)->config_fname); if ((*tmp_data)->globals) delete_config_globals(&(*tmp_data)->globals); if ((*tmp_data)->networks) delete_config_network(&(*tmp_data)->networks); free (*tmp_data); *tmp_data = NULL;}void initialize_config_data(struct config_data **tmp_data){ if (*tmp_data != NULL) { delete_config_data(tmp_data); } *tmp_data = (struct config_data *)malloc(sizeof(struct config_data)); if (*tmp_data) { memset(*tmp_data, 0, sizeof(struct config_data)); } else { printf("Couldn't allocate memory for configuration data!\n"); }}void dump_config_data(struct config_data *data){ if (!data) return; printf("=-=-=-=-=-=-=-=-=-=-=-=-=\n"); printf("Configuration File: %s\n", data->config_fname); dump_config_globals(data->globals); dump_config_network(data->networks); printf("=-=-=-=-=-=-=-=-=-=-=-=-=\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -