# The Klish user manual ## About ## The klish is a framework for implementing a CISCO-like CLI on a UNIX systems. It is configurable by XML files. The KLISH stands for Kommand Line Interface Shell. I know that "command" starts with "c" :) . The klish is a fork of [clish] 0.7.3 project (http://sourceforge.net/projects/clish/). The original clish was developed by [gmckerrell Graeme McKerrell]. The klish obtain some new features but it's compatible (as much as possible) with clish's XML configuration files. The author of klish project is Serj Kalichev. The main target for the klish is a Linux platform. Additionally it can be build on FreeBSD, OpenBSD, Solaris. The QNX support is planned. The klish project is written in C. The klish development is sponsored by "Factor-TS" company http://www.factor-ts.ru/. == Repository == The main klish GIT repository is https://src.libcode.org/klish == Downloads == All downloads were moved to http://klish.libcode.org/files The googlecode.com engine doesn't allow to add new downloads now. == Issue tracking == Post new issues to http://klish.libcode.org/issues/new please. == Mailing lists == The klish related mailing lists: * The klish discussion group [http://groups.google.com/group/klish]. * The klish development discussion group [http://groups.google.com/group/klish-dev].
*Code* | *Id* | *Key* | *Action* | *Comment* |
0 | NUL | ^@ | Null character | |
1 | SOH | ^A | Home | Start of heading, = console interrupt |
2 | STX | ^B | Start of text, maintenance mode on HP console | |
3 | ETX | ^C | Break | End of text |
4 | EOT | ^D | Delete | End of transmission, not the same as ETB |
5 | ENQ | ^E | End | Enquiry, goes with ACK; old HP flow control |
6 | ACK | ^F | Acknowledge, clears ENQ logon hand | |
7 | BEL | ^G | Bell, rings the bell... | |
8 | BS | ^H | Backspace | Backspace, works on HP terminals/computers |
9 | HT | ^I | Tab | Horizontal tab, move to next tab stop |
10 | LF | ^J | Enter | Line Feed |
11 | VT | ^K | Kill line | Vertical tab |
12 | FF | ^L | Clear screen | Form Feed, page eject |
13 | CR | ^M | Enter | Carriage Return |
14 | SO | ^N | Shift Out, alternate character set | |
15 | SI | ^O | Shift In, resume defaultn character set | |
16 | DLE | ^P | Data link escape | |
17 | DC1 | ^Q | XON, with XOFF to pause listings; "okay to send". | |
18 | DC2 | ^R | Device control 2, block-mode flow control | |
19 | DC3 | ^S | XOFF, with XON is TERM=18 flow control | |
20 | DC4 | ^T | Device control 4 | |
21 | NAK | ^U | Erase line | Negative acknowledge |
22 | SYN | ^V | Synchronous idle | |
23 | ETB | ^W | Erase word | End transmission block, not the same as EOT |
24 | CAN | ^X | Cancel line, MPE echoes !!! | |
25 | EM | ^Y | Yank | End of medium, Control-Y interrupt |
26 | SUB | ^Z | Substitute | |
27 | ESC | ^[ | Escape | Escape, next character is not echoed |
28 | FS | ^\ | File separator | |
29 | GS | ^](HOTKEY]) | Group separator | |
30 | RS | ^^ | Record separator, block-mode terminator | |
31 | US | `^_` | Unit separator |
hostname Router
!
interface ethernet 0
ip address 192.168.1.1/24
enable
!
interface ethernet 1
ip address 10.0.0.1
The "hostname Router" entry has no nested entries. The "interface ethernet 0" and "interface ethernet 1" contain nested entries.
## Comments
The "!" symbol is a comment for the klish. Each line starting with the "!" consider as a comment so this line will be ignored by the klish. The konfd daemon can output a current state of running-config. The previous text is an example of such output. Generally the comments are not really stored by the konfd. The konfd automatically inserts "!" beetween first level running-config entries for more human readable view.
## Path
The running-config structure can be considered as a filesystem-like structure. The "interface ethernet 0" entry can be considered as a directory with the nested "files". So each entry has a "path". The first level entries have an empty path but the nested entries like a "enable" entry has a non-empty path:
"interface ethernet 0"
The running-config can contain multi level nesting:
interface ethernet 0
ip address 192.168.1.1/24
ip options
mtu 1500
enable
In this case the "mtu 1500" entry has a following path:
"interface ethernet 0" "ip options"
The "path" concept is important for running-config entries manipulations.
## Priority
Each entry has a priority. The priority is a 16-bit unsigned integer. The entries with minimal priority resides on the begining of the running-config. The default priority is "0". The entries with the same priority will be ordered alphabetically.
The priority can be specified in hex format. The klish use "0x7f00" default value for the priority if priority is not specified explicitly within [CONFIG] tag. The "0x7f00" is a middle of the possible priority range.
The high and low bytes within priority value have a little different meanings. The first level entries with different high bytes will be splitted by "!" (comment sign) always. By default the entries with equal high byte and arbitrary low byte will be splitted by "!" too. But if the entry has a "non-split" flag (see konfd protocol description to find out how to set this flag) the "!" will not be inserted before current entry if previous entry has the same high byte. So the entries can be grouped and don't be splitted by the "!".
The high and low bytes within priority value have no special meanings for nested entries.
## Sequences
The konfd supports ordered lists a.k.a. "sequences". The entry can be or not to be a part of the sequence. It can be specified by a special options while entry creation. All entries in sequence must have the same priority value. The priority can be considered as an identifier of the sequence. The running-config can contain many sequences at the same time. The sequences will be identified by the priority value.
The new entry can be inserted into sequence with specified sequence number. The entry can be removed from the sequence by its sequence number.
The konfd can output entries without or with sequence numbers prepending the entry value.
See the konfd communication protocol description for detail about sequence using.
# Communicate to konfd daemon
The konfd daemon is accessible via UNIX socket interface. The socket path can be specified via command line. So it's possible to have a several konfd executed simultaneously. The default socket path is /tmp/konfd.socket.
The konfd uses text based protocol for communication with another processes. The syntax of protocol is like a command line with options. It will be documented later in this document.
# Options
## `-v, --version`
Print the version of clish utility.
## `-h, --help`
Print help.
## `-d, --debug`
Enable debug mode. Don't daemonize konfd.
## `-s
-s -l "interface ethernet 0" -r "^interface ethernet 0$"
This example will add new entry "interface ethernet 0" to the first level of the running-config. If the entry "interface ethernet 0" already exists it will be overwritten by the same entry. The definitions of another interfaces (with another interface numbers) will not be removed because the regular expression contain the number "0" at the end of the pattern.
-s -l "ip address 192.168.0.1/24" -r "^ip address " "interface ethernet 0"
This example will add new nested entry "ip address 192.168.0.1/24" to the "interface ethernet 0" path. If the IP-address was defined before this action the old entry matching the "^ip address " pattern will be replaced by the new address. Suppose the entry "interface ethernet 0" already exists.
-s -l "mtu 1500" -r "^mtu " "interface ethernet 0" "ip options"
This code will add "mtu 1500" nested entry to the path "interface ethernet 0" "ip options". Suppose the path entries already exist. The running-config output after this operation is:
interface ethernet 0
ip options
mtu 1500
# The sigexec utility.
$ ./configure --disable-shared
$ make LDFLAGS+="-all-static"
The LDFLAGS is global so shared libraries can't be build and building of shared libraries must be disabled.
# Leak of dlopen()
If target system doesn't support dlopen() then configure script will configure building process to don't use dlopen() (and other dl functions) but link to plugin's shared objects.
If you need to link statically with plugins use:
$ ac_cv_header_dlfcn_h=no ./configure --prefix=/usr --with-lua --disable-shared
$ make LDFLAGS+="-all-static"
# The klish XML examples.