JNIEXPORT void JNICALL Java_cn_edu_hust_buildingtalkback_jni_NativeInterface_stopNetwork( JNIEnv *env, jclass clazz) { LOG_FUNC(); stop_network(); }
bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/) { switch(command) { case HOTKEY_CYCLE_UNITS: cycle_units(); break; case HOTKEY_CYCLE_BACK_UNITS: cycle_back_units(); break; case HOTKEY_ENDTURN: end_turn(); break; case HOTKEY_UNIT_HOLD_POSITION: unit_hold_position(); break; case HOTKEY_END_UNIT_TURN: end_unit_turn(); break; case HOTKEY_LEADER: goto_leader(); break; case HOTKEY_UNDO: undo(); break; case HOTKEY_REDO: redo(); break; case HOTKEY_UNIT_DESCRIPTION: unit_description(); break; case HOTKEY_RENAME_UNIT: rename_unit(); break; case HOTKEY_SAVE_GAME: save_game(); break; case HOTKEY_SAVE_REPLAY: save_replay(); break; case HOTKEY_SAVE_MAP: save_map(); break; case HOTKEY_LOAD_GAME: load_game(); break; case HOTKEY_TOGGLE_ELLIPSES: toggle_ellipses(); break; case HOTKEY_TOGGLE_GRID: toggle_grid(); break; case HOTKEY_STATUS_TABLE: status_table(); break; case HOTKEY_RECALL: recall(); break; case HOTKEY_RECRUIT: recruit(); break; case hotkey::HOTKEY_REPEAT_RECRUIT: repeat_recruit(); break; case HOTKEY_SPEAK: speak(); break; case HOTKEY_SPEAK_ALLY: whisper(); break; case HOTKEY_SPEAK_ALL: shout(); break; case HOTKEY_CREATE_UNIT: create_unit(); break; case HOTKEY_CHANGE_SIDE: change_side(); break; case HOTKEY_PREFERENCES: preferences(); break; case HOTKEY_OBJECTIVES: objectives(); break; case HOTKEY_UNIT_LIST: unit_list(); break; case HOTKEY_STATISTICS: show_statistics(); break; case HOTKEY_STOP_NETWORK: stop_network(); break; case HOTKEY_START_NETWORK: start_network(); break; case HOTKEY_LABEL_TEAM_TERRAIN: label_terrain(true); break; case HOTKEY_LABEL_TERRAIN: label_terrain(false); break; case HOTKEY_CLEAR_LABELS: clear_labels(); break; case HOTKEY_SHOW_ENEMY_MOVES: show_enemy_moves(false); break; case HOTKEY_BEST_ENEMY_MOVES: show_enemy_moves(true); break; case HOTKEY_DELAY_SHROUD: toggle_shroud_updates(); break; case HOTKEY_UPDATE_SHROUD: update_shroud_now(); break; case HOTKEY_CONTINUE_MOVE: continue_move(); break; case HOTKEY_SEARCH: search(); break; case HOTKEY_HELP: show_help(); break; case HOTKEY_CHAT_LOG: show_chat_log(); break; case HOTKEY_USER_CMD: user_command(); break; case HOTKEY_CUSTOM_CMD: custom_command(); break; case HOTKEY_AI_FORMULA: ai_formula(); break; case HOTKEY_CLEAR_MSG: clear_messages(); break; case HOTKEY_LANGUAGE: change_language(); break; case HOTKEY_PLAY_REPLAY: play_replay(); break; case HOTKEY_RESET_REPLAY: reset_replay(); break; case HOTKEY_STOP_REPLAY: stop_replay(); break; case HOTKEY_REPLAY_NEXT_TURN: replay_next_turn(); break; case HOTKEY_REPLAY_NEXT_SIDE: replay_next_side(); break; case HOTKEY_REPLAY_SHOW_EVERYTHING: replay_show_everything(); break; case HOTKEY_REPLAY_SHOW_EACH: replay_show_each(); break; case HOTKEY_REPLAY_SHOW_TEAM1: replay_show_team1(); break; case HOTKEY_REPLAY_SKIP_ANIMATION: replay_skip_animation(); break; case HOTKEY_WB_TOGGLE: whiteboard_toggle(); break; case HOTKEY_WB_EXECUTE_ACTION: whiteboard_execute_action(); break; case HOTKEY_WB_EXECUTE_ALL_ACTIONS: whiteboard_execute_all_actions(); break; case HOTKEY_WB_DELETE_ACTION: whiteboard_delete_action(); break; case HOTKEY_WB_BUMP_UP_ACTION: whiteboard_bump_up_action(); break; case HOTKEY_WB_BUMP_DOWN_ACTION: whiteboard_bump_down_action(); break; case HOTKEY_WB_SUPPOSE_DEAD: whiteboard_suppose_dead(); break; case HOTKEY_LEFT_MOUSE_CLICK: left_mouse_click(); break; case HOTKEY_RIGHT_MOUSE_CLICK: right_mouse_click(); break; default: return false; } return true; }
bool command_executor::execute_command(const hotkey_command& cmd, int /*index*/, bool press) { // hotkey release handling if (!press) { switch(cmd.id) { // release a scroll key, un-apply scrolling in the given direction case HOTKEY_SCROLL_UP: scroll_up(false); break; case HOTKEY_SCROLL_DOWN: scroll_down(false); break; case HOTKEY_SCROLL_LEFT: scroll_left(false); break; case HOTKEY_SCROLL_RIGHT: scroll_right(false); break; default: return false; // nothing else handles a hotkey release } return true; } // hotkey press handling switch(cmd.id) { case HOTKEY_SCROLL_UP: scroll_up(true); break; case HOTKEY_SCROLL_DOWN: scroll_down(true); break; case HOTKEY_SCROLL_LEFT: scroll_left(true); break; case HOTKEY_SCROLL_RIGHT: scroll_right(true); break; case HOTKEY_CYCLE_UNITS: cycle_units(); break; case HOTKEY_CYCLE_BACK_UNITS: cycle_back_units(); break; case HOTKEY_ENDTURN: end_turn(); break; case HOTKEY_UNIT_HOLD_POSITION: unit_hold_position(); break; case HOTKEY_END_UNIT_TURN: end_unit_turn(); break; case HOTKEY_LEADER: goto_leader(); break; case HOTKEY_UNDO: undo(); break; case HOTKEY_REDO: redo(); break; case HOTKEY_TERRAIN_DESCRIPTION: terrain_description(); break; case HOTKEY_UNIT_DESCRIPTION: unit_description(); break; case HOTKEY_RENAME_UNIT: rename_unit(); break; case HOTKEY_SAVE_GAME: save_game(); break; case HOTKEY_SAVE_REPLAY: save_replay(); break; case HOTKEY_SAVE_MAP: save_map(); break; case HOTKEY_LOAD_GAME: load_game(); break; case HOTKEY_TOGGLE_ELLIPSES: toggle_ellipses(); break; case HOTKEY_TOGGLE_GRID: toggle_grid(); break; case HOTKEY_STATUS_TABLE: status_table(); break; case HOTKEY_RECALL: recall(); break; case HOTKEY_LABEL_SETTINGS: label_settings(); break; case HOTKEY_RECRUIT: recruit(); break; case hotkey::HOTKEY_REPEAT_RECRUIT: repeat_recruit(); break; case HOTKEY_SPEAK: speak(); break; case HOTKEY_SPEAK_ALLY: whisper(); break; case HOTKEY_SPEAK_ALL: shout(); break; case HOTKEY_CREATE_UNIT: create_unit(); break; case HOTKEY_CHANGE_SIDE: change_side(); break; case HOTKEY_KILL_UNIT: kill_unit(); break; case HOTKEY_PREFERENCES: preferences(); break; case HOTKEY_OBJECTIVES: objectives(); break; case HOTKEY_UNIT_LIST: unit_list(); break; case HOTKEY_STATISTICS: show_statistics(); break; case HOTKEY_STOP_NETWORK: stop_network(); break; case HOTKEY_START_NETWORK: start_network(); break; case HOTKEY_LABEL_TEAM_TERRAIN: label_terrain(true); break; case HOTKEY_LABEL_TERRAIN: label_terrain(false); break; case HOTKEY_CLEAR_LABELS: clear_labels(); break; case HOTKEY_SHOW_ENEMY_MOVES: show_enemy_moves(false); break; case HOTKEY_BEST_ENEMY_MOVES: show_enemy_moves(true); break; case HOTKEY_DELAY_SHROUD: toggle_shroud_updates(); break; case HOTKEY_UPDATE_SHROUD: update_shroud_now(); break; case HOTKEY_CONTINUE_MOVE: continue_move(); break; case HOTKEY_SEARCH: search(); break; case HOTKEY_HELP: show_help(); break; case HOTKEY_CHAT_LOG: show_chat_log(); break; case HOTKEY_USER_CMD: user_command(); break; case HOTKEY_CUSTOM_CMD: custom_command(); break; case HOTKEY_AI_FORMULA: ai_formula(); break; case HOTKEY_CLEAR_MSG: clear_messages(); break; case HOTKEY_LANGUAGE: change_language(); break; case HOTKEY_REPLAY_PLAY: play_replay(); break; case HOTKEY_REPLAY_RESET: reset_replay(); break; case HOTKEY_REPLAY_STOP: stop_replay(); break; case HOTKEY_REPLAY_NEXT_TURN: replay_next_turn(); break; case HOTKEY_REPLAY_NEXT_SIDE: replay_next_side(); break; case HOTKEY_REPLAY_NEXT_MOVE: replay_next_move(); break; case HOTKEY_REPLAY_SHOW_EVERYTHING: replay_show_everything(); break; case HOTKEY_REPLAY_SHOW_EACH: replay_show_each(); break; case HOTKEY_REPLAY_SHOW_TEAM1: replay_show_team1(); break; case HOTKEY_REPLAY_SKIP_ANIMATION: replay_skip_animation(); break; case HOTKEY_REPLAY_EXIT: replay_exit(); break; case HOTKEY_WB_TOGGLE: whiteboard_toggle(); break; case HOTKEY_WB_EXECUTE_ACTION: whiteboard_execute_action(); break; case HOTKEY_WB_EXECUTE_ALL_ACTIONS: whiteboard_execute_all_actions(); break; case HOTKEY_WB_DELETE_ACTION: whiteboard_delete_action(); break; case HOTKEY_WB_BUMP_UP_ACTION: whiteboard_bump_up_action(); break; case HOTKEY_WB_BUMP_DOWN_ACTION: whiteboard_bump_down_action(); break; case HOTKEY_WB_SUPPOSE_DEAD: whiteboard_suppose_dead(); break; case HOTKEY_SELECT_HEX: select_hex(); break; case HOTKEY_DESELECT_HEX: deselect_hex(); break; case HOTKEY_MOVE_ACTION: move_action(); break; case HOTKEY_SELECT_AND_ACTION: select_and_action(); break; case HOTKEY_ACCELERATED: toggle_accelerated_speed(); break; case LUA_CONSOLE: lua_console(); break; case HOTKEY_ZOOM_IN: zoom_in(); break; case HOTKEY_ZOOM_OUT: zoom_out(); break; case HOTKEY_ZOOM_DEFAULT: zoom_default(); break; case HOTKEY_MAP_SCREENSHOT: map_screenshot(); break; case HOTKEY_QUIT_TO_DESKTOP: quit_confirmation::quit_to_desktop(); break; case HOTKEY_QUIT_GAME: quit_confirmation::quit_to_title(); break; default: return false; } return true; }
/* this functione tryes to interpret what we have read from the config file and makes the changes to the global variables if possible */ void change_config (struct name_value *config_values) { int result, ret; unsigned int conv; struct name_value *config_list, *csv_list, *this_name_value; struct fcp_address_list *this_address_list, *tmp; config_list = config_values; fcp_log (LOG_DEBUG, "CONFIGURE: begin of changing configuration"); while (config_list->name != NULL) { /* what parameter was read */ result = compare_to_def (config_list->name); if (result) { /* if it was a correct spelled parameter switch to point where we scan the value and make the changes */ switch (result) { case argument_PORT: conv = atol (config_list->value); if ((conv > 65535) || (conv < 1)) { sprintf (debug_msg_helper, "CONFIGURE: error port %i out of range", conv); fcp_log (LOG_ERR, debug_msg_helper); conv = FCP_DEFAULT_PORT; sprintf (debug_msg_helper, "CONFIGURE: using standard port %i instead", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { sprintf (debug_msg_helper, "CONFIGURE: using port %i", conv); fcp_log (LOG_DEBUG, debug_msg_helper); } if (conv != fcp_port) { /* the listening port have changed so we stop our network (all connections are getting lost) and restart it with the new port */ stop_network(); fcp_port = conv; init_network(); fcp_log (LOG_DEBUG, "CONFIGURE: network restartet with new port"); } break; case argument_DEBUGLEVEL: conv = atoi (config_list->value); if ((conv > 7) || (conv < 0)) { sprintf (debug_msg_helper, "CONFIGURE: error debuglevel %i out of range", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { if (fcp_loglevel_override) conv = fcp_loglevel; /* was specified on command line */ sprintf (debug_msg_helper, "CONFIGURE: using debuglevel %i", conv); fcp_log (LOG_INFO, debug_msg_helper); if (conv != fcp_loglevel) /* change our loglevel to the new value */ fcp_loglevel = conv; } break; case argument_ACL: sprintf (debug_msg_helper, "CONFIGURE: access restricted to %s.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Seperate the string by the commas */ csv_list = (struct name_value *) scan_csv (config_list->value); if (csv_list) { /* First of all free the existing acl_list. */ this_address_list = fcp_acl_list.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } /* Convert the strings into IPs and netmasks and put them into the acl_list. */ this_name_value = csv_list; fcp_acl_list.next = malloc (sizeof (struct fcp_address_list)); this_address_list = fcp_acl_list.next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in ACL isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in ACL isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in ACL isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; /* The first element is now in the list, now do the same for the rest. */ while (this_name_value) { this_address_list->next = malloc (sizeof (struct fcp_address_list)); this_address_list = this_address_list->next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in ACL isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in ACL isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in ACL isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; } /* Everything is in the acl_list now freeing the name_value_list where the strings were in. */ while (csv_list) { this_name_value = csv_list->next; free (csv_list->name); free (csv_list); csv_list = this_name_value; } } else { fcp_log (LOG_ERR, "CONFIGURE: ACL couldn't be converted"); /* Free the existing acl_list if exists. */ if (fcp_acl_list.next) { this_address_list = fcp_acl_list.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } fcp_acl_list.next = NULL; } } break; case argument_INTFIN: if (strlen (config_list->value) > 0) { sprintf (debug_msg_helper, "CONFIGURE: in interface %s found.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Freeing the old interface if specified, alloc and copy the new value. More then one interface is NOT supported yet. */ if (fcp_in_interface.name) free (fcp_in_interface.name); fcp_in_interface.name = malloc (sizeof (config_list->value)); strcpy (fcp_in_interface.name, config_list->value); } break; case argument_INTFOUT: if (strlen (config_list->value) > 0) { sprintf (debug_msg_helper, "CONFIGURE: out interface %s found.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Freeing the old interface if specified, alloc and copy the new value. More then one interface is NOT supported yet. */ if (fcp_out_interface.name) free (fcp_out_interface.name); fcp_out_interface.name = malloc (sizeof (config_list->value)); strcpy (fcp_out_interface.name, config_list->value); } break; case argument_INTFDMZ: if (strlen (config_list->value) > 0) { sprintf (debug_msg_helper, "CONFIGURE: dmz interface %s found.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Freeing the old interface if specified, alloc and copy the new value. More then one interface is NOT supported yet. */ if (fcp_dmz_interface.name) free (fcp_dmz_interface.name); fcp_dmz_interface.name = malloc (sizeof (config_list->value)); strcpy (fcp_dmz_interface.name, config_list->value); } break; case argument_TIMEOUT: conv = atoi (config_list->value); if ((conv > FCP_MAX_TIMEOUT) || (conv < 0)) { sprintf (debug_msg_helper, "CONFIGURE: the timeout value %i is grater then the" " maximum %i or less 0", conv, FCP_MAX_TIMEOUT); fcp_log (LOG_ERR, debug_msg_helper); conv = FCP_DEFAULT_TIMEOUT; sprintf (debug_msg_helper, "CONFIGURE: using standard timeout %i instead", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { sprintf (debug_msg_helper, "CONFIGURE: using %i as standard timeout value", conv); fcp_log (LOG_DEBUG, debug_msg_helper); } if (conv != fcp_timeout) /* is there anything else to do ??? should we calculate the timeout of the existing states new? but how? we don't know how much time is elapsed by every state. so i assume that the new timeout is only valid for new states. :( */ fcp_timeout = conv; break; case argument_MAXPRIORITY: conv = atoi (config_list->value); if ((conv > FCP_MAX_PRIORITY_CLASSES) || (conv < 0)) { sprintf (debug_msg_helper, "CONFIGURE: %i priority classes are grater then the" " maximum %i or less 0", conv, FCP_MAX_PRIORITY_CLASSES); fcp_log (LOG_ERR, debug_msg_helper); conv = FCP_DEFAULT_PRIORITY_CLASSES; sprintf (debug_msg_helper, "CONFIGURE: using %i priority classes instead.", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { sprintf (debug_msg_helper, "CONFIGURE: using %i priority classes.", conv); fcp_log (LOG_DEBUG, debug_msg_helper); } if (conv != fcp_priorityclasses) /* *FIXME* here we definetly have to do some more things but at this ... */ fcp_priorityclasses = conv; break; case argument_MAXLOG: conv = atoi (config_list->value); if ((conv > FCP_MAX_LOG_CLASSES) || (conv < 0)) { sprintf (debug_msg_helper, "CONFIGURE: %i log classes are grater then the" " maximum %i or less 0", conv, FCP_MAX_LOG_CLASSES); fcp_log (LOG_ERR, debug_msg_helper); conv = FCP_DEFAULT_LOG_CLASSES; sprintf (debug_msg_helper, "CONFIGURE: using %i log classes instead.", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { sprintf (debug_msg_helper, "CONFIGURE: using %i logging classes.", conv); fcp_log (LOG_DEBUG, debug_msg_helper); } if (fcp_logclasses != conv) /* *FIXME* here we definetly have to do some more things but at this time ... */ fcp_logclasses = conv; break; case argument_INTERNALIPS: sprintf (debug_msg_helper, "CONFIGURE: internal IPs are %s.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Seperate the string by the commas */ csv_list = (struct name_value *) scan_csv (config_list->value); if (csv_list) { /* First of all free the existing internal_ips. */ this_address_list = fcp_internal_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } /* Convert the strings into IPs and netmasks and put them into the internal_ips. */ this_name_value = csv_list; fcp_internal_ips.next = malloc (sizeof (struct fcp_address_list)); this_address_list = fcp_internal_ips.next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in INTERNALIPS isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in INTERNALIPS isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in INTERNALIPS isn't" " valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; /* The first element is now in the list, now do the same for the rest. */ while (this_name_value) { this_address_list->next = malloc (sizeof (struct fcp_address_list)); this_address_list = this_address_list->next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in INTERNALIPS isn't" " valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in INTERNALIPS isn't" " valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in INTERNALIPS isn't" " valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; } /* Everything is in the internal_ips now freeing the name_value_list where the strings were in. */ while (csv_list) { this_name_value = csv_list->next; free (csv_list->name); free (csv_list); csv_list = this_name_value; } } else { fcp_log (LOG_ERR, "CONFIGURE: INTERNALIPS couldn't be converted"); /* Free the existing internal_ips if exists. */ if (fcp_internal_ips.next) { this_address_list = fcp_internal_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } fcp_internal_ips.next = NULL; } } break; case argument_MASQUIPS: sprintf (debug_msg_helper, "CONFIGURE: this IPS %s will be masqueraded.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Seperate the string by the commas */ csv_list = (struct name_value *) scan_csv (config_list->value); if (csv_list) { /* First of all free the existing masqu_ips. */ this_address_list = fcp_masq_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } /* Convert the strings into IPs and netmasks and put them into the masqu_ips. */ this_name_value = csv_list; fcp_masq_ips.next = malloc (sizeof (struct fcp_address_list)); this_address_list = fcp_masq_ips.next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in MASQUIPS isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in MASQUIPS isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in MASQUIPS isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; /* The first element is now in the list, now do the same for the rest. */ while (this_name_value) { this_address_list->next = malloc (sizeof (struct fcp_address_list)); this_address_list = this_address_list->next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in MASQUIPS isn't" " valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in MASQUIPS isn't" " valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in MASQUIPS isn't" " valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; } /* Everything is in the masqu_ips now freeing the name_value_list where the strings were in. */ while (csv_list) { this_name_value = csv_list->next; free (csv_list->name); free (csv_list); csv_list = this_name_value; } } else { fcp_log (LOG_ERR, "CONFIGURE: MASQIPS couldn't be converted"); /* Free the existing masq_ips if exists. */ if (fcp_masq_ips.next) { this_address_list = fcp_masq_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } fcp_masq_ips.next = NULL; } } break; case argument_IPIN: if (parse_ip_address (config_list->value, &conv)) { sprintf (debug_msg_helper, "CONFIGURE: IP of internal interface is %s", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); fcp_internal_IP = conv; } else { sprintf (debug_msg_helper, "CONFIGURE: couldn't convert IP (%s) of internal" " interface", config_list->value); fcp_log (LOG_ERR, debug_msg_helper); } break; case argument_IPOUT: if (parse_ip_address (config_list->value, &conv)) { sprintf (debug_msg_helper, "CONFIGURE: IP of outer (external) interface is %s", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); fcp_outer_IP = conv; } else { sprintf (debug_msg_helper, "CONFIGURE: couldn't convert IP (%s) of outer" " (external) interface", config_list->value); fcp_log (LOG_ERR, debug_msg_helper); } break; case argument_IPDMZ: if (parse_ip_address (config_list->value, &conv)) { sprintf (debug_msg_helper, "CONFIGURE: IP of DMZ interface is %s", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); fcp_demilitary_IP = conv; } else { sprintf (debug_msg_helper, "CONFIGURE: couldn't convert IP (%s) of DMZ" " interface", config_list->value); fcp_log (LOG_ERR, debug_msg_helper); } break; case argument_DMZIPS: sprintf (debug_msg_helper, "CONFIGURE: this IPS %s are in the DMZ.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Seperate the string by the commas */ csv_list = (struct name_value *) scan_csv (config_list->value); if (csv_list) { /* First of all free the existing dmz_ips. */ this_address_list = fcp_dmz_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } /* Convert the strings into IPs and netmasks and put them into the dmz_ips. */ this_name_value = csv_list; fcp_dmz_ips.next = malloc (sizeof (struct fcp_address_list)); this_address_list = fcp_dmz_ips.next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in DMZIPS isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in DMZIPS isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in DMZIPS isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; /* The first element is now in the list, now do the same for the rest. */ while (this_name_value) { this_address_list->next = malloc (sizeof (struct fcp_address_list)); this_address_list = this_address_list->next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in DMZIPS isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in DMZIPS isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in DMZIPS isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; } /* Everything is in the dmz_ips now freeing the name_value_list where the strings were in. */ while (csv_list) { this_name_value = csv_list->next; free (csv_list->name); free (csv_list); csv_list = this_name_value; } } else { fcp_log (LOG_ERR, "CONFIGURE: DMZIPS couldn't be converted"); /* Free the existing dmz_ips if exists. */ if (fcp_dmz_ips.next) { this_address_list = fcp_dmz_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } fcp_dmz_ips.next = NULL; } } break; case argument_LOG_S: fcp_log_per_sec = atoi (config_list->value); sprintf (debug_msg_helper, "CONFIGURE: log class 1 will log %i packets/second", fcp_log_per_sec); fcp_log (LOG_DEBUG, debug_msg_helper); break; case argument_LOG_M: fcp_log_per_min = atoi (config_list->value); sprintf (debug_msg_helper, "CONFIGURE: log class 2 will log %i packets/minute", fcp_log_per_min); fcp_log (LOG_DEBUG, debug_msg_helper); break; case argument_LOG_H: fcp_log_per_hou = atoi (config_list->value); sprintf (debug_msg_helper, "CONFIGURE: log class 3 will log %i packets/hour", fcp_log_per_hou); fcp_log (LOG_DEBUG, debug_msg_helper); break; case argument_LOG_D: fcp_log_per_day = atoi (config_list->value); sprintf (debug_msg_helper, "CONFIGURE: log class 4 will log %i packets/day", fcp_log_per_day); fcp_log (LOG_DEBUG, debug_msg_helper); break; default: sprintf (debug_msg_helper, "CONFIGURE: don't know what to do with parameter %s", config_list->name); fcp_log (LOG_ERR, debug_msg_helper); break; } } /* if result */ else { sprintf (debug_msg_helper, "CONFIGURE: unknown parameter %s found in config file\n", config_list->name); fcp_log (LOG_CRIT, debug_msg_helper); } /* if result */ config_list = config_list->next; } /* while */ fcp_log (LOG_DEBUG, "CONFIGURE: end of changing configuration\n"); }