From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../elabs/Engine/actions_commandline.txt | 1385 ++++++++++++++++++++ 1 file changed, 1385 insertions(+) create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/actions_commandline.txt (limited to 'Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/actions_commandline.txt') diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/actions_commandline.txt b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/actions_commandline.txt new file mode 100644 index 0000000..c8b5b16 --- /dev/null +++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/actions_commandline.txt @@ -0,0 +1,1385 @@ +//Modified by Bargavi +//to be compatible with Flash MX +// Modified by Dean Wood 05.10.01 +// Changed hard-coded 7s to cursorXOffset + + +// ***** process (int) ***** +// IN: 1 integer representing the keycode of a key pressed +// DO: process the key by calling other functions +// NOTE: +// process is a global variable name. it can be assigned with another function name. +// that means process is a pointer variable to other functions. +// ie, the following line, when the key capturing event calls process(keycode), +// it will call the router_startup_processStartUp() function. + +var process = router_startup_processStartUp; +var processName = new String("router_startup_processStartUp"); // a global variable storing which function is currently pointed by process. + +var doneIsWaiting = false; + +// ***** commandline_changeProcess (str) ***** +//IN: p = string, name of a function (next process to run) +//DO: assign this function to the process 'p' +//OUT: +function commandline_changeProcess(p) { + processName = p; + + //the current process is set to the 'p' process + //modified by Bargavi + with(eval("_root.r" + _root.active_router )) + { + processCurrent = p; + } + process = eval(p); +} + + + + +// ***** commandline_processCommandLine(int) ***** +//IN: keycode = int, represents the keycode of a key pressed +// +// NOTE: This is the most common process function because the user is at +// the command line most of the time. +//DO: process a key entered at the command line +function commandline_processCommandLine(keycode) { + + //special keycodes temporarily defined + var KEY_CTRL = -10; + var KEY_TAB = -11; + + + //this.controlCharPressed = 0; + //this.lineIndexCounter = 0; + + + // use this as a pointer to the visible router object + var rptr = eval("_root.r" + _root.VISIBLE_ROUTER); + + // use this as a pointer to the active router object + var rptr2 = eval("_root.r" + _root.active_router); + + //resets the more function scroll; tells the more function to count + //the number of lines printed starting from the line when this + //function is called + rptr.scrollStartLine = rptr.lastDLine - 23; + + //output_write("keycode="+keycode); + //output_write("!switch="+rptr.controlCharPressed); + + if (rptr.controlCharPressed == 0) { + + if (keycode == KEY_CTRL) { + + // key is pressed + + //set the rptr.controlCharPressed switch so that the + //next key to be pressed, becomes part of a + //-something sequence + rptr.controlCharPressed = 1; + return; + + } else { + + //the key pressed was anything but , so + //interpret the keypress like normal + + + if (keycode == 8) { + + //BACKSPACE detected: delete 1 character if + //the input is longer than 0. + + + if (rptr.lineIndexCounter > 0) { + //we only need to delete a character if there are + //characters to delete. if lineIndexCounter is <= 0, + //then there are no characters on the command line + //input! + + + if (rptr.INPUT.length == rptr.lineIndexCounter) { + //the cursor is at the end of the commandline + //input. no need to do anything special to + //remove it + + //erase last character position and adjust rptr.lineIndexCounter + rptr.INPUT = rptr.INPUT.substring(0,rptr.INPUT.length-1); + + //Move the rptr.lineIndexCounter one postion to the left to + //account for removed character + rptr.lineIndexCounter -=1; + + //actually erase one character from the line + //buffer as well, and reprint the commandline + output_erase(1); + + } else { + //cursor is not at the end of the command line input, + //we need to delete from some other part of it. + + //decrement the cursor pointer + rptr.lineIndexCounter -=1; + + //remove the character denoted by 'rptr.lineIndexCounter' + //from the command line input string + rptr.INPUT = rptr.INPUT.substr(0,rptr.lineIndexCounter)+rptr.INPUT.substr(rptr.lineIndexCounter+1,rptr.INPUT.length+1-rptr.lineIndexCounter); + + //remove the correct character from the output buffer + //and reprint the output buffer to the Hyperterminal window + var grab = rptr.lineIndexCounter + rptr.PROMPT.length; + rptr.line[rptr.lastLine] = rptr.line[rptr.lastLine].substr(0,grab) + rptr.line[rptr.lastLine].substr(grab+1,rptr.line[rptr.lastLine].length+1-grab); + output_write(); + + //move the cursor over one character to the left + //to account for the deleted character + rptr.cursorX = rptr2.PROMPT.length + rptr.lineIndexCounter; + _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX; + } + + } //end if(rptr.lineIndexCounter > 0) + + + } else if (keycode == 13) { + + //ENTER detected--the command entry is finished. now, + //the entire current command line string is to be parsed... + //...reset the cursor pointer, as well. + + rptr.lineIndexCounter = 0; + commandline_parseCommandLine(1,1); + } else if (keycode == -1) { + + //we are returning from a popup box display, so no + //newline needed when the next prompt is + //printed (0 is the flag value) + rptr.lineIndexCounter = 0; + rptr.HELPING = false; + commandline_parseCommandLine(0,1); + + } else if (keycode == KEY_TAB) { + + // detected + + //prevent the Flash projector + //from "stealing" the tab + Selection.setFocus(_root.Menu.tabAbsorb); + + //try to match the current command line + //input to existing commands.. + commands_tabCompleteCommand(eval(rptr2.MODE+"C"), rptr.INPUT); + + } else { + //begin modification by Bargavi + //all other keys + //begin for the configuration mode of the routers -- suresh + //if the user is in the erase command then what ever character the user presses + //it is checked and action is performed + if ( eval("config" + _root.active_router) == "erase"){ + //eval("config" + _root.active_router) = "normal"; //resetting the mode back to normal + setConfigVariable("normal"); + output_write("\n"); + rptr.lineIndexCounter = 0; + //checking if the user presses y or Y + if (keycode == 121 || keycode == 89) + COMMAND[0] = "y"; + else + COMMAND[0] = "n"; + processErase(); + rptr.INPUT = ""; + commandline_parseCommandLine(0,0); + return; + } + //end for the configuration mode of the routers -- suresh + if (keycode == 63) + { + if (!isComputer() && !isNameOnly()) + { + //'?' detected + + //print the key that was pressed out to the console + output_write(chr(keycode)); + + //the user pressed "?", then turn on HELPING. + rptr2.HELPING = true; + commandline_parseCommandLine(1,1); + } + else if(isComputer()) + { + // When the user is on a computer, please make them know there are no ? help + errorNotice("On workstations, there are no '?' help commands. Supported commands: ping, tracert, telnet"); + } + else if(isNameOnly()) + { + } + + } else if (rptr.INPUT.length == rptr.lineIndexCounter) { + //the cursor is at the end of the commandline, + //so just append this new incoming character to + //the end of the commandline input + + //print the key that was pressed out to the console + output_write(chr(keycode)); + + //add the character pressed to the router's + //input buffer + rptr.INPUT += chr(keycode); + + //update the cursor pointer + rptr.lineIndexCounter += 1; + + } else { + + //the cursor is somewhere in the middle of the + //current command line input (at location 'rptr.indexLineCounter'). + //this new key that was pressed must be inserted into the + //commandline input at the specified location. + + + //add the character to the middle of the + //command line input buffer + rptr.INPUT = rptr.INPUT.substr(0,rptr.lineIndexCounter) + chr(keycode) + rptr.INPUT.substr(rptr.lineIndexCounter,rptr.INPUT.length+1-rptr.lineIndexCounter); + + //add the character to the middle of the + //output buffer + var grab = rptr.lineIndexCounter + rptr.PROMPT.length; + rptr.line[rptr.lastLine] = rptr.line[rptr.lastLine].substr(0,grab) + chr(keycode) + rptr.line[rptr.lastLine].substr(grab,rptr.line[rptr.lastLine].length+1-grab); + + //update the display with the new character + //inserted somewhere in the middle... + output_write(); +//trace("LINE INDEX COUNTER = " + rptr.lineIndexCounter); + //reposition the cursor to accomodate for the added character + rptr.cursorX = rptr.PROMPT.length + rptr.lineIndexCounter + 1; + _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX; + + //increment the cursor pointer + rptr.lineIndexCounter +=1; + + } //end if (keycode == 63) + + } //end keycode if-else-if chain + + } //end if (keycode == 17) else.. + + } else { //if (rptr.controlCharPressed == 0) + + //this part of the if-else block executes if the key + //has been pressed--the next character matched will complete + //a control key sequence to be interpreted as a command + // + //currently supported control sequences: + //----------------------------------------------------------- + // = move cursor one character to the left + // = move cursor one character to the right + // = move cursor to beginning of command line input + // = move cursor to end of command line input + // = shortcut for "end" (exits config modes) + // = move to prev line in the command history + // = move to next line in the command history + // = [currently not implemented] + + + //reset the control character switch + rptr.controlCharPressed = 0; + + //the following if-else-if.. block interprets the second half + //of the control key sequence: + // + if ((keycode == 98) || (keycode == 66)) { + + // or detected + + //move cursor one character left + commandline_arrowLeft(); + + + } else if ((keycode == 102) || (keycode == 70)) { + + // or detected + + //move cursor one character right + commandline_arrowRight(); + + + } else if ((keycode == 97) || (keycode == 65)) { + + // or detected + //move to beginning of input line + + //set cursor pointer to the beginning of the + //current command line input string + rptr.lineIndexCounter = 0; + + //move the cursor to the beginning of the + //command line input string + rptr.cursorX = rptr.PROMPT.length; + _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX; + + + } else if ((keycode == 101) || (keycode == 69)) { + + //begin commented for template + /* + // or detected + //move to end of input line + + //set cursor pointer to the length of the + //current command line input string (the end + //of the command line input string) + rptr.lineIndexCounter = rptr.INPUT.length; + + //move the cursor to the end of the + //command line input string + rptr.cursorX = rptr.PROMPT.length + rptr.INPUT.length; + _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX; + */ + //end commented for template + + + } else if ((keycode == 122) || (keycode == 90)) { + + // or detected + + //exits configuration mode, or any of + //the configuration submodes + //begin commented for template + /*if (!((rptr2.MODE == "user") || (rptr2.MODE == "enable"))) { + + //this if-statement only executes if the user + //is in configuration mode, or in one of the + //configuration submodes (i.e. not in user or + //enable mode) + + //substitute the "end" command into the input line + rptr.INPUT = "end"; + + //do commandline parse and execution--the 0 flag + //denotes that this "end" command wont be stored + //in the command history + commandline_parseCommandLine(1,0); + } + */ + //end commented for template + + + } else if ((keycode == 112) || (keycode == 80)) { + + // or detected + + //move to previous line in command history (same + //routine as pressing up arrow + _root.history_historyBackward(); + + + } else if ((keycode == 110) || (keycode == 78)) { + + // or detected + + //move to next line in command history (same + //routine as pressing down arrow) + _root.history_historyForward(); + + + } else if ((keycode == 99) || (keycode == 67)) { + + // or detected + + //'break'--this will put user in common mode + //if issues right after reload command. + + //not implemented yet.. + + + } else {} + + + } //if (rptr.controlCharPressed == 0) + +} + + + +//*** commandline_arrowLeft() +//IN: +//DO: moves the cursor one character to the left +//OUT: +// +function commandline_arrowLeft() { + + //move cursor one character left + + + var rptr = eval("_root.r" + _root.VISIBLE_ROUTER); + + if (rptr.lineIndexCounter > 0) { + + //if characters exist to back up to (>0), + //then back up the pointer one character. + rptr.lineIndexCounter -= 1; + + //move the cursor one character + //backward on the screen + rptr.cursorX -= 1; + _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX; + + } +} + + + +//*** commandline_arrowRight() +//IN: +//DO: moves the cursor one character to the right +//OUT: +// +function commandline_arrowRight() { + + //move cursor one character to the right + var rptr = eval("_root.r" + _root.VISIBLE_ROUTER); + + if (rptr.lineIndexCounter < rptr.INPUT.length) { + + //if the cursor isn't all the way to the + //end of the commandline text, then + //move it one position to the right + rptr.lineIndexCounter +=1; + + //move the cursor one character + //forward on the screen + rptr.cursorX += 1; + _root.HyperTerminal.cursor._x = rptr.cx + rptr.cursorXOffset * rptr.cursorX; + } +} + + +// ***** commandline_parseCommandLine(int flag_prNewline, int flag_storeInHist) +//IN: flag_prNewline = int, flag whether or not to print a newline +// before the current command is parsed/interpreted +// (1 prints the newline, 0 does not). +// 2 = perfect config hack +// flag_storeInHist = int, flag that determines whether or not to +// add this command to the command history +// (1 adds to history, 0 does not). +// rptr.INPUT = the command line input string +//DO: split up the command line input into an array with multiple elements. +// each element is a word separated by one or more spaces at the command line. +// The commands_useCommand function to interpret the input... +//OUT: +function commandline_parseCommandLine(flag_prNewline, flag_storeInHist) { + + // use this as a pointer to the visible router object + var rptr = eval("_root.r" + _root.VISIBLE_ROUTER); + + // use this as a pointer to the active router object + var actrptr = eval("_root.r" + _root.active_router); + + //separate the command line input (rptr.INPUT) into different words, + //using the space " " as a delimiter. COMMAND is an array of strings, + //the individual words + COMMAND = rptr.INPUT.split(" "); + for (var i = 0; i < COMMAND.length; i++) { + + //removes the empty "" elements from + //the COMMAND array + if (COMMAND[i] == "") { + COMMAND.splice(i,1); + i--; + } + } + + + if (flag_prNewline == 1) { + //if 'flag_prNewline' is 1, print a newline. + output_write("\n"); + } + + //if the input command is not empty or "?" is pressed + if ((COMMAND.length != 0) || (actrptr.HELPING == true)) { + + + //if "?" WASN'T pressed, store this input command + //line to the history buffer + if (actrptr.HELPING == false) { + + //if 'flag_storeInHist' is 1, + //store this command in + //the history buffer + if (flag_storeInHist == 1) { + history_setHistory(); + } + + } + //begin for the configuration mode of the routers -- suresh + //checking if the user is in any of the commands like "config", "erase", + //"start", "run" or "telnet" + // reason is :- if the user types any of the above command then the corresponding + //question has to be asked. since for every key pressed it comes to this function + //we are checking for these commands when the user enters something after these commands + //were shown. + //we can acheive the same functionality by changing the process. But then we need to + //check for every key pressed in all of the process. + + if ( eval("config" + _root.active_router) == "normal"){ + //"use" this command (interpret the commandline input) + //trace((eval(actrptr.MODE+"C")).toString()); + var returnvalue = commands_useCommand(eval(actrptr.MODE+"C"), 0); + //calling the processStep function of the lab-drill -- suresh + processStep(stepnum,returnvalue); + } + else if ( eval("config" + _root.active_router) == "config"){ + //eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + processConfig(eval(actrptr.MODE+"C")["configure"]); + } + else if ( eval("config" + _root.active_router) == "erase"){ +// eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + processErase(); + } + else if ( eval("config" + _root.active_router) == "start"){ +// eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + copyStartupToRun(); + } + else if ( eval("config" + _root.active_router) == "run"){ +// eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + copyRunToStartup(); + } + else if ( eval("config" + _root.active_router) == "telnethost"){ +// eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + doTelnet(); + } + //end for the configuration mode of the routers -- suresh + } + else if ( eval("config" + _root.active_router) == "config") { + //begin for the configuration mode of the router -- suresh +// eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + processConfig(eval(actrptr.MODE+"C")["configure"]); + } + else if ( eval("config" + _root.active_router) == "erase") { + //begin for the configuration mode of the router -- suresh +// eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + processErase(); + } + else if ( eval("config" + _root.active_router) == "start") { + //begin for the configuration mode of the router -- suresh +// eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + copyStartupToRun(); + } + else if ( eval("config" + _root.active_router) == "run") { + //begin for the configuration mode of the router -- suresh +// eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + copyRunToStartup(); + } + else if ( eval("config" + _root.active_router) == "telnethost"){ +// eval("config" + _root.active_router) = "normal"; + setConfigVariable("normal"); + doTelnet(); + } + //end for the configuration mode of the router -- suresh + + + + //if the process is "commandline_processCommandLine", + //then print the command line. + if (processName == "commandline_processCommandLine") + commandline_commandLine(); +} + + + + +// ***** commandline_commandLine() ***** +//IN: rptr.PROMPT, the command line prompt +// rptr.INPUT, the command line input +//DO: echo the command line prompt to the console +//OUT: the command line prompt is printed to the screen +function commandline_commandLine() { + + // use this as a pointer to the active router object + var rptr = eval("_root.r" + _root.active_router); + + var rptr2 = eval("_root.r" + _root.VISIBLE_ROUTER); + + //print out the current prompt + output_write(rptr.PROMPT); + + + if (rptr.HELPING == true) { + + //HELPING is on (==true), that means "?" has been pressed. the + //command line will show the input of the last input before "?". + // else, clear the input + rptr.HELPING = false; + output_write(rptr2.INPUT); + } else { + + //the command line prompt has been printed, and is ready for the + //next command from the user--clear the input buffer to prepare + //for the next command to be typed. + rptr2.INPUT = ""; + } + + //reset the COMMAND array, which will be used to hold the next + //command line input that is parsed + COMMAND = new Array(); +} + + + + +// commandline_setMode(arg1, arg2) +//IN: arg1 = string, the new mode to change the router to +// arg2 = string, router name in which to change the mode +//DO: Changes the current mode to the new mode +//OUT: the current mode is changed to 'newMode' on the 'rtrName' router, +// and the command prompt will change to the reflect the new mode +function commandline_setMode(arg1, arg2) { + + var rptr = eval("_root.r" + arg2); //pointer to router that will + //get its mode changed + +// *********** for loading command arrays ******* + //trace("stepnum " + _root.stepnum); + + + trace("arg is " + arg1); + var stepDevice = _root.routerInfoArray[_root.routerUsedForThisStep[_root.stepnum]].deviceType; + //trace("device for this step: " + stepDevice); +trace("rootsarg is" + _root.loadedCommands.arg1); + if (eval("_root.loadedCommands." + arg1) != stepDevice) + { + with(eval("_root.loadedCommands.") ) + { + arg1 = stepDevice; + + } + + // eval("_root." + arg1 + "C") = new Array(); + emptyArray(arg1); //modified by Bargavi + + + + tellTarget("CommandLoad") + { + loadMovie(_level0.EngineDir + stepDevice + "/" + arg1 + ".swf", _root.CommandLoad); + } + + } + + + + + + //holds the string that is the new prompt + var p = ""; + + if (arg1 == "user") { + + if (deviceUsed != "Switch 4006 Sup 2") + p = ">"; + else + p = "> "; + + } else if (arg1 == "enable") { + + if (deviceUsed != "Switch 4006 Sup 2") + p = "#"; + else + p = "> (enable) "; + + } else if (arg1 == "global") { + + p = "(config)#"; + + } + + else if (arg1.substr(0, 3) == "int") { + p = "(config-if)#"; + } + + else if (arg1.substr(0, 3) == "sub") { + p = "(config-subif)#"; + } + + else if (arg1.substr(0, 4) == "line") { + p = "(config-line)#"; + } + + else if (arg1.substr(0, 6) == "router") { + p = "(config-router)#"; + } + + else if (arg1.indexOf("controller") == 0) { + p = "(config-controller)#"; + } + + else if (arg1.indexOf("extNacl") == 0) { + p = "(config-ext-nacl)#"; + } + + else if (arg1.indexOf("mapClass") == 0) { + p = "(config-map-class)#"; + } + + else if (arg1.indexOf("timeRange") == 0) { + p = "(config-time-range)#"; + } + + else if (arg1.indexOf("dhcp") == 0) { + p = "(dhcp-config)#"; + } + + else if (arg1.indexOf("routeMap") == 0) { + p = "(config-route-map)#"; + } + + else if (arg1.indexOf("classMap") == 0) { + p = "(config-cmap)#"; + } + + else if (arg1.indexOf("policyMap") == 0) { + p = "(config-pmap)#"; + } + + else if (arg1.indexOf("policyMapClass") == 0) { + p = "(config-pmap-c)#"; + } + + else if (arg1 == "vlanDB") { + p = "(vlan)#"; + } + else if (arg1 == "ATMPVC") { + p = "(config-if-atm-vc)#"; + } + else if (arg1 == "DOS") + { + p = " C:\\>"; + } + else if (arg1 == "NameOnly") + { + p = ""; + } + + //set the new prompt and mode on the router in question + rptr.PROMPT = rptr.run.hostname + p; + rptr.MODE = arg1; +} + + + + +// ***** commandline_matchKey(int, char) ***** +//IN: keycode = int, representing the keycode of the key pressed +// letter = char, 1 character +//DO: determines if given 'keycode' represents the character 'letter' +//OUT: true = if character represented by 'keycode' matches 'letter' +// false = no match +function commandline_matchKey(keycode, letter) { + + return (chr(keycode).toUpperCase() == letter.toUpperCase()); +} + + + +//begin for the configuration mode of the routers -- suresh + +// ***** processConfig(commandArray) ***** +//IN: commandArray = array, representing all the options under the configure mode +//DO: determines if the parameter given for the configure mode is one of its valid option + +function processConfig(commandArray) +{ + var rptr = eval("_root.r" + _root.active_router); + var arrayptr = eval(rptr.MODE + "C")["configure"]; + + //if the user did not type any option then by default the terminal option is chosen + if (COMMAND.length == 0) + COMMAND[0] = "terminal"; + + for (var i=0; i