package org.freertr.user; import java.util.ArrayList; import java.util.List; import org.freertr.addr.addrIP; import org.freertr.addr.addrIPv4; import org.freertr.addr.addrIPv6; import org.freertr.addr.addrIpx; import org.freertr.auth.authGeneric; import org.freertr.auth.authLocal; import org.freertr.auth.authResult; import org.freertr.cfg.cfgAceslst; import org.freertr.cfg.cfgAlias; import org.freertr.cfg.cfgAll; import org.freertr.cfg.cfgAuther; import org.freertr.cfg.cfgBndl; import org.freertr.cfg.cfgBrdg; import org.freertr.cfg.cfgCert; import org.freertr.cfg.cfgChat; import org.freertr.cfg.cfgCheck; import org.freertr.cfg.cfgDial; import org.freertr.cfg.cfgEvntmgr; import org.freertr.cfg.cfgGeneric; import org.freertr.cfg.cfgHrpn; import org.freertr.cfg.cfgInit; import org.freertr.cfg.cfgKey; import org.freertr.cfg.cfgMenuK; import org.freertr.cfg.cfgMenuT; import org.freertr.cfg.cfgMtrack; import org.freertr.cfg.cfgObjnet; import org.freertr.cfg.cfgObjprt; import org.freertr.cfg.cfgPlymp; import org.freertr.cfg.cfgPool; import org.freertr.cfg.cfgPrcss; import org.freertr.cfg.cfgPrfxlst; import org.freertr.cfg.cfgProxy; import org.freertr.cfg.cfgRoump; import org.freertr.cfg.cfgRouplc; import org.freertr.cfg.cfgRtr; import org.freertr.cfg.cfgSched; import org.freertr.cfg.cfgScrpt; import org.freertr.cfg.cfgSensor; import org.freertr.cfg.cfgSessn; import org.freertr.cfg.cfgTime; import org.freertr.cfg.cfgTlmtry; import org.freertr.cfg.cfgTrack; import org.freertr.cfg.cfgTrnsltn; import org.freertr.cfg.cfgVdc; import org.freertr.cfg.cfgVnet; import org.freertr.cfg.cfgVpdn; import org.freertr.cfg.cfgVrf; import org.freertr.cfg.cfgXconn; import org.freertr.clnt.clntIrc; import org.freertr.clnt.clntNetflow; import org.freertr.clnt.clntNtp; import org.freertr.clnt.clntSyslog; import org.freertr.enc.encBase64; import org.freertr.cry.cryCertificate; import org.freertr.cry.cryKeyDSA; import org.freertr.cry.cryKeyECDSA; import org.freertr.cry.cryKeyGeneric; import org.freertr.cry.cryKeyRSA; import org.freertr.ip.ipFwd; import org.freertr.ip.ipFwdRoute; import org.freertr.ipx.ipxFwd; import org.freertr.pipe.pipeSetting; import org.freertr.pipe.pipeSide; import org.freertr.serv.servGenList; import org.freertr.serv.servGeneric; import org.freertr.serv.servQuote; import org.freertr.serv.servSyslog; import org.freertr.tab.tabGen; import org.freertr.tab.tabNatCfgN; import org.freertr.tab.tabNshEntry; import org.freertr.tab.tabPbrN; import org.freertr.tab.tabRouteAttr; import org.freertr.tab.tabRouteEntry; import org.freertr.util.bits; import org.freertr.util.cmds; import org.freertr.util.debugger; import org.freertr.util.logger; import org.freertr.util.verCore; /** * process config commands * * @author matecsaba */ public class userConfig { /** * authenticated username */ public String username = ""; /** * authorization list */ public authGeneric authorization; /** * expand variables */ public boolean needExpand; private pipeSide pipe; // pipe to use private userReader reader; // reader of the user private cmds cmd; // currently processed string private modes modeV; // mode value private servGeneric modeDserver; private cfgGeneric modeDconfig; private enum modes { global, server, config } /** * constructs new reader for a pipeline * * @param pip pipeline to use as input * @param rdr reader to use as input */ public userConfig(pipeSide pip, userReader rdr) { pipe = pip; reader = rdr; resetMode(); } /** * reset current mode to global config */ public void resetMode() { modeV = modes.global; modeDserver = null; modeDconfig = null; } /** * get help text for exec commands * * @param needEdit need editor * @param needShow need show * @param needGen need generic * @return helping instance */ public userHelping getHelping(boolean needEdit, boolean needShow, boolean needGen) { userHelping l = new userHelping(); l.expand = needExpand; if (needEdit) { l.add(null, "1 . editor edit the current section"); } if (needShow) { userHelping.getCfgHelp(l); } if (needGen) { userHelping.getCfgGen(l); } switch (modeV) { case global: getHelpGlobal(l); return l; case server: modeDserver.getHelp(l); return l; case config: modeDconfig.getHelp(l); return l; default: resetMode(); return l; } } /** * get current prompt * * @return prompt value */ public String getPrompt() { switch (modeV) { case global: return "(cfg)"; case server: return "(cfg-" + modeDserver.getPrompt() + ")"; case config: return "(cfg-" + modeDconfig.getPrompt() + ")"; default: resetMode(); return "(bad)"; } } private cfgGeneric getCurrConfiger() { switch (modeV) { case server: return modeDserver; case config: return modeDconfig; case global: return null; default: return null; } } /** * execute one command * * @param a the command to execute * @return status of operation, false to continue processing */ public boolean executeCommand(String a) { if (a == null) { a = ""; } cmd = new cmds("config", a); cmd.pipe = pipe; if (authorization != null) { authResult ntry = authorization.authUserCommand(username, a); if (ntry.result != authResult.authSuccessful) { cmd.error("not authorized to configure that"); return false; } } if (debugger.userConfigEvnt) { logger.debug(cmd.getOriginal()); } a = cmd.word(); if (a.length() < 1) { return false; } if (a.equals(cmds.finish)) { if (modeV == modes.global) { return true; } resetMode(); return false; } if (a.equals("end")) { resetMode(); return true; } if (a.equals("editor")) { if (authorization != null) { authResult ntry = authorization.authUserCommand(username, cmd.getRemaining()); if (ntry.result != authResult.authSuccessful) { cmd.error("not authorized to edit this"); return false; } } cfgGeneric cur = getCurrConfiger(); if (cur == null) { cmd.error("not allowed here"); return false; } List c1 = cur.getShRun(1); List c2 = new ArrayList(); c2.addAll(c1); userEditor edt = new userEditor(new userScreen(cmd.pipe), c2, "current", false); if (edt.doEdit()) { return false; } List c3 = userFilter.getDiffs(c1, c2); reader.putStrArr(bits.lst2lin(c3, false)); int res = cfgInit.executeSWcommands(c3, false); reader.putStrArr(bits.str2lst("errors=" + res)); c3 = userFilter.getDiffs(c2, c1); reader.putStrArr(c3); return false; } if (a.equals("show")) { if (pipe.settingsGet(pipeSetting.times, false)) { pipe.linePut(logger.getTimestamp()); } userShow shw = new userShow(); cmd = reader.setFilter(cmd); shw.cmd = cmd; shw.rdr = reader; shw.hlp = getHelping(false, false, false); shw.cfg = getCurrConfiger(); if (authorization != null) { authResult ntry = authorization.authUserCommand(username, cmd.getRemaining()); if (ntry.result != authResult.authSuccessful) { cmd.error("not authorized to show that"); return false; } } cfgAlias alias = shw.doer(); if (alias == null) { return false; } userExec e = new userExec(pipe, reader); alias.doCommands(e, cmd); return false; } if (a.equals("do")) { if (pipe.settingsGet(pipeSetting.times, false)) { pipe.linePut(logger.getTimestamp()); } userExec exe = new userExec(pipe, reader); exe.privileged = true; exe.username = username; exe.authorization = authorization; a = exe.repairCommand(cmd.getRemaining()); if (authorization != null) { authResult ntry = authorization.authUserCommand(username, a); if (ntry.result != authResult.authSuccessful) { cmd.error("not authorized to do that"); return false; } } exe.executeCommand(a); return false; } cmd = cmd.copyBytes(true); switch (modeV) { case global: doGlobal(); return false; case server: modeDserver.doCfgStr(cmd); return false; case config: modeDconfig.doCfgStr(cmd); return false; default: cmd.badCmd(); resetMode(); return false; } } /** * execute one command * * @return status of operation, see at one command */ public boolean doCommand() { reader.setContext(getHelping(true, true, true), cfgAll.hostName + getPrompt() + "#"); String s = reader.readLine(cmds.finish); if (s == null) { return true; } return executeCommand(s); } private void getHelpGlobal(userHelping l) { l.add(null, "1 2 hostname set name of system"); l.add(null, "2 . name of system"); l.add(null, "1 . buggy enable dangerous things"); l.add(null, "1 2 locale set locale of system"); l.add(null, "2 . enable password"); l.add(null, "1 2 enable set enable password"); l.add(null, "2 . enable password"); l.add(null, "1 2 password-encrypt set password encryption key"); l.add(null, "2 . encryption key"); l.add(null, "1 2 banner banner of system"); l.add(null, "2 3 set set banner"); l.add(null, "3 3,. first line of banner"); l.add(null, "2 3 add add banner"); l.add(null, "3 3,. add line to banner"); l.add(null, "2 3 encoded set banner"); l.add(null, "3 3,. encoded banner"); l.add(null, "1 2 logging set logging parameters"); l.add(null, "2 3 debug always on debugging"); debugger.getHelping(l, 3); l.add(null, "2 . tracestop stop on traceback"); l.add(null, "2 . milliseconds millisecond logging"); l.add(null, "2 3 proxy set proxy to use"); l.add(null, "3 . proxy profile"); l.add(null, "2 3 buffered buffered logging"); l.add(null, "3 4 debug debugging messages"); l.add(null, "3 4 informational informational messages"); l.add(null, "3 4 warning warning messages"); l.add(null, "3 4 error error messages"); l.add(null, "3 4 exception exception messages"); l.add(null, "4 . number of lines"); l.add(null, "2 3 file file logging"); l.add(null, "3 4,. debug debugging messages"); l.add(null, "3 4,. informational informational messages"); l.add(null, "3 4,. warning warning messages"); l.add(null, "3 4,. error error messages"); l.add(null, "3 4,. exception exception messages"); l.add(null, "4 . name of file"); l.add(null, "2 3 rotate log file rotation"); l.add(null, "3 4 maximum file size"); l.add(null, "4 5,. name of second file"); l.add(null, "5 . ms between backup"); l.add(null, "2 3 syslog syslog logging"); l.add(null, "3 4 debug debugging messages"); l.add(null, "3 4 informational informational messages"); l.add(null, "3 4 warning warning messages"); l.add(null, "3 4 error error messages"); l.add(null, "3 4 exception exception messages"); l.add(null, "4 5 kernel facility"); l.add(null, "4 5 user facility"); l.add(null, "4 5 mail facility"); l.add(null, "4 5 system facility"); l.add(null, "4 5 security1 facility"); l.add(null, "4 5 syslogd facility"); l.add(null, "4 5 lpd facility"); l.add(null, "4 5 news facility"); l.add(null, "4 5 uucp facility"); l.add(null, "4 5 clock1 facility"); l.add(null, "4 5 security2 facility"); l.add(null, "4 5 ftp facility"); l.add(null, "4 5 ntp facility"); l.add(null, "4 5 logaudit facility"); l.add(null, "4 5 logalert facility"); l.add(null, "4 5 clock2 facility"); l.add(null, "4 5 local0 facility"); l.add(null, "4 5 local1 facility"); l.add(null, "4 5 local2 facility"); l.add(null, "4 5 local3 facility"); l.add(null, "4 5 local4 facility"); l.add(null, "4 5 local5 facility"); l.add(null, "4 5 local6 facility"); l.add(null, "4 5 local7 facility"); l.add(null, "5 5,. address of host"); l.add(null, "2 3 irc irc logging"); l.add(null, "3 4,. debug debugging messages"); l.add(null, "3 4,. informational informational messages"); l.add(null, "3 4,. warning warning messages"); l.add(null, "3 4,. error error messages"); l.add(null, "3 4,. exception exception messages"); l.add(null, "4 5 name of host"); l.add(null, "5 . name of channel"); l.add(null, "2 3 monitor terminal logging"); l.add(null, "3 . debug debugging messages"); l.add(null, "3 . informational informational messages"); l.add(null, "3 . warning warning messages"); l.add(null, "3 . error error messages"); l.add(null, "3 . exception exception messages"); l.add(null, "2 3 format logging format"); l.add(null, "3 . none not log source at all"); l.add(null, "3 . brief log only class name"); l.add(null, "3 . normal log class, file, line number"); l.add(null, "3 . full log full stack trace"); l.add(null, "1 2 vrf configure a virtual routing forwarding"); l.add(null, "2 3 definition create new or update existing vrf"); l.add(null, "3 . name of vrf"); l.add(null, "1 2 vdc configure a virtual device context"); l.add(null, "2 3 definition create new or update existing vdc"); l.add(null, "3 . name of vdc"); l.add(null, "1 2 process configure a external process"); l.add(null, "2 3 definition create new or update existing process"); l.add(null, "3 . name of process"); l.add(null, "1 2 interface select an interface to configure"); l.add(null, "2 . name of interface"); l.add(null, "1 . console0 select a line to configure"); l.add(null, "1 2 line select a line to configure"); l.add(null, "2 . name of line"); l.add(null, "1 2 bridge transparent bridging parameters"); l.add(null, "2 . number of bridge group"); l.add(null, "1 2 bundle interface bundle parameters"); l.add(null, "2 . number of bundle group"); l.add(null, "1 2 hairpin interface hairpin parameters"); l.add(null, "2 . number of hairpin group"); l.add(null, "1 2 vnet external hairpin parameters"); l.add(null, "2 . number of hairpin group"); l.add(null, "1 2 session stateful session parameters"); l.add(null, "2 . name of session"); l.add(null, "1 2 check check parameters"); l.add(null, "2 . name of check"); l.add(null, "1 2 sensor sensor parameters"); l.add(null, "2 . name of sensor"); l.add(null, "1 2 dial-peer dial peer parameters"); l.add(null, "2 . number of peer"); l.add(null, "1 2 translation-rule translation rule parameters"); l.add(null, "2 . number of peer"); l.add(null, "1 2 nsh specify service chaining"); l.add(null, "2 3 service path"); l.add(null, "3 4 service index"); l.add(null, "4 4,. drop drop packets"); l.add(null, "4 4,. rawpack output as raw packet, witout nsh header"); l.add(null, "4 4,. keephdr keep original layer2 addresses"); l.add(null, "4 5 interface forward as nsh"); l.add(null, "5 6 target interface"); l.add(null, "6 4,. target mac address"); l.add(null, "4 5 route route normally"); l.add(null, "5 4,. target vrf"); l.add(null, "4 5 tunnel tunnel in ip"); l.add(null, "5 6 target vrf"); l.add(null, "6 7 source interface"); l.add(null, "7 4,. target ip address"); l.add(null, "4 5 switch switch service"); l.add(null, "5 6 new service path"); l.add(null, "6 4,. new service index"); l.add(null, "1 2 client specify address of name server"); l.add(null, "2 3 cpuhog specify cpuhog parameters"); l.add(null, "3 . percentage"); l.add(null, "2 3 label-range specify label range parameters"); l.add(null, "3 4 beginning"); l.add(null, "4 . ending"); l.add(null, "2 3 ifacestall specify interface stall check"); l.add(null, "3 . timeout in ms"); l.add(null, "2 3 capture-path specify default capture location"); l.add(null, "3 . path on the flash"); l.add(null, "2 3 pastebin specify default pastebin service"); l.add(null, "3 . url on the internet"); l.add(null, "2 3 l2f-timer specify l2f parameters"); l.add(null, "3 4 retransmit in ms"); l.add(null, "4 . retry times"); l.add(null, "2 3 l2tp2-timer specify l2tp2 parameters"); l.add(null, "3 4 hello after ticks"); l.add(null, "4 . retry ticks"); l.add(null, "2 3 l2tp3-timer specify l2tp3 parameters"); l.add(null, "3 4 hello after ticks"); l.add(null, "4 . retry ticks"); l.add(null, "2 3 redundancy specify redundancy parameters"); l.add(null, "3 4 keepalive in ms"); l.add(null, "4 5 hold time in ms"); l.add(null, "5 . init time in ms"); l.add(null, "2 3 proxy specify proxy profile"); l.add(null, "3 . name of profile"); l.add(null, "2 3 bullying specify shame quote source"); l.add(cfgAll.dmnQuote.listServers(), "3 . name of server"); l.add(null, "2 . domain-lookup allow dns queries"); l.add(null, "2 3 domain-name specify domain name"); l.add(null, "3 . name of domain"); l.add(null, "2 3 name-proxy specify proxy profile"); l.add(null, "3 . name of profile"); l.add(null, "2 3 name-server specify address of name server"); l.add(null, "3 3,. address of server"); l.add(null, "2 . upgrade-config automatically save configuration on upgrade"); l.add(null, "2 3 upgrade-revert specify time after revert if unreachable"); l.add(null, "3 . time in ms"); l.add(null, "2 . upgrade-backup automatically backup image on upgrade"); l.add(null, "2 . upgrade-ownkey use just the configured key"); l.add(null, "2 3 upgrade-server specify url of upgrade server"); l.add(null, "3 . url of server"); l.add(null, "2 3 upgrade-script specify script to run on upgrade"); l.add(null, "3 . name of script"); l.add(null, "2 3 upgrade-pubkey specify key of upgrade"); l.add(null, "3 . public key"); l.add(null, "2 3 config-server specify url of config server"); l.add(null, "3 . url of server"); l.add(null, "2 3 config-username specify username on config server"); l.add(null, "3 . set username"); l.add(null, "2 3 config-password specify password on config server"); l.add(null, "3 . set password"); l.add(null, "2 3,. config-backup specify backup config file"); l.add(null, "3 3,. file to use"); l.add(null, "2 . config-save automatically save configuration"); l.add(null, "2 . config-archive automatically archive configuration"); l.add(null, "2 . config-exclusive allow only one user in configuration mode"); l.add(null, "2 . graceful-reload close sessions before reload"); l.add(null, "2 3,. end-format specify end format"); l.add(null, "3 3,. date append date"); l.add(null, "3 3,. image append image"); l.add(null, "3 3,. chksum append chksum"); l.add(null, "3 3,. user append user"); l.add(null, "3 3,. none append nothing"); l.add(null, "2 3 whois-online set online information"); l.add(null, "3 3,. server name"); l.add(null, "2 3 whois-server set whois server"); l.add(null, "3 . server name"); l.add(null, "2 3 whois-option set whois option"); l.add(null, "3 . server name"); l.add(null, "2 3 whois-proxy specify proxy profile"); l.add(null, "3 . name of profile"); l.add(null, "2 . password-stars type stars in passwords"); l.add(null, "2 . prefer-ipv6 prefer ipv6 for domains"); l.add(null, "2 . prefer-ipv4 prefer ipv4 for domains"); l.add(null, "2 3 ipv4-tos set ipv4 default tos"); l.add(null, "3 . value"); l.add(null, "2 3 ipv4-ttl set ipv4 default ttl"); l.add(null, "3 . value"); l.add(null, "2 3 ipv6-tos set ipv6 default tos"); l.add(null, "3 . value"); l.add(null, "2 3 ipv6-ttl set ipv6 default ttl"); l.add(null, "3 . value"); l.add(null, "2 3 ipv4-checksum set ipv4 checksum mode"); l.add(null, "2 3 icmp4-checksum set icmp4 checksum mode"); l.add(null, "2 3 icmp6-checksum set icmp6 checksum mode"); l.add(null, "2 3 udp-checksum set udp checksum mode"); l.add(null, "2 3 tcp-checksum set tcp checksum mode"); l.add(null, "2 3 ludp-checksum set ludp checksum mode"); l.add(null, "2 3 dccp-checksum set dccp checksum mode"); l.add(null, "2 3 sctp-checksum set sctp checksum mode"); l.add(null, "3 . both both generate and check"); l.add(null, "3 . transmit only generate, not check"); l.add(null, ".3 . receive only check, not generate"); l.add(null, ".3 . none nor generate nor check"); l.add(null, "2 . tcp-timestamp set tcp timestamping"); l.add(null, "2 . tcp-ecn set tcp ecn"); l.add(null, "2 . tcp-keepalive set tcp keepalive"); l.add(null, "2 3 tcp-timer set tcp timestamping"); l.add(null, "3 4 work set tcp work"); l.add(null, "4 . ms"); l.add(null, "3 4 alive set tcp keepalive"); l.add(null, "4 . ms"); l.add(null, "3 4 fin set tcp finish"); l.add(null, "4 . ms"); l.add(null, "3 4 syn set tcp startup"); l.add(null, "4 . ms"); l.add(null, "3 4 open set tcp inactivity"); l.add(null, "4 . ms"); l.add(null, "3 4 close set tcp inactivity"); l.add(null, "4 . ms"); l.add(null, "3 4 later set tcp retransmit"); l.add(null, "4 . ms"); l.add(null, "3 4 now set tcp transmit"); l.add(null, "4 . ms"); l.add(null, "3 4 max set tcp fallback"); l.add(null, "4 . ms"); l.add(null, "2 3 tcp-segments set tcp segment size"); l.add(null, "3 4 minimum bytes"); l.add(null, "4 . maximum bytes"); l.add(null, "2 3 tcp-winscale set tcp window scale"); l.add(null, "3 . factor"); l.add(null, "2 3 udp-portrange set udp client range"); l.add(null, "3 4 lower bound"); l.add(null, "4 . upper bound"); l.add(null, "2 3 tcp-portrange set tcp client range"); l.add(null, "3 4 lower bound"); l.add(null, "4 . upper bound"); l.add(null, "2 3 ludp-portrange set ludp client range"); l.add(null, "3 4 lower bound"); l.add(null, "4 . upper bound"); l.add(null, "2 3 dccp-portrange set dccp client range"); l.add(null, "3 4 lower bound"); l.add(null, "4 . upper bound"); l.add(null, "2 3 sctp-portrange set sctp client range"); l.add(null, "3 4 lower bound"); l.add(null, "4 . upper bound"); l.add(null, "2 3 access-subnet-ipv4 access subnet length"); l.add(null, "3 . bits"); l.add(null, "2 3 access-subnet-ipv6 access subnet length"); l.add(null, "3 . bits"); l.add(null, "2 3 access-supernet-ipv4 access subnet length"); l.add(null, "3 . bits"); l.add(null, "2 3 access-supernet-ipv6 access subnet length"); l.add(null, "3 . bits"); l.add(null, "2 . ftp-passive use passive mode ftp"); l.add(null, "2 . ftp-active use active mode ftp"); l.add(null, "2 3 ftp-proxy specify proxy profile"); l.add(null, "3 . name of profile"); l.add(null, "2 3 pop3-proxy specify proxy profile"); l.add(null, "3 . name of profile"); l.add(null, "2 3 tls-version specify tls version"); l.add(null, "3 4 forced minimum version"); l.add(null, "4 . forced maximum version"); l.add(null, "2 3 ssh-agent specify ssh agent to fake"); l.add(null, "3 3,. name of faker"); l.add(null, "2 3 ssh-group specify ssh group"); l.add(null, "3 4 forced minimum size"); l.add(null, "4 . forced maximum size"); l.add(null, "2 3 time-server specify name of time server"); l.add(null, "3 . name of server"); l.add(null, "2 3 time-zone specify time zone"); l.add(null, "3 . name of time zone"); l.add(null, "2 3 time-proxy specify proxy profile"); l.add(null, "3 . name of profile"); l.add(null, "2 3 tftp-proxy specify proxy profile"); l.add(null, "3 . name of profile"); l.add(null, "2 3 http-agent specify http agent to fake"); l.add(null, "3 3,. name of faker"); l.add(null, "2 3 http-proxy specify proxy profile"); l.add(null, "3 . name of profile"); l.add(null, "2 3 mail-proxy specify proxy profile"); l.add(null, "3 . name of profile"); l.add(null, "2 3 mail-server specify name of mail server"); l.add(null, "3 . name of server"); l.add(null, "2 3 mail-username specify username on mail server"); l.add(null, "3 . set username"); l.add(null, "2 3 mail-password specify password on mail server"); l.add(null, "3 . set password"); l.add(null, "1 2 ipx ipx config commands"); l.add(null, "2 3 route configure static routes"); l.add(null, "3 4 name of routing table"); l.add(null, "4 5 destination network"); l.add(null, "5 6 destination mask"); l.add(null, "6 . forwarding router's address"); l.add(null, "1 2 ipv4 internet protocol config commands"); getHelpIpX(l); l.add(null, "2 3 pool configure address pool"); l.add(null, "3 4 name of address pool"); l.add(null, "4 5 first address in pool"); l.add(null, "5 6 increment in address format"); l.add(null, "6 . number of addresses"); l.add(null, "1 2 ipv6 internet protocol config commands"); getHelpIpX(l); l.add(null, "2 3 pool configure address pool"); l.add(null, "3 4 name of address pool"); l.add(null, "4 5 first address in pool"); l.add(null, "5 6 increment in address format"); l.add(null, "6 . number of addresses"); l.add(null, "1 2 scheduler configure a scheduler"); l.add(null, "2 . name of scheduler"); l.add(null, "1 2 script configure a script"); l.add(null, "2 . name of script"); l.add(null, "1 2 tracker configure a tracker"); l.add(null, "2 . name of tracker"); l.add(null, "1 2 mtracker configure a mtracker"); l.add(null, "2 . name of mtracker"); l.add(null, "1 2 alias configure a command alias"); l.add(null, "2 3 exec exec alias"); l.add(null, "2 3 show show alias"); l.add(null, "2 3 clear clear alias"); l.add(null, "2 3 packet packet alias"); l.add(null, "2 3 flash flash alias"); l.add(null, "2 3 test test alias"); l.add(null, "3 4 name of new command"); l.add(null, "4 . hidden hide the command"); l.add(null, "4 . error-free check errors before the 2nd command"); l.add(null, "4 5 command specify command to execute"); l.add(null, "5 5,. command"); l.add(null, "4 5 cmd2nd specify 2nd command to execute"); l.add(null, "5 5,. command"); l.add(null, "4 5 cmd3rd specify 3rd command to execute"); l.add(null, "5 5,. command"); l.add(null, "4 5 cmd4th specify 4th command to execute"); l.add(null, "5 5,. command"); l.add(null, "4 5 cmd5th specify 5th command to execute"); l.add(null, "5 5,. command"); l.add(null, "4 5 description specify help description"); l.add(null, "5 5,. help text"); l.add(null, "4 . sticky-onlychanged execute only if change happened"); l.add(null, "4 . sticky-onlysuccess remember the choice only if succeeded"); l.add(null, "4 . sticky-persistent no need to execute during bootup"); l.add(null, "4 5 sticky-extpersist read state from file during bootup"); l.add(null, "5 5,. file name"); l.add(null, "4 5 sticky-param specify sticky parameter"); l.add(null, "5 5,. parameter text"); l.add(null, "4 5 default-param specify default parameter"); l.add(null, "5 5,. parameter text"); l.add(null, "4 5 parameter specify parameter existence"); l.add(null, "5 . forbidden no parameters"); l.add(null, "5 . required need parameters"); l.add(null, "5 . optional parameters allowed"); l.add(null, "4 5 param2nd specify 2nd parameter existence"); l.add(null, "5 . forbidden no parameters"); l.add(null, "5 . required need parameters"); l.add(null, "5 . optional parameters allowed"); l.add(null, "4 5 param3rd specify 3rd parameter existence"); l.add(null, "5 . forbidden no parameters"); l.add(null, "5 . required need parameters"); l.add(null, "5 . optional parameters allowed"); l.add(null, "4 5 param4th specify 4th parameter existence"); l.add(null, "5 . forbidden no parameters"); l.add(null, "5 . required need parameters"); l.add(null, "5 . optional parameters allowed"); l.add(null, "4 5 param5th specify 5th parameter existence"); l.add(null, "5 . forbidden no parameters"); l.add(null, "5 . required need parameters"); l.add(null, "5 . optional parameters allowed"); l.add(null, "1 2 router enable a routing protocol"); cfgRtr.getRouterList(l, 0, " to configure"); l.add(null, "3 4,. process id"); l.add(null, "4 5 vrf bind a vrf"); l.add(null, "5 . vrf to bind to"); l.add(null, "1 2 chat-script build a chat script"); l.add(null, "2 . name of script"); l.add(null, "1 2 object-group build an object group"); l.add(null, "2 3 network network entries"); l.add(null, "3 . name of object group"); l.add(null, "2 3 port port entries"); l.add(null, "3 . name of object group"); l.add(null, "1 2 access-list build an access list"); l.add(null, "2 . name of access list"); l.add(null, "1 2 telemetry telemetry configuration"); l.add(null, "2 . name of destination"); l.add(null, "1 2 event-manager build an event manager"); l.add(null, "2 . name of event manager"); l.add(null, "1 2 prefix-list build a prefix list"); l.add(null, "2 . name of prefix list"); l.add(null, "1 2 route-map build a route map"); l.add(null, "2 . name of route map"); l.add(null, "1 2 route-policy build a route policy"); l.add(null, "2 . name of route policy"); l.add(null, "1 2 policy-map build a policy map"); l.add(null, "2 . name of policy map"); l.add(null, "1 2 aaa authentication configuration"); l.add(null, "2 3 userlist build a user list"); l.add(null, "3 . name of authenticator"); l.add(null, "2 3 radius set up a radius client"); l.add(null, "3 . name of authenticator"); l.add(null, "2 3 tacacs set up a tacacs client"); l.add(null, "3 . name of authenticator"); l.add(null, "2 3 list set up an aaa list"); l.add(null, "3 . name of authenticator"); l.add(null, "1 2 vpdn vpdn client parameters"); l.add(null, "2 . name of client"); l.add(null, "1 2 proxy-profile proxy profile parameters"); l.add(null, "2 . name of profile"); l.add(null, "1 2 time-map time map parameters"); l.add(null, "2 . name of profile"); l.add(null, "1 2 crypto cryptographic configuration"); l.add(null, "2 3 ipsec ipsec profile"); l.add(null, "3 . name of profile"); l.add(null, "2 3 rsakey rsa key"); l.add(null, "3 4 name of key"); l.add(null, "4 5 import import key"); l.add(null, "5 . base64 encoded private key"); l.add(null, "4 5 external load key from file"); l.add(null, "5 . file name"); l.add(null, "4 5,. generate generate new key"); l.add(null, "5 . [size] key size in bits"); l.add(null, "4 . zeroize delete the key"); l.add(null, "4 . editor import in editor"); l.add(null, "2 3 dsakey dsa key"); l.add(null, "3 4 name of key"); l.add(null, "4 5 import import key"); l.add(null, "5 . base64 encoded private key"); l.add(null, "4 5 external load key from file"); l.add(null, "5 . file name"); l.add(null, "4 5,. generate generate new key"); l.add(null, "5 . [size] key size in bits"); l.add(null, "4 . zeroize delete the key"); l.add(null, "4 . editor import in editor"); l.add(null, "2 3 ecdsakey ecdsa key"); l.add(null, "3 4 name of key"); l.add(null, "4 5 import import key"); l.add(null, "5 . base64 encoded private key"); l.add(null, "4 5 external load key from file"); l.add(null, "5 . file name"); l.add(null, "4 5,. generate generate new key"); l.add(null, "5 . [size] key size in bits"); l.add(null, "4 . zeroize delete the key"); l.add(null, "4 . editor import in editor"); l.add(null, "2 3 certificate certificate"); l.add(null, "3 4 name of certificate"); l.add(null, "4 5 import import certificate"); l.add(null, "5 6 rsa rsa key"); l.add(null, "6 7 name of key"); l.add(null, "7 . base64 encoded certificate"); l.add(null, "5 6 dsa dsa key"); l.add(null, "6 7 name of key"); l.add(null, "7 . base64 encoded certificate"); l.add(null, "5 6 ecdsa ecdsa key"); l.add(null, "6 7 name of key"); l.add(null, "7 . base64 encoded certificate"); l.add(null, "4 5 external load certificate from file"); l.add(null, "5 6 rsa rsa key"); l.add(null, "6 7 name of key"); l.add(null, "7 . file name"); l.add(null, "5 6 dsa dsa key"); l.add(null, "6 7 name of key"); l.add(null, "7 . file name"); l.add(null, "5 6 ecdsa ecdsa key"); l.add(null, "6 7 name of key"); l.add(null, "7 . file name"); l.add(null, "4 5 generate generate new certificate"); l.add(null, "5 6 rsa rsa key"); l.add(null, "6 7,. name of key"); l.add(null, "7 8,. identifier to give"); l.add(null, "8 . validity in days"); l.add(null, "5 6 dsa dsa key"); l.add(null, "6 7,. name of key"); l.add(null, "7 8,. identifier to give"); l.add(null, "8 . validity in days"); l.add(null, "5 6 ecdsa ecdsa key"); l.add(null, "6 7,. name of key"); l.add(null, "7 8,. identifier to give"); l.add(null, "8 . validity in days"); l.add(null, "4 . zeroize delete the certificate"); l.add(null, "4 5 editor import in editor"); l.add(null, "5 6 rsa rsa key"); l.add(null, "6 . name of key"); l.add(null, "5 6 dsa dsa key"); l.add(null, "6 . name of key"); l.add(null, "5 6 ecdsa ecdsa key"); l.add(null, "6 . name of key"); l.add(null, "1 2 xconnect define one protocol cross connection"); l.add(null, "2 . name of connection"); l.add(null, "1 2 menu define one menu"); l.add(null, "2 3 key letter based"); l.add(null, "3 . name of menu"); l.add(null, "2 3 tui tui based"); l.add(null, "3 . name of menu"); userHelping k = new userHelping(); k.expand = true; k.add(null, "4 5 vrf bind a vrf"); k.add(null, "5 4,. vrf to bind to"); k.add(null, "4 5 interface bind an interface"); k.add(null, "5 4,. interface to bind to"); l.add(null, "1 2 server create new or update existing server process"); servGenList.srvHelp(l, 2, " to configure", k); } private byte[] cmdGetRem() { return bits.byteConcat(cmd.getRemaining().getBytes(), pipeSide.getEnding(pipeSide.modTyp.modeCRLF)); } private void doGlobal() { String a = cmd.word(); if (a.equals("hostname")) { cfgAll.hostName = cmd.word(); return; } if (a.equals("locale")) { cfgAll.locale = cmd.word(); return; } if (a.equals("enable")) { cfgAll.enaPass = authLocal.secretDecode(cmd.word()); return; } if (a.equals("password-encrypt")) { cfgAll.passEnc = authLocal.passwdDecode(cmd.word()); return; } if (a.equals("buggy")) { cfgAll.buggy = true; return; } if (a.equals("banner")) { a = cmd.word(); if (a.equals("set")) { cfgAll.banner = cmdGetRem(); return; } if (a.equals("add")) { cfgAll.banner = bits.byteConcat(cfgAll.banner, cmdGetRem()); return; } if (a.equals("encoded")) { cfgAll.banner = encBase64.decodeBytes(cmd.getRemaining()); if (cfgAll.banner == null) { cfgAll.banner = new byte[0]; } return; } cmd.badCmd(); return; } if (a.equals("vdc")) { if (cfgAll.evalVdcPrivs()) { cmd.error("not in a vdc"); return; } a = cmd.word(); if (a.equals("definition")) { a = cmd.word(); modeDconfig = cfgAll.vdcFind(a, true); if (modeDconfig == null) { cmd.error("bad vdc name"); return; } modeV = modes.config; return; } cmd.badCmd(); return; } if (a.equals("process")) { if (cfgAll.evalVdcPrivs()) { cmd.error("not in a vdc"); return; } a = cmd.word(); if (a.equals("definition")) { a = cmd.word(); modeDconfig = cfgAll.prcFind(a, true); if (modeDconfig == null) { cmd.error("bad process name"); return; } modeV = modes.config; return; } cmd.badCmd(); return; } if (a.equals("vrf")) { a = cmd.word(); if (a.equals("definition")) { a = cmd.word(); modeDconfig = cfgAll.vrfFind(a, true); if (modeDconfig == null) { cmd.error("bad vrf name"); return; } modeV = modes.config; return; } cmd.badCmd(); return; } if (a.equals("interface")) { modeDconfig = cfgAll.ifcFind(cmd.word(), 1); if (modeDconfig == null) { cmd.error("no such interface"); return; } modeV = modes.config; return; } if (a.equals("bridge")) { modeDconfig = cfgAll.brdgFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid bridge number"); return; } modeV = modes.config; return; } if (a.equals("bundle")) { modeDconfig = cfgAll.bndlFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid bundle number"); return; } modeV = modes.config; return; } if (a.equals("hairpin")) { modeDconfig = cfgAll.hrpnFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid hairpin number"); return; } modeV = modes.config; return; } if (a.equals("session")) { modeDconfig = cfgAll.sessnFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid session name"); return; } modeV = modes.config; return; } if (a.equals("check")) { modeDconfig = cfgAll.checkFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid check name"); return; } modeV = modes.config; return; } if (a.equals("sensor")) { modeDconfig = cfgAll.sensorFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid sensor name"); return; } modeV = modes.config; return; } if (a.equals("dial-peer")) { modeDconfig = cfgAll.dialFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid dial peer number"); return; } modeV = modes.config; return; } if (a.equals("translation-rule")) { modeDconfig = cfgAll.trnsltnFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid translation rule number"); return; } modeV = modes.config; return; } if (a.equals("nsh")) { int p = bits.str2num(cmd.word()); int i = bits.str2num(cmd.word()); tabNshEntry ntry = new tabNshEntry(p, i); ntry.doCfgStr(cmd); tabNshEntry.services.put(ntry); return; } if (a.equals("router")) { tabRouteAttr.routeType o = cfgRtr.name2num(cmd.word()); if (o == null) { cmd.error("invalid routing protocol"); return; } cfgRtr rtr = cfgAll.rtrFind(o, bits.str2num(cmd.word()), true); if (rtr == null) { cmd.error("bad process number"); return; } modeDconfig = rtr; cmds c = cmd.copyBytes(false); modeV = modes.config; if (!cmd.word().equals("vrf")) { return; } a = c.getRemaining(); userHelping hlp = getHelping(false, true, true); reader.setContext(hlp, ""); String b = hlp.repairLine(a); if (b.length() < 1) { pipe.linePut("bad: " + a); modeV = modes.global; reader.setContext(hlp, ""); return; } rtr.embedVrf = true; executeCommand(c.getRemaining()); return; } if (a.equals("scheduler")) { modeDconfig = cfgAll.schedFind(cmd.word(), true); if (modeDconfig == null) { return; } modeV = modes.config; return; } if (a.equals("script")) { modeDconfig = cfgAll.scrptFind(cmd.word(), true); if (modeDconfig == null) { return; } modeV = modes.config; return; } if (a.equals("tracker")) { modeDconfig = cfgAll.trackFind(cmd.word(), true); if (modeDconfig == null) { return; } modeV = modes.config; return; } if (a.equals("mtracker")) { modeDconfig = cfgAll.mtrackFind(cmd.word(), true); if (modeDconfig == null) { return; } modeV = modes.config; return; } if (a.equals("alias")) { a = cmd.word(); cfgAlias ntry = cfgAll.aliasFind(cmd.word(), cfgAlias.string2type(a), true); ntry.doCfgStr(cmd); return; } if (a.equals("ipx")) { doCmdIpx(); return; } if (a.equals("ipv4")) { doCmdIp4(); return; } if (a.equals("ipv6")) { doCmdIp6(); return; } if (a.equals("logging")) { doCmdLogging(); return; } if (a.equals("crypto")) { doCmdCrypto(); return; } if (a.equals("chat-script")) { modeDconfig = cfgAll.chatFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad script name"); return; } modeV = modes.config; return; } if (a.equals("object-group")) { a = cmd.word(); if (a.equals("network")) { modeDconfig = cfgAll.objnetFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad object group name"); return; } modeV = modes.config; return; } if (a.equals("port")) { modeDconfig = cfgAll.objprtFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad object group name"); return; } modeV = modes.config; return; } return; } if (a.equals("access-list")) { modeDconfig = cfgAll.aclsFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad access list name"); return; } modeV = modes.config; return; } if (a.equals("telemetry")) { modeDconfig = cfgAll.tlmdsFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad destination name"); return; } modeV = modes.config; return; } if (a.equals("event-manager")) { modeDconfig = cfgAll.eemFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad event manager name"); return; } modeV = modes.config; return; } if (a.equals("xconnect")) { modeDconfig = cfgAll.xconFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad connect name"); return; } modeV = modes.config; return; } if (a.equals("vnet")) { modeDconfig = cfgAll.vnetFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad vnet name"); return; } modeV = modes.config; return; } if (a.equals("vpdn")) { modeDconfig = cfgAll.vpdnFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad vpdn name"); return; } modeV = modes.config; return; } if (a.equals("proxy-profile")) { modeDconfig = cfgAll.proxyFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad proxy name"); return; } modeV = modes.config; return; } if (a.equals("time-map")) { modeDconfig = cfgAll.timeFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad time name"); return; } modeV = modes.config; return; } if (a.equals("prefix-list")) { modeDconfig = cfgAll.prfxFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad prefix list name"); return; } modeV = modes.config; return; } if (a.equals("route-map")) { modeDconfig = cfgAll.rtmpFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad route map name"); return; } modeV = modes.config; return; } if (a.equals("route-policy")) { modeDconfig = cfgAll.rtplFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad route policy name"); return; } modeV = modes.config; return; } if (a.equals("policy-map")) { modeDconfig = cfgAll.plmpFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad policy map name"); return; } modeV = modes.config; return; } if (a.equals("console0")) { modeDconfig = cfgAll.con0; modeV = modes.config; return; } if (a.equals("line")) { modeDconfig = cfgAll.linFind(cmd.word()); if (modeDconfig == null) { cmd.error("invalid line name"); return; } modeV = modes.config; return; } if (a.equals("menu")) { a = cmd.word(); if (a.equals("key")) { modeDconfig = cfgAll.menuKfind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid menu name"); return; } modeV = modes.config; return; } if (a.equals("tui")) { modeDconfig = cfgAll.menuTfind(cmd.word(), true); if (modeDconfig == null) { cmd.error("invalid menu name"); return; } modeV = modes.config; return; } cmd.badCmd(); return; } if (a.equals("aaa")) { cfgAuther.methodType i = cfgAuther.string2auther(cmd.word()); if (i == null) { cmd.badCmd(); return; } modeDconfig = cfgAll.autherFind(cmd.word(), i); if (modeDconfig == null) { cmd.error("invalid authenticator name"); return; } modeV = modes.config; return; } if (a.equals("server")) { a = cmd.word(); modeDserver = servGenList.srvFind(a, cmd.word(), true); if (modeDserver == null) { cmd.error("invalid server"); return; } modeV = modes.server; boolean b = false; for (;;) { a = cmd.word(); if (a.length() < 1) { break; } if (a.equals("vrf")) { a = cmd.word(); modeDserver.srvVrf = cfgAll.vrfFind(a, false); b = true; continue; } if (a.equals("interface")) { a = cmd.word(); modeDserver.srvIface = cfgAll.ifcFind(a, 0); b = true; continue; } } if (!b) { return; } modeDserver.srvEmbedVrf |= b; modeDserver.srvInit(); return; } if (a.equals("client")) { doCmdClient(); return; } if (!a.equals(cmds.negated)) { cmd.badCmd(); return; } a = cmd.word(); if (a.equals("locale")) { cfgAll.locale = null; return; } if (a.equals("enable")) { cfgAll.enaPass = null; return; } if (a.equals("password-encrypt")) { cfgAll.passEnc = null; return; } if (a.equals("buggy")) { cfgAll.buggy = false; return; } if (a.equals("vdc")) { a = cmd.word(); if (a.equals("definition")) { a = cmd.word(); cfgVdc vdc = cfgAll.vdcDel(a); if (vdc == null) { cmd.error("no such vdc"); return; } return; } cmd.badCmd(); return; } if (a.equals("process")) { a = cmd.word(); if (a.equals("definition")) { a = cmd.word(); cfgPrcss prc = cfgAll.prcDel(a); if (prc == null) { cmd.error("no such process"); return; } prc.stopNow(); return; } cmd.badCmd(); return; } if (a.equals("banner")) { cfgAll.banner = new byte[0]; return; } if (a.equals("vrf")) { a = cmd.word(); if (a.equals("definition")) { a = cmd.word(); cfgVrf vrf = cfgAll.vrfDel(a); if (vrf == null) { cmd.error("no such vrf"); return; } return; } cmd.badCmd(); return; } if (a.equals("bridge")) { cfgBrdg ntry = cfgAll.brdgDel(cmd.word()); if (ntry == null) { cmd.error("invalid bridge number"); return; } return; } if (a.equals("bundle")) { cfgBndl ntry = cfgAll.bndlDel(cmd.word()); if (ntry == null) { cmd.error("invalid bundle number"); return; } return; } if (a.equals("hairpin")) { cfgHrpn ntry = cfgAll.hrpnDel(cmd.word()); if (ntry == null) { cmd.error("invalid hairpin number"); return; } return; } if (a.equals("session")) { cfgSessn ntry = cfgAll.sessnDel(cmd.word()); if (ntry == null) { cmd.error("invalid session name"); return; } return; } if (a.equals("check")) { cfgCheck ntry = cfgAll.checkDel(cmd.word()); if (ntry == null) { cmd.error("invalid check name"); return; } return; } if (a.equals("sensor")) { cfgSensor ntry = cfgAll.sensorDel(cmd.word()); if (ntry == null) { cmd.error("invalid sensor name"); return; } return; } if (a.equals("dial-peer")) { cfgDial ntry = cfgAll.dialDel(cmd.word()); if (ntry == null) { cmd.error("invalid dial peer number"); return; } return; } if (a.equals("translation-rule")) { cfgTrnsltn ntry = cfgAll.trnsltnDel(cmd.word()); if (ntry == null) { cmd.error("invalid translation rule number"); return; } return; } if (a.equals("nsh")) { int p = bits.str2num(cmd.word()); int i = bits.str2num(cmd.word()); tabNshEntry ntry = new tabNshEntry(p, i); if (tabNshEntry.services.del(ntry) == null) { cmd.error("invalid nsh number"); return; } return; } if (a.equals("router")) { tabRouteAttr.routeType o = cfgRtr.name2num(cmd.word()); if (o == null) { cmd.error("invalid routing protocol"); return; } cfgRtr ntry = cfgAll.rtrDel(o, bits.str2num(cmd.word())); if (ntry == null) { cmd.error("bad process number"); return; } return; } if (a.equals("interface")) { if (cfgAll.ifcDel(cmd.word(), true)) { cmd.error("error deleting interface"); return; } return; } if (a.equals("scheduler")) { cfgSched ntry = cfgAll.schedDel(cmd.word()); if (ntry == null) { cmd.error("no such scheduler"); return; } ntry.doCfgStr(new cmds("cfg", "stop")); return; } if (a.equals("script")) { cfgScrpt ntry = cfgAll.scrptDel(cmd.word()); if (ntry == null) { cmd.error("no such script"); return; } ntry.doCfgStr(new cmds("cfg", "stop")); return; } if (a.equals("tracker")) { cfgTrack ntry = cfgAll.trackDel(cmd.word()); if (ntry == null) { cmd.error("no such tracker"); return; } ntry.doCfgStr(new cmds("cfg", "stop")); return; } if (a.equals("mtracker")) { cfgMtrack ntry = cfgAll.mtrackDel(cmd.word()); if (ntry == null) { cmd.error("no such mtracker"); return; } ntry.doCfgStr(new cmds("cfg", "stop")); return; } if (a.equals("ipx")) { doCmdNoIpx(); return; } if (a.equals("ipv4")) { doCmdNoIp4(); return; } if (a.equals("ipv6")) { doCmdNoIp6(); return; } if (a.equals("alias")) { a = cmd.word(); cfgAlias ntry = cfgAll.aliasFind(cmd.word(), cfgAlias.string2type(a), true); cmd = new cmds("c", cmds.negated + cmds.tabulator + cmd.getRemaining()); ntry.doCfgStr(cmd); if (ntry.command.length() > 0) { return; } cfgAll.aliasDel(ntry.name, cfgAlias.string2type(a)); return; } if (a.equals("logging")) { doCmdNoLogging(); return; } if (a.equals("crypto")) { doCmdNoCrypto(); return; } if (a.equals("chat-script")) { cfgChat prf = cfgAll.chatDel(cmd.word()); if (prf == null) { cmd.error("no such script"); return; } return; } if (a.equals("object-group")) { a = cmd.word(); if (a.equals("network")) { cfgObjnet prf = cfgAll.objnetDel(cmd.word()); if (prf == null) { cmd.error("no such object group"); return; } return; } if (a.equals("port")) { cfgObjprt prf = cfgAll.objprtDel(cmd.word()); if (prf == null) { cmd.error("no such object group"); return; } return; } return; } if (a.equals("access-list")) { cfgAceslst prf = cfgAll.aclsDel(cmd.word()); if (prf == null) { cmd.error("no such access list"); return; } return; } if (a.equals("telemetry")) { cfgTlmtry prf = cfgAll.tlmdsDel(cmd.word()); if (prf == null) { cmd.error("no such destination"); return; } prf.worker.stopWork(); return; } if (a.equals("event-manager")) { cfgEvntmgr prf = cfgAll.eemDel(cmd.word()); if (prf == null) { cmd.error("no such event manager"); return; } return; } if (a.equals("xconnect")) { cfgXconn prf = cfgAll.xconDel(cmd.word()); if (prf == null) { cmd.error("no such connect"); return; } return; } if (a.equals("vnet")) { cfgVnet prf = cfgAll.vnetDel(cmd.word()); if (prf == null) { cmd.error("bad vnet name"); return; } return; } if (a.equals("vpdn")) { cfgVpdn prf = cfgAll.vpdnDel(cmd.word()); if (prf == null) { cmd.error("no such vpdn"); return; } return; } if (a.equals("proxy-profile")) { cfgProxy prf = cfgAll.proxyDel(cmd.word()); if (prf == null) { cmd.error("no such profile"); return; } return; } if (a.equals("time-map")) { cfgTime prf = cfgAll.timeDel(cmd.word()); if (prf == null) { cmd.error("no such profile"); return; } return; } if (a.equals("prefix-list")) { cfgPrfxlst prf = cfgAll.prfxDel(cmd.word()); if (prf == null) { cmd.error("no such prefix list"); return; } return; } if (a.equals("route-map")) { cfgRoump prf = cfgAll.rtmpDel(cmd.word()); if (prf == null) { cmd.error("no such route map"); return; } return; } if (a.equals("route-policy")) { cfgRouplc prf = cfgAll.rtplDel(cmd.word()); if (prf == null) { cmd.error("no such route policy"); return; } return; } if (a.equals("policy-map")) { cfgPlymp prf = cfgAll.plmpDel(cmd.word()); if (prf == null) { cmd.error("no such policy map"); return; } return; } if (a.equals("aaa")) { cfgAuther.methodType i = cfgAuther.string2auther(cmd.word()); if (i == null) { cmd.badCmd(); return; } cfgAuther prf = cfgAll.autherDel(cmd.word()); if (prf == null) { cmd.error("no such authenticator"); return; } return; } if (a.equals("line")) { cmd.error("cannot delete physical line"); return; } if (a.equals("menu")) { a = cmd.word(); if (a.equals("key")) { cfgMenuK prf = cfgAll.menuKdel(cmd.word()); if (prf == null) { cmd.error("no such menu"); return; } return; } if (a.equals("tui")) { cfgMenuT prf = cfgAll.menuTdel(cmd.word()); if (prf == null) { cmd.error("no such menu"); return; } return; } cmd.badCmd(); return; } if (a.equals("server")) { a = cmd.word(); servGeneric ntry = servGenList.srvDel(a, cmd.word()); if (ntry == null) { cmd.error("invalid server"); return; } return; } if (a.equals("client")) { doCmdNoClient(); return; } cmd.badCmd(); } private int parseUpRxtx() { String a = cmd.word(); if (a.equals("receive")) { return 1; } if (a.equals("transmit")) { return 2; } if (a.equals("both")) { return 3; } if (a.equals("none")) { return 0; } return 3; } private void parseUpMcast(int p, boolean b) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwd fwd; if (p == 4) { fwd = vrf.fwd4; } else { fwd = vrf.fwd6; } String a = cmd.word(); if (a.equals("join-group")) { addrIP a1 = new addrIP(); addrIP a2 = new addrIP(); if (a1.fromString(cmd.word())) { cmd.error("bad group address"); return; } if (!a1.isMulticast()) { cmd.error("not a multicast address"); return; } if (a2.fromString(cmd.word())) { cmd.error("bad source address"); return; } if (b) { fwd.mcastAddFloodIfc(a1, a2, null, -2); } else { fwd.mcastDelFloodIfc(a1, a2, null); } return; } cmd.badCmd(); } private cfgVrf parseUpPbr(int p, tabPbrN ntry) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return null; } ipFwd fwd; if (p == 4) { fwd = vrf.fwd4; } else { fwd = vrf.fwd6; } String s = cmd.getRemaining(); String a = cmd.word(); if (a.equals("reindex")) { int i = bits.str2num(cmd.word()); fwd.pbrCfg.reindex(i, bits.str2num(cmd.word())); return null; } ntry.sequence = fwd.pbrCfg.nextseq(); if (ntry.fromString(p, s)) { return null; } ntry.matcher.copyCores(fwd.pbrCfg); return vrf; } private cfgVrf parseUpNat(int p, tabNatCfgN ntry, boolean neg) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return null; } ipFwd fwd; if (p == 4) { fwd = vrf.fwd4; } else { fwd = vrf.fwd6; } String s = cmd.getRemaining(); String a = cmd.word(); if (a.equals("reindex")) { if (neg) { return null; } int i = bits.str2num(cmd.word()); fwd.natCfg.reindex(i, bits.str2num(cmd.word())); return null; } ntry.sequence = fwd.natCfg.nextseq(); int res = ntry.fromString(p, s, neg); switch (res) { case 0: // entry if (ntry.origSrcList != null) { ntry.origSrcList.copyCores(fwd.natCfg); } return vrf; case 1: // error return null; default: break; } tabNatCfgN old = fwd.natCfg.find(ntry); if (old == null) { return null; } old.fromString(p, s, neg); return null; } private void parseUpFlow(int ver, boolean create) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwd fwd; if (ver == 4) { fwd = vrf.fwd4; } else { fwd = vrf.fwd6; } String a = cmd.word(); if (a.equals("parameters")) { if (fwd.netflow == null) { cmd.error("not enabled"); return; } fwd.netflow.session.fromString(cmd); return; } if (fwd.netflow != null) { fwd.netflow.stopTimer(); } fwd.netflow = null; if (!create) { return; } if (a.equals("collect")) { fwd.netflow = new clntNetflow(ver); fwd.netflow.startTimer(); return; } if (!a.equals("export")) { cmd.badCmd(); return; } clntNetflow flw = new clntNetflow(ver); cfgProxy prx = cfgAll.proxyFind(cmd.word(), false); if (prx == null) { cmd.error("no such profile"); return; } flw.proxy = prx.proxy; flw.trgAddr = new addrIP(); if (flw.trgAddr.fromString(cmd.word())) { cmd.error("bad address"); return; } flw.trgPort = bits.str2num(cmd.word()); flw.startTimer(); fwd.netflow = flw; } private void parseUpPool(int ver, boolean create) { String nam = cmd.word(); addrIPv4 net4 = new addrIPv4(); addrIPv4 inc4 = new addrIPv4(); addrIPv6 net6 = new addrIPv6(); addrIPv6 inc6 = new addrIPv6(); if (ver == 4) { if (net4.fromString(cmd.word())) { return; } if (inc4.fromString(cmd.word())) { return; } } else { if (net6.fromString(cmd.word())) { return; } if (inc6.fromString(cmd.word())) { return; } } int num = bits.str2num(cmd.word()); if (!create) { if (ver == 4) { cfgAll.poolDel(cfgAll.ip4pool, nam); } else { cfgAll.poolDel(cfgAll.ip6pool, nam); } return; } if (ver == 4) { cfgPool pool = cfgAll.poolFind(cfgAll.ip4pool, nam, true); pool.setup(ver, net4, inc4, num); pool.pool.poolName = nam; pool.name = nam; } else { cfgPool pool = cfgAll.poolFind(cfgAll.ip6pool, nam, true); pool.setup(ver, net6, inc6, num); pool.pool.poolName = nam; pool.name = nam; } } private void getHelpIpX(userHelping l) { l.add(null, "2 3 multicast configure multicast parameters"); l.add(null, "3 4 name of routing table"); l.add(null, "4 5 join-group unconditionally process multicast traffic"); l.add(null, "5 6 group address"); l.add(null, "6 . source address"); l.add(null, "2 3 flow configure netflow parameters"); l.add(null, "3 4 name of routing table"); l.add(null, "4 . collect just collect"); l.add(null, "4 5,. parameters session parameters"); l.add(null, "5 6 timeout set timeout"); l.add(null, "6 5,. timeout in ms"); l.add(null, "5 6 sessions set session limit"); l.add(null, "6 5,. number of sessions"); l.add(null, "5 6 rate specify translation rate"); l.add(null, "6 5,. name of policy map"); l.add(null, "5 5,. before log on session start"); l.add(null, "5 5,. after log on session stop"); l.add(null, "4 5 export collect and export"); l.add(null, "5 6 proxy profile"); l.add(null, "6 7 target address"); l.add(null, "7 . port number"); l.add(null, "2 3 pbr configure policy based routing"); l.add(null, "3 4,6 name of routing table"); l.add(null, "4 5,. reindex reindex pbrs"); l.add(null, "5 7,. [num] initial number to start with"); l.add(null, "7 . [num] increment number"); l.add(null, "4 5 sequence sequence number"); l.add(null, "5 6 number"); l.add(null, "6 7 access list name"); l.add(null, "7 8,. target vrf"); l.add(null, "8 9 interface set target interface"); l.add(null, "9 8,. interface name"); l.add(null, "8 9 nexthop set target address"); l.add(null, "9 8,. target address"); l.add(null, "8 9 nsh set target service"); l.add(null, "9 10 service path"); l.add(null, "10 8,. service index"); l.add(null, "2 3 nat configure network address translation"); l.add(null, "3 4,6 name of routing table"); l.add(null, "4 5,. reindex reindex nats"); l.add(null, "5 7,. [num] initial number to start with"); l.add(null, "7 . [num] increment number"); l.add(null, "4 5 sequence sequence number"); l.add(null, "5 6 number"); l.add(null, "6 . log-translations turn on logging"); l.add(null, "6 7 timeout specify timeout"); l.add(null, "7 . time in ms"); l.add(null, "6 7 sessions specify translation limit"); l.add(null, "7 . number of translations"); l.add(null, "6 7 rate specify translation rate"); l.add(null, "7 . name of policy map"); l.add(null, "6 7 randomize randomize source port"); l.add(null, "7 8 lowest port number"); l.add(null, "8 . highest port number"); l.add(null, "6 7 srclist source address translation"); l.add(null, "7 8 access list name"); l.add(null, "8 9 interface translated interface"); l.add(null, "9 . translated interface"); l.add(null, "8 9 pool translated pool"); l.add(null, "9 . translated pool"); l.add(null, "8 . translated address"); l.add(null, "6 7 source source address translation"); l.add(null, "7 8 original address"); l.add(null, "8 9 interface translated interface"); l.add(null, "9 . translated interface"); l.add(null, "8 9 pool translated pool"); l.add(null, "9 . translated pool"); l.add(null, "8 . translated address"); l.add(null, "7 8 interface original interface"); l.add(null, "8 9 original interface"); l.add(null, "9 10 interface translated interface"); l.add(null, "10 . translated interface"); l.add(null, "9 10 pool translated pool"); l.add(null, "10 . translated pool"); l.add(null, "9 . translated address"); l.add(null, "6 7 target target address translation"); l.add(null, "7 8 original address"); l.add(null, "8 9 interface translated interface"); l.add(null, "9 . translated interface"); l.add(null, "8 . translated address"); l.add(null, "7 8 interface original interface"); l.add(null, "8 9 original interface"); l.add(null, "9 10 interface translated interface"); l.add(null, "10 . translated interface"); l.add(null, "9 . translated address"); l.add(null, "6 7 srcport source address translation"); l.add(null, "7 8 protocol number"); l.add(null, "8 9 original address"); l.add(null, "9 10 original port"); l.add(null, "10 11 interface translated interface"); l.add(null, "11 12 translated interface"); l.add(null, "12 . translated port"); l.add(null, "10 11 translated address"); l.add(null, "11 . translated port"); l.add(null, "8 9 interface original interface"); l.add(null, "9 10 original interface"); l.add(null, "10 11 original port"); l.add(null, "11 12 interface translated interface"); l.add(null, "12 13 translated interface"); l.add(null, "13 . translated port"); l.add(null, "11 12 translated address"); l.add(null, "12 . translated port"); l.add(null, "6 7 trgport target address translation"); l.add(null, "7 8 protocol number"); l.add(null, "8 9 original address"); l.add(null, "9 10 original port"); l.add(null, "10 11 interface translated interface"); l.add(null, "11 12 translated interface"); l.add(null, "12 . translated port"); l.add(null, "10 11 translated address"); l.add(null, "11 . translated port"); l.add(null, "8 9 interface original interface"); l.add(null, "9 10 original interface"); l.add(null, "10 11 original port"); l.add(null, "11 12 interface translated interface"); l.add(null, "12 13 translated interface"); l.add(null, "13 . translated port"); l.add(null, "11 12 translated address"); l.add(null, "12 . translated port"); l.add(null, "6 7 srcpref source address translation"); l.add(null, "7 8 original address"); l.add(null, "8 9 translated address"); l.add(null, "9 . address mask"); l.add(null, "6 7 trgpref target address translation"); l.add(null, "7 8 original address"); l.add(null, "8 9 translated address"); l.add(null, "9 . address mask"); l.add(null, "2 3 route configure static unicast routes"); l.add(null, "3 4 name of routing table"); l.add(null, "4 5 destination network"); l.add(null, "5 6 destination mask"); l.add(null, "6 7,. forwarding router's address"); l.add(null, "7 7,. recurigp use recursive nexthop"); l.add(null, "7 7,. recurbgp use recursive nexthop"); l.add(null, "7 7,. recurvpn use recursive nexthop"); l.add(null, "7 7,. mplsimp use mpls implicit null"); l.add(null, "7 7,. mplsexp use mpls explicit null"); l.add(null, "7 8 distance set distance metric"); l.add(null, "8 7,. distance value"); l.add(null, "7 8 metric set metric value"); l.add(null, "8 7,. metric value"); l.add(null, "7 8 tag set tag value"); l.add(null, "8 7,. tag value"); l.add(null, "7 8 id set id value"); l.add(null, "8 7,. id value"); l.add(null, "7 8 tracker set tracker to check"); l.add(null, "8 7,. tracker name"); l.add(null, "7 8 interface force to interface"); l.add(null, "8 7,. interface name"); l.add(null, "7 8 route-map set parameters from route map"); l.add(null, "8 7,. name of route map"); l.add(null, "7 8 route-policy set parameters from route policy"); l.add(null, "8 7,. name of route policy"); l.add(null, "2 3 mroute configure static multicast routes"); l.add(null, "3 4 name of routing table"); l.add(null, "4 5 destination network"); l.add(null, "5 6 destination mask"); l.add(null, "6 7,. forwarding router's address"); l.add(null, "7 7,. recurigp use recursive nexthop"); l.add(null, "7 7,. recurbgp use recursive nexthop"); l.add(null, "7 7,. recurvpn use recursive nexthop"); l.add(null, "7 8 distance set distance metric"); l.add(null, "8 7,. distance value"); l.add(null, "7 8 metric set metric value"); l.add(null, "8 7,. metric value"); l.add(null, "7 8 tag set tag value"); l.add(null, "8 7,. tag value"); l.add(null, "7 8 id set id value"); l.add(null, "8 7,. id value"); l.add(null, "7 8 tracker set tracker to check"); l.add(null, "8 7,. tracker name"); l.add(null, "7 8 interface force to interface"); l.add(null, "8 7,. interface name"); l.add(null, "7 8 route-map set parameters from route map"); l.add(null, "8 7,. name of route map"); l.add(null, "7 8 route-policy set parameters from route policy"); l.add(null, "8 7,. name of route policy"); } private void doCmdIpx() { String a = cmd.word(); if (a.equals("route")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { return; } tabRouteEntry ntry = ipxFwd.staticParse(cmd); if (ntry == null) { return; } vrf.ipx.staticAdd(ntry); return; } cmd.badCmd(); } private void doCmdNoIpx() { String a = cmd.word(); if (a.equals("route")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { return; } tabRouteEntry ntry = ipxFwd.staticParse(cmd); if (ntry == null) { return; } vrf.ipx.staticDel(ntry); return; } cmd.badCmd(); } private void doCmdIp4() { String a = cmd.word(); if (a.equals("multicast")) { parseUpMcast(4, true); return; } if (a.equals("flow")) { parseUpFlow(4, true); return; } if (a.equals("nat")) { tabNatCfgN red = new tabNatCfgN(); cfgVrf vrf = parseUpNat(4, red, false); if (vrf == null) { return; } vrf.fwd4.natCfg.add(red); vrf.fwd4.routerStaticChg(); return; } if (a.equals("pbr")) { tabPbrN red = new tabPbrN(); cfgVrf vrf = parseUpPbr(4, red); if (vrf == null) { return; } vrf.fwd4.pbrCfg.add(red); return; } if (a.equals("pool")) { parseUpPool(4, true); return; } if (a.equals("route")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwdRoute red = new ipFwdRoute(); if (red.fromString(4, cmd)) { return; } vrf.fwd4.staticDel(true, red); vrf.fwd4.staticAdd(true, red); return; } if (a.equals("mroute")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwdRoute red = new ipFwdRoute(); if (red.fromString(4, cmd)) { return; } vrf.fwd4.staticDel(false, red); vrf.fwd4.staticAdd(false, red); return; } cmd.badCmd(); } private void doCmdNoIp4() { String a = cmd.word(); if (a.equals("multicast")) { parseUpMcast(4, false); return; } if (a.equals("flow")) { parseUpFlow(4, false); return; } if (a.equals("nat")) { tabNatCfgN red = new tabNatCfgN(); cfgVrf vrf = parseUpNat(4, red, true); if (vrf == null) { return; } vrf.fwd4.natCfg.del(red); return; } if (a.equals("pbr")) { tabPbrN red = new tabPbrN(); cfgVrf vrf = parseUpPbr(4, red); if (vrf == null) { return; } vrf.fwd4.pbrCfg.del(red); return; } if (a.equals("pool")) { parseUpPool(4, false); return; } if (a.equals("route")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwdRoute red = new ipFwdRoute(); if (red.fromString(4, cmd)) { return; } vrf.fwd4.staticDel(true, red); return; } if (a.equals("mroute")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwdRoute red = new ipFwdRoute(); if (red.fromString(4, cmd)) { return; } vrf.fwd4.staticDel(false, red); return; } cmd.badCmd(); } private void doCmdIp6() { String a = cmd.word(); if (a.equals("multicast")) { parseUpMcast(6, true); return; } if (a.equals("flow")) { parseUpFlow(6, true); return; } if (a.equals("nat")) { tabNatCfgN red = new tabNatCfgN(); cfgVrf vrf = parseUpNat(6, red, false); if (vrf == null) { return; } vrf.fwd6.natCfg.add(red); vrf.fwd6.routerStaticChg(); return; } if (a.equals("pbr")) { tabPbrN red = new tabPbrN(); cfgVrf vrf = parseUpPbr(6, red); if (vrf == null) { return; } vrf.fwd6.pbrCfg.add(red); return; } if (a.equals("pool")) { parseUpPool(6, true); return; } if (a.equals("route")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwdRoute red = new ipFwdRoute(); if (red.fromString(6, cmd)) { return; } vrf.fwd6.staticDel(true, red); vrf.fwd6.staticAdd(true, red); return; } if (a.equals("mroute")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwdRoute red = new ipFwdRoute(); if (red.fromString(6, cmd)) { return; } vrf.fwd6.staticDel(false, red); vrf.fwd6.staticAdd(false, red); return; } cmd.badCmd(); } private void doCmdNoIp6() { String a = cmd.word(); if (a.equals("multicast")) { parseUpMcast(6, false); return; } if (a.equals("flow")) { parseUpFlow(6, false); return; } if (a.equals("nat")) { tabNatCfgN red = new tabNatCfgN(); cfgVrf vrf = parseUpNat(6, red, true); if (vrf == null) { return; } vrf.fwd6.natCfg.del(red); return; } if (a.equals("pbr")) { tabPbrN red = new tabPbrN(); cfgVrf vrf = parseUpPbr(6, red); if (vrf == null) { return; } vrf.fwd6.pbrCfg.del(red); return; } if (a.equals("pool")) { parseUpPool(6, false); return; } if (a.equals("route")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwdRoute red = new ipFwdRoute(); if (red.fromString(6, cmd)) { return; } vrf.fwd6.staticDel(true, red); return; } if (a.equals("mroute")) { cfgVrf vrf = cfgAll.vrfFind(cmd.word(), false); if (vrf == null) { cmd.error("no such vrf"); return; } ipFwdRoute red = new ipFwdRoute(); if (red.fromString(6, cmd)) { return; } vrf.fwd6.staticDel(false, red); return; } cmd.badCmd(); } private void doCmdNoLogging() { String s = cmd.word(); if (s.equals("debug")) { s = cmd.getRemaining().trim(); if (cfgAll.alwaysDebugs.indexOf(s) < 0) { return; } cfgAll.alwaysDebugs.remove(s); debugger.setByName(cmd, false); return; } if (s.equals("tracestop")) { cfgAll.tracebackStops = false; return; } if (s.equals("milliseconds")) { logger.logMillis = false; return; } if (s.equals("buffered")) { logger.logBufLev = logger.string2level(""); logger.bufferStart(0); return; } if (s.equals("monitor")) { logger.logPipLev = logger.string2level(""); return; } if (s.equals("file")) { logger.fileName(null); return; } if (s.equals("proxy")) { logger.logProxy = null; return; } if (s.equals("rotate")) { logger.fileRotate(null, 0, 0); return; } if (s.equals("syslog")) { for (int i = 0; i < logger.logSylHnd.size(); i++) { logger.logSylHnd.get(i).logStop(); } logger.logSylHnd = new ArrayList(); return; } if (s.equals("irc")) { logger.logIrcHnd.logStop(); logger.logIrcHnd = new clntIrc(null, null); return; } if (s.equals("format")) { logger.logPosForm = logger.string2format(""); return; } cmd.badCmd(); } private void doCmdLogging() { String s = cmd.word(); if (s.equals("debug")) { s = cmd.getRemaining().trim(); if (cfgAll.alwaysDebugs.indexOf(s) >= 0) { return; } cfgAll.alwaysDebugs.add(s); debugger.setByName(cmd, true); return; } if (s.equals("tracestop")) { cfgAll.tracebackStops = true; return; } if (s.equals("milliseconds")) { logger.logMillis = true; return; } if (s.equals("buffered")) { logger.logBufLev = logger.string2level(cmd.word()); logger.bufferStart(bits.str2num(cmd.word())); return; } if (s.equals("monitor")) { logger.logPipLev = logger.string2level(cmd.word()); return; } if (s.equals("file")) { logger.logFilLev = logger.string2level(cmd.word()); logger.fileName(cmd.word()); return; } if (s.equals("proxy")) { cfgProxy prx = cfgAll.proxyFind(cmd.word(), false); if (prx == null) { cmd.error("no such proxy"); return; } logger.logProxy = prx.proxy; return; } if (s.equals("rotate")) { int siz = bits.str2num(cmd.word()); s = cmd.word(); int tim = bits.str2num(cmd.word()); logger.fileRotate(s, siz, tim); return; } if (s.equals("syslog")) { for (int i = 0; i < logger.logSylHnd.size(); i++) { logger.logSylHnd.get(i).logStop(); } logger.logSylHnd = new ArrayList(); logger.logSylLev = logger.string2level(cmd.word()); logger.logSylFac = servSyslog.facility2num(cmd.word()); for (;;) { String a = cmd.word(); if (a.length() < 1) { break; } addrIP adr = new addrIP(); if (adr.fromString(a)) { continue; } logger.logSylHnd.add(new clntSyslog(adr, logger.logSylFac)); } return; } if (s.equals("irc")) { logger.logIrcHnd.logStop(); logger.logIrcLev = logger.string2level(cmd.word()); s = cmd.word(); logger.logIrcHnd = new clntIrc(s, cmd.word()); logger.logIrcHnd.logStart(); return; } if (s.equals("format")) { logger.logPosForm = logger.string2format(cmd.word()); return; } cmd.badCmd(); } private void doCmdNoClient() { String s = cmd.word(); if (s.equals("pastebin")) { cfgAll.pasteBin = null; return; } if (s.equals("capture-path")) { cfgAll.capturePath = null; return; } if (s.equals("bullying")) { cfgAll.clientShamer = null; return; } if (s.equals("whois-online")) { cfgAll.whoisOnline = null; return; } if (s.equals("whois-server")) { cfgAll.whoisServer = null; return; } if (s.equals("whois-option")) { cfgAll.whoisOption = null; return; } if (s.equals("whois-proxy")) { cfgAll.whoisProxy = null; return; } if (s.equals("end-format")) { cfgAll.endForm = 0; return; } if (s.equals("graceful-reload")) { cfgAll.graceReload = false; return; } if (s.equals("tcp-ecn")) { cfgAll.tcpEcn = false; return; } if (s.equals("tcp-keepalive")) { cfgAll.tcpKeepalive = false; return; } if (s.equals("tcp-timestamp")) { cfgAll.tcpTimStmp = false; return; } if (s.equals("prefer-ipv6")) { cfgAll.preferIpv6 = false; return; } if (s.equals("prefer-ipv4")) { cfgAll.preferIpv6 = true; return; } if (s.equals("ftp-passive")) { cfgAll.ftpPassive = false; return; } if (s.equals("ftp-active")) { cfgAll.ftpPassive = true; return; } if (s.equals("ftp-proxy")) { cfgAll.ftpProxy = null; return; } if (s.equals("pop3-proxy")) { cfgAll.pop3proxy = null; return; } if (s.equals("ssh-agent")) { cfgAll.sshAgent = null; return; } if (s.equals("proxy")) { cfgAll.clientProxy = null; return; } if (s.equals("domain-lookup")) { cfgAll.domainLookup = false; return; } if (s.equals("domain-name")) { cfgAll.domainName = null; return; } if (s.equals("name-proxy")) { cfgAll.nameServerProxy = null; return; } if (s.equals("name-server")) { cfgAll.nameServerAddr = new ArrayList(); return; } if (s.equals("upgrade-config")) { cfgAll.upgradeConfig = false; return; } if (s.equals("upgrade-revert")) { cfgAll.upgradeRevert = 0; return; } if (s.equals("upgrade-backup")) { cfgAll.upgradeBackup = false; return; } if (s.equals("upgrade-ownkey")) { cfgAll.upgradeOwnKey = false; return; } if (s.equals("upgrade-server")) { cfgAll.upgradeServer = verCore.homeUrl; return; } if (s.equals("upgrade-script")) { cfgAll.upgradeScript = null; return; } if (s.equals("upgrade-pubkey")) { cfgAll.upgradePubKey = null; return; } if (s.equals("config-server")) { cfgAll.configServer = null; return; } if (s.equals("config-username")) { cfgAll.configUser = null; return; } if (s.equals("config-password")) { cfgAll.configPass = null; return; } if (s.equals("config-save")) { cfgAll.configAsave = false; return; } if (s.equals("config-archive")) { cfgAll.configAbackup = false; return; } if (s.equals("config-backup")) { cfgAll.configBackup = null; return; } if (s.equals("config-exclusive")) { cfgAll.configExclusive = 0; return; } if (s.equals("time-server")) { if (cfgAll.timeServerName != null) { cfgAll.timeServerName.stopWork(); } cfgAll.timeServerName = null; return; } if (s.equals("time-zone")) { cfgAll.timeZoneName = "Z"; return; } if (s.equals("time-proxy")) { cfgAll.timeProxy = null; return; } if (s.equals("tftp-proxy")) { cfgAll.tftpProxy = null; return; } if (s.equals("http-agent")) { cfgAll.httpAgent = null; return; } if (s.equals("http-proxy")) { cfgAll.httpProxy = null; return; } if (s.equals("mail-proxy")) { cfgAll.mailProxy = null; return; } if (s.equals("mail-server")) { cfgAll.mailServerName = null; return; } if (s.equals("mail-username")) { cfgAll.mailServerUser = null; return; } if (s.equals("mail-password")) { cfgAll.mailServerPass = null; return; } cmd.badCmd(); } private void doCmdClient() { String a = cmd.word(); if (a.equals("pastebin")) { cfgAll.pasteBin = cmd.word(); return; } if (a.equals("capture-path")) { cfgAll.capturePath = cmd.word(); return; } if (a.equals("l2f-timer")) { cfgAll.l2fTimer = bits.str2num(cmd.word()); cfgAll.l2fRetry = bits.str2num(cmd.word()); return; } if (a.equals("l2tp2-timer")) { cfgAll.l2tp2hello = bits.str2num(cmd.word()); cfgAll.l2tp2retry = bits.str2num(cmd.word()); return; } if (a.equals("l2tp3-timer")) { cfgAll.l2tp3hello = bits.str2num(cmd.word()); cfgAll.l2tp3retry = bits.str2num(cmd.word()); return; } if (a.equals("bullying")) { servQuote ntry = new servQuote(); ntry.srvName = cmd.word(); ntry = cfgAll.dmnQuote.find(ntry, false); if (ntry == null) { cmd.error("no such server"); return; } cfgAll.clientShamer = ntry; return; } if (a.equals("label-range")) { cfgAll.labelRangeBeg = bits.str2num(cmd.word()); cfgAll.labelRangeEnd = bits.str2num(cmd.word()); return; } if (a.equals("cpuhog")) { cfgAll.cpuhogCheck = bits.str2num(cmd.word()); return; } if (a.equals("ifacestall")) { cfgAll.ifaceStallCheck = bits.str2num(cmd.word()); return; } if (a.equals("redundancy")) { cfgAll.redundancyKeep = bits.str2num(cmd.word()); cfgAll.redundancyHold = bits.str2num(cmd.word()); cfgAll.redundancyInit = bits.str2num(cmd.word()); return; } if (a.equals("whois-online")) { cfgAll.whoisOnline = new ArrayList(); for (;;) { a = cmd.word(); if (a.length() < 1) { break; } cfgAll.whoisOnline.add(a); } if (cfgAll.whoisOnline.size() > 0) { return; } cfgAll.whoisOnline = null; return; } if (a.equals("whois-server")) { cfgAll.whoisServer = cmd.getRemaining(); return; } if (a.equals("whois-option")) { cfgAll.whoisOption = cmd.getRemaining(); return; } if (a.equals("whois-proxy")) { cfgProxy prx = cfgAll.proxyFind(cmd.word(), false); if (prx == null) { cmd.error("no such proxy"); return; } cfgAll.whoisProxy = prx.proxy; return; } if (a.equals("end-format")) { cfgAll.endForm = 0; for (;;) { a = cmd.word(); if (a.length() < 1) { break; } if (a.equals("date")) { cfgAll.endForm |= 0x1; continue; } if (a.equals("image")) { cfgAll.endForm |= 0x2; continue; } if (a.equals("chksum")) { cfgAll.endForm |= 0x4; continue; } if (a.equals("user")) { cfgAll.endForm |= 0x8; continue; } if (a.equals("none")) { cfgAll.endForm = 0; continue; } } return; } if (a.equals("graceful-reload")) { cfgAll.graceReload = true; return; } if (a.equals("prefer-ipv6")) { cfgAll.preferIpv6 = true; return; } if (a.equals("prefer-ipv4")) { cfgAll.preferIpv6 = false; return; } if (a.equals("ipv4-tos")) { cfgAll.ipv4sendingTOS = bits.str2num(cmd.word()); return; } if (a.equals("ipv4-ttl")) { cfgAll.ipv4sendingTTL = bits.str2num(cmd.word()); return; } if (a.equals("ipv6-tos")) { cfgAll.ipv6sendingTOS = bits.str2num(cmd.word()); return; } if (a.equals("ipv6-ttl")) { cfgAll.ipv6sendingTTL = bits.str2num(cmd.word()); return; } if (a.equals("ipv4-checksum")) { int i = parseUpRxtx(); cfgAll.ipv4ChecksumRx = (i & 1) != 0; cfgAll.ipv4ChecksumTx = (i & 2) != 0; return; } if (a.equals("icmp4-checksum")) { int i = parseUpRxtx(); cfgAll.icmp4ChecksumRx = (i & 1) != 0; cfgAll.icmp4ChecksumTx = (i & 2) != 0; return; } if (a.equals("icmp6-checksum")) { int i = parseUpRxtx(); cfgAll.icmp6ChecksumRx = (i & 1) != 0; cfgAll.icmp6ChecksumTx = (i & 2) != 0; return; } if (a.equals("udp-checksum")) { int i = parseUpRxtx(); cfgAll.udpChecksumRx = (i & 1) != 0; cfgAll.udpChecksumTx = (i & 2) != 0; return; } if (a.equals("udp-portrange")) { cfgAll.udpRangeMin = bits.str2num(cmd.word()); cfgAll.udpRangeMax = bits.str2num(cmd.word()); return; } if (a.equals("tcp-timer")) { a = cmd.word(); if (a.equals("work")) { cfgAll.tcpTimeWork = bits.str2num(cmd.word()); return; } if (a.equals("alive")) { cfgAll.tcpTimeAlive = bits.str2num(cmd.word()); return; } if (a.equals("fin")) { cfgAll.tcpTimeFin = bits.str2num(cmd.word()); return; } if (a.equals("syn")) { cfgAll.tcpTimeSyn = bits.str2num(cmd.word()); return; } if (a.equals("open")) { cfgAll.tcpTimeOpen = bits.str2num(cmd.word()); return; } if (a.equals("close")) { cfgAll.tcpTimeClose = bits.str2num(cmd.word()); return; } if (a.equals("later")) { cfgAll.tcpTimeLater = bits.str2num(cmd.word()); return; } if (a.equals("now")) { cfgAll.tcpTimeNow = bits.str2num(cmd.word()); return; } if (a.equals("max")) { cfgAll.tcpTimeMax = bits.str2num(cmd.word()); return; } cmd.badCmd(); return; } if (a.equals("tcp-ecn")) { cfgAll.tcpEcn = true; return; } if (a.equals("tcp-keepalive")) { cfgAll.tcpKeepalive = true; return; } if (a.equals("tcp-timestamp")) { cfgAll.tcpTimStmp = true; return; } if (a.equals("tcp-segments")) { cfgAll.tcpSegmentMin = bits.str2num(cmd.word()); cfgAll.tcpSegmentMax = bits.str2num(cmd.word()); return; } if (a.equals("tcp-winscale")) { cfgAll.tcpWinScale = bits.str2num(cmd.word()); return; } if (a.equals("tcp-checksum")) { int i = parseUpRxtx(); cfgAll.tcpChecksumRx = (i & 1) != 0; cfgAll.tcpChecksumTx = (i & 2) != 0; return; } if (a.equals("tcp-portrange")) { cfgAll.tcpRangeMin = bits.str2num(cmd.word()); cfgAll.tcpRangeMax = bits.str2num(cmd.word()); return; } if (a.equals("ludp-checksum")) { int i = parseUpRxtx(); cfgAll.ludpChecksumRx = (i & 1) != 0; cfgAll.ludpChecksumTx = (i & 2) != 0; return; } if (a.equals("ludp-portrange")) { cfgAll.ludpRangeMin = bits.str2num(cmd.word()); cfgAll.ludpRangeMax = bits.str2num(cmd.word()); return; } if (a.equals("dccp-checksum")) { int i = parseUpRxtx(); cfgAll.dccpChecksumRx = (i & 1) != 0; cfgAll.dccpChecksumTx = (i & 2) != 0; return; } if (a.equals("dccp-portrange")) { cfgAll.dccpRangeMin = bits.str2num(cmd.word()); cfgAll.dccpRangeMax = bits.str2num(cmd.word()); return; } if (a.equals("sctp-checksum")) { int i = parseUpRxtx(); cfgAll.sctpChecksumRx = (i & 1) != 0; cfgAll.sctpChecksumTx = (i & 2) != 0; return; } if (a.equals("sctp-portrange")) { cfgAll.sctpRangeMin = bits.str2num(cmd.word()); cfgAll.sctpRangeMax = bits.str2num(cmd.word()); return; } if (a.equals("ftp-passive")) { cfgAll.ftpPassive = true; return; } if (a.equals("ftp-active")) { cfgAll.ftpPassive = false; return; } if (a.equals("ftp-proxy")) { cfgProxy prx = cfgAll.proxyFind(cmd.word(), false); if (prx == null) { cmd.error("no such proxy"); return; } cfgAll.ftpProxy = prx.proxy; return; } if (a.equals("pop3-proxy")) { cfgProxy prx = cfgAll.proxyFind(cmd.word(), false); if (prx == null) { cmd.error("no such proxy"); return; } cfgAll.pop3proxy = prx.proxy; return; } if (a.equals("tls-version")) { cfgAll.tlsVerMin = bits.str2num(cmd.word()); cfgAll.tlsVerMax = bits.str2num(cmd.word()); return; } if (a.equals("ssh-group")) { cfgAll.sshGrpMin = bits.str2num(cmd.word()); cfgAll.sshGrpMax = bits.str2num(cmd.word()); return; } if (a.equals("ssh-agent")) { cfgAll.sshAgent = cmd.getRemaining(); return; } if (a.equals("proxy")) { cfgAll.clientProxy = cfgAll.proxyFind(cmd.word(), false); if (cfgAll.clientProxy == null) { cmd.error("no such profile"); return; } return; } if (a.equals("domain-lookup")) { cfgAll.domainLookup = true; return; } if (a.equals("domain-name")) { cfgAll.domainName = cmd.word(); return; } if (a.equals("name-proxy")) { cfgAll.nameServerProxy = cfgAll.proxyFind(cmd.word(), false); if (cfgAll.nameServerProxy == null) { cmd.error("no such profile"); return; } return; } if (a.equals("name-server")) { cfgAll.nameServerAddr = new ArrayList(); for (;;) { a = cmd.word(); if (a.length() < 1) { break; } addrIP adr = new addrIP(); if (adr.fromString(a)) { continue; } cfgAll.nameServerAddr.add(adr); } return; } if (a.equals("upgrade-config")) { cfgAll.upgradeConfig = true; return; } if (a.equals("upgrade-revert")) { cfgAll.upgradeRevert = bits.str2num(cmd.word()); userUpgrade.startReverter(); return; } if (a.equals("upgrade-backup")) { cfgAll.upgradeBackup = true; return; } if (a.equals("upgrade-ownkey")) { cfgAll.upgradeOwnKey = true; return; } if (a.equals("upgrade-script")) { cfgScrpt ntry = cfgAll.scrptFind(cmd.word(), false); if (ntry == null) { cmd.error("no such script"); return; } cfgAll.upgradeScript = ntry; return; } if (a.equals("upgrade-server")) { cfgAll.upgradeServer = cmd.word(); return; } if (a.equals("upgrade-pubkey")) { cfgAll.upgradePubKey = cmd.word(); return; } if (a.equals("config-server")) { cfgAll.configServer = cmd.word(); return; } if (a.equals("config-username")) { cfgAll.configUser = cmd.word(); return; } if (a.equals("config-password")) { cfgAll.configPass = authLocal.passwdDecode(cmd.word()); return; } if (a.equals("config-save")) { cfgAll.configAsave = true; return; } if (a.equals("config-archive")) { cfgAll.configAbackup = true; return; } if (a.equals("config-backup")) { cfgAll.configBackup = cmd.getRemaining(); return; } if (a.equals("config-exclusive")) { cfgAll.configExclusive = 1; return; } if (a.equals("access-subnet-ipv4")) { cfgAll.accessSubnet4 = bits.str2num(cmd.word()); return; } if (a.equals("access-subnet-ipv6")) { cfgAll.accessSubnet6 = bits.str2num(cmd.word()); return; } if (a.equals("access-supernet-ipv4")) { cfgAll.accessSupnet4 = bits.str2num(cmd.word()); return; } if (a.equals("access-supernet-ipv6")) { cfgAll.accessSupnet6 = bits.str2num(cmd.word()); return; } if (a.equals("time-server")) { if (cfgAll.timeServerName != null) { cfgAll.timeServerName.stopWork(); } cfgAll.timeServerName = new clntNtp(cmd.word()); cfgAll.timeServerName.startWork(); return; } if (a.equals("time-zone")) { cfgAll.timeZoneName = cmd.word(); return; } if (a.equals("time-proxy")) { cfgProxy prx = cfgAll.proxyFind(cmd.word(), false); if (prx == null) { cmd.error("no such proxy"); return; } cfgAll.timeProxy = prx.proxy; return; } if (a.equals("tftp-proxy")) { cfgProxy prx = cfgAll.proxyFind(cmd.word(), false); if (prx == null) { cmd.error("no such proxy"); return; } cfgAll.tftpProxy = prx.proxy; return; } if (a.equals("http-agent")) { cfgAll.httpAgent = cmd.getRemaining(); return; } if (a.equals("http-proxy")) { cfgProxy prx = cfgAll.proxyFind(cmd.word(), false); if (prx == null) { cmd.error("no such proxy"); return; } cfgAll.httpProxy = prx.proxy; return; } if (a.equals("mail-proxy")) { cfgProxy prx = cfgAll.proxyFind(cmd.word(), false); if (prx == null) { cmd.error("no such proxy"); return; } cfgAll.mailProxy = prx.proxy; return; } if (a.equals("mail-server")) { cfgAll.mailServerName = cmd.word(); return; } if (a.equals("mail-username")) { cfgAll.mailServerUser = cmd.word(); return; } if (a.equals("mail-password")) { cfgAll.mailServerPass = authLocal.passwdDecode(cmd.word()); return; } cmd.badCmd(); } private void cryptoDoKey(tabGen> lst, T key) { String nam = cmd.word(); String a = cmd.word(); if (a.equals("zeroize")) { cfgAll.keyDel(lst, nam); return; } if (a.equals("editor")) { List txt = new ArrayList(); userEditor e = new userEditor(new userScreen(cmd.pipe), txt, "key", false); if (e.doEdit()) { return; } if (key.pemReadLst(txt, false)) { cmd.error("error decoding"); return; } key.keyName = nam; cfgKey cfg = cfgAll.keyFind(lst, nam, true); cfg.key = key; return; } if (a.equals("import")) { a = authLocal.passwdDecode(cmd.word()); if (a == null) { cmd.error("error reading"); return; } if (key.pemReadStr(a, false)) { cmd.error("error decoding"); return; } key.keyName = nam; cfgKey cfg = cfgAll.keyFind(lst, nam, true); cfg.key = key; return; } if (a.equals("external")) { a = cmd.word(); List t = bits.txt2buf(a); if (t == null) { cmd.error("not found"); return; } if (key.pemReadLst(t, false)) { cmd.error("error decoding"); return; } key.keyName = nam; cfgKey cfg = cfgAll.keyFind(lst, nam, true); cfg.key = key; cfg.filNam = a; return; } if (a.equals("generate")) { int i = bits.str2num(cmd.word()); if (i < 1) { i = 512; } for (;;) { if (key.keyMake(i)) { continue; } if (key.keyVerify()) { continue; } break; } key.keyName = nam; cfgKey cfg = cfgAll.keyFind(lst, nam, true); cfg.key = key; return; } } private cryKeyGeneric findKey() { cryKeyGeneric k = null; String t = cmd.word(); if (t.equals("rsa")) { cfgKey cfg = cfgAll.keyFind(cfgAll.rsakeys, cmd.word(), false); if (cfg != null) { k = cfg.key; } } if (t.equals("dsa")) { cfgKey cfg = cfgAll.keyFind(cfgAll.dsakeys, cmd.word(), false); if (cfg != null) { k = cfg.key; } } if (t.equals("ecdsa")) { cfgKey cfg = cfgAll.keyFind(cfgAll.ecdsakeys, cmd.word(), false); if (cfg != null) { k = cfg.key; } } if (k == null) { cmd.error("key not found"); } return k; } private void doCmdCrypto() { String a = cmd.word(); if (a.equals("rsakey")) { cryptoDoKey(cfgAll.rsakeys, new cryKeyRSA()); return; } if (a.equals("dsakey")) { cryptoDoKey(cfgAll.dsakeys, new cryKeyDSA()); return; } if (a.equals("ecdsakey")) { cryptoDoKey(cfgAll.ecdsakeys, new cryKeyECDSA()); return; } if (a.equals("certificate")) { String nam = cmd.word(); a = cmd.word(); if (a.equals("zeroize")) { cfgAll.certDel(nam); return; } if (a.equals("editor")) { cryKeyGeneric k = findKey(); if (k == null) { return; } cryCertificate c = new cryCertificate(); c.crtName = nam; List txt = new ArrayList(); userEditor e = new userEditor(new userScreen(cmd.pipe), txt, "cert", false); if (e.doEdit()) { return; } if (c.pemReadLst(txt)) { cmd.error("error decoding"); return; } c.key = k; cfgCert cfg = cfgAll.certFind(nam, true); cfg.cert = c; cfg.key = k; return; } if (a.equals("import")) { cryKeyGeneric k = findKey(); if (k == null) { return; } cryCertificate c = new cryCertificate(); c.crtName = nam; a = authLocal.passwdDecode(cmd.word()); if (a == null) { cmd.error("error reading"); return; } if (c.pemReadStr(a)) { cmd.error("error decoding"); return; } c.key = k; cfgCert cfg = cfgAll.certFind(nam, true); cfg.cert = c; cfg.key = k; return; } if (a.equals("external")) { cryKeyGeneric k = findKey(); if (k == null) { return; } a = cmd.word(); cryCertificate c = new cryCertificate(); c.crtName = nam; List t = bits.txt2buf(a); if (t == null) { cmd.error("not found"); return; } if (c.pemReadLst(t)) { cmd.error("error decoding"); return; } c.key = k; cfgCert cfg = cfgAll.certFind(nam, true); cfg.cert = c; cfg.key = k; cfg.filNam = a; return; } if (a.equals("generate")) { cryKeyGeneric k = findKey(); if (k == null) { return; } a = cmd.word(); if (a.length() < 1) { a = cfgAll.getFqdn(); } int i = bits.str2num(cmd.word()); if (i < 1) { i = 3650; } cryCertificate c = cryCertificate.createSelfSigned(k, a, i); c.crtName = nam; cfgCert cfg = cfgAll.certFind(nam, true); cfg.cert = c; cfg.key = k; return; } cmd.badCmd(); return; } if (a.equals("ipsec")) { modeDconfig = cfgAll.ipsecFind(cmd.word(), true); if (modeDconfig == null) { cmd.error("bad profile name"); return; } modeV = modes.config; return; } cmd.badCmd(); } private void doCmdNoCrypto() { String a = cmd.word(); if (a.equals("ipsec")) { cfgAll.ipsecDel(cmd.word()); return; } cmd.badCmd(); } }