int cmd_dns_end(struct cli_def *cli, const char *command, char *argv[], int argc) { char prompt[16]; sprintf(prompt, "pkt-%i",clipkt->id); cli_set_configmode(cli, MZ_MODE_PACKET, prompt); return CLI_OK; }
// PURPOSE: Enter sequence configuration mode // either a) create new or b) edit old or c) delete old sequence // // # sequence MY_SEQUENCE // # sequence OLD_SEQUENCE delete // int conf_sequence (struct cli_def *cli, char *command, char *argv[], int argc) { struct mz_ll *cur; char str[512]; int ret=0; if ( (strcmp(argv[argc-1],"?")==0) || (argc<1) || (argc>2)) { cli_print(cli, "Configure a sequence of packets.\n"); cli_print(cli, "ARGUMENTS: <sequence_name> [delete]\n"); cli_print(cli, "Current list of packet sequences:\n"); while (mops_dump_sequence(str)) cli_print(cli, "%s\r", str); return CLI_OK; } switch (argc) { case 1: cur = mz_ll_search_name (packet_sequences, argv[0]); if (cur==NULL) { // create NEW sequence cli_print(cli, "Sequence does not exist; creating new sequence named '%s'\n", argv[0]); cur = mops_create_sequence(argv[0]); if (cur==NULL) { cli_print(cli, "ERROR: Cannot allocate another sequence!\n"); return CLI_OK; } } // else ENTER EXISTING (cur already points to it) cli_seq = cur; cli_set_configmode(cli, MZ_MODE_SEQUENCE, "config-seq"); break; case 2: // otherwise DELETE? if (mz_strcmp(argv[1], "delete", 3)==0) { ret = mops_delete_sequence(argv[0]); switch (ret) { case 1: cli_print(cli, "Sequence '%s' does not exist\n", argv[0]); break; case 2: cli_print(cli, "Sequence '%s' is currently active! Cannot delete it.\n", argv[0]); break; default: cli_print(cli, "Sequence '%s' deleted.\n", argv[0]); } } break; default: // nothing break; } return CLI_OK; }
int cmd_config_end(struct cli_def *cli, char *command, char *argv[], int argc) { if (argc>0){ if (strcmp(argv[0],"?")==0){ cli_print(cli, " <cr>"); }else{ cli_print(cli, "%% Invalid input detected."); } }else{ cli_set_configmode(cli, MODE_EXEC, NULL); } return CLI_OK; }
int cmd_config_int(struct cli_def *cli, UNUSED(const char *command), char *argv[], int argc) { if (argc < 1) { cli_print(cli, "Specify an interface to configure"); return CLI_OK; } if (strcmp(argv[0], "?") == 0) cli_print(cli, " test0/0"); else if (strcasecmp(argv[0], "test0/0") == 0) cli_set_configmode(cli, MODE_CONFIG_INT, "test"); else cli_print(cli, "Unknown interface %s", argv[0]); return CLI_OK; }
// Enter interface config mode: // int enter_interface (struct cli_def *cli, const char *command, char *argv[], int argc) { int i, j=0; char prompt[10]; if ( (strcmp(argv[argc-1],"?")==0) || (argc>1) ) { cli_print(cli, "Specify an interface to configure\n"); return CLI_OK; } if (argc) { for (i=0; i<device_list_entries; i++) { if (strncmp(device_list[i].dev, argv[0], 16)==0) { j=1; sprintf(prompt, "if-%s", device_list[i].dev); clidev = i; break; } } if (j) { cli_set_configmode(cli, MZ_MODE_INTERFACE, prompt); } else { cli_print(cli, "Unknown device!\n"); } } else { cli_print(cli, "Specify an interface to configure\n"); } return CLI_OK; }
int cmd_config_int_exit(struct cli_def *cli, UNUSED(const char *command), UNUSED(char *argv[]), UNUSED(int argc)) { cli_set_configmode(cli, MODE_CONFIG, NULL); return CLI_OK; }
static int jem_test_mode(struct cli_def *cli, char *command, char *argv[], int argc) { cli_set_configmode(cli, CLI_TEST_MODE, "utest"); return CLI_OK; }
int cmd_config_int_exit(struct cli_def *cli, char *command, char *argv[], int argc) { cli_set_configmode(cli, MODE_CONFIG, NULL); return CLI_OK; }