Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions CMD_HIST_RECORD_FILE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
show help
show .
show topology
.
cd
cls
.
run node R0 resolve_arp 1.2.3.4
show .
run .
run node R0_re resolve_arp 20.1.1.2
show .
show node R0_re arp
run .
run node R0_re resolve_arp 20.1.1.2
show node R0_re arp
run .
run node R0_re resolve_arp 20.1.1.2
show topology
run .
run node R0_re resolve_arp 20.1.1.2
run .
run node R0_re resolve_arp 20.1.1.2
show .
show node R0_re arp
show topology
run .
run node R0_re resolve_arp 20.1.1.2
show .
show node R0_re arp
show topology
run node R0_re resolve_arp 20.1.1.2
run node R0_re resolve_arp 40.1.1.2
show node R0_re arp
show topology
show topology
show topology
show topology
show topology
show topology
run .
run node H1 resolve_arp 10.1.1.6
run node H1 resolve_arp 10.1.1.6
show node H1 arp
show node L2SW1 mac
show node L2SW2 mac
run node H1 resolve_arp 10.1.1.6
show node H1 arp
show node L2SW1 mac
run node H1 resolve_arp 10.1.1.6
show node H1 arp
show node L2SW1 mac
run node H1 resolve_arp 10.1.1.6
run node H1 resolve_arp 10.1.1.6
show node H1 arp
show node L2SW1 mac
show node L2SW2 mac
run node H1 resolve_arp 10.1.1.6
show node H1 arp
show node L2SW1 mac
show node L2SW2 mac
show .
run node H1 resolve_arp 10.1.1.6
run node H1 resolve_arp 10.1.1.6
show node L2SW1 mac
show node L2SW2 mac
config .
config
config .
config node R1 route 122.1.1.3 32
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run .
run node R1 resolve_arp 10.1.1.2
show topology
show topology
run .
run node R1 resolve_arp 10.1.1.2
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run node R2 resolve_arp 10.1.1.1
show node R1 arp
show node R2 arp
show .
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run node R2 resolve_arp 10.1.1.1
run node R1 resolve_arp 10.1.1.2
show node R1 arp
show node R1 rt
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run node R1 ping /
run node R1 ping 122.1.1.3
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run .
run node R1 resolve-arp 10.1.1.2
run node R2 resolve-arp 10.1.1.1
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
show node R1 arp
show node R1 rt
show node R2 rt
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run node R1 ping 122.1.1.3
show node R1 rt
run node R2 ping 122.1.1.3
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
show node R1 arp
run node R1 resolve-arp 10.1.1.2
show node R1 arp
run node R2 resolve-arp 11.1.1.1
show node R2 arp
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run node R2 resolve-arp 11.1.1.1
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run node R2 resolve-arp 11.1.1.1
run node R1 resolve-arp 10.1.1.2
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run node R2 resolve-arp 11.1.1.1
run node R1 resolve-arp 10.1.1.2
run node R1 ping 10.1.1.2
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run node R2 resolve-arp 11.1.1.1
run node R1 resolve-arp 10.1.1.2
run node R1 ping 10.1.1.2
run node R1 ping 122.1.1.3
run node R1 ping 10.1.1.1
config node R1 route 122.1.1.3 32 10.1.1.2 eth0/1
config node R2 route 122.1.1.3 32 11.1.1.1 eth0/3
run node R1 ping 10.1.1.2
run node R1 ping 122.1.1.3
run node R1 ping 10.1.1.2
run node R1 ping 122.1.1.3
Binary file added CommandParser/LinuxLikeCommandLineInterface.docx
Binary file not shown.
56 changes: 56 additions & 0 deletions CommandParser/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
CC=gcc
CFLAGS=-g -Wall
INCLUDES=-I .
CLILIB=libcli.a
TARGET:exe ${CLILIB} ${FMSLIB}
OBJ=cmd_hier.o parser.o serialize.o string_util.o clistd.o clicbext.o gluethread/glthread.o ut/utinfra/ut_parser.o
exe:testapp.o ${CLILIB}
@echo "Building final executable"
@ ${CC} ${CFLAGS} ${INCLUDES} testapp.o -o exe -L . -lcli -lpthread -lrt
cmd_hier.o:cmd_hier.c
@echo "Building cmd_hier.o"
@ ${CC} ${CFLAGS} -c ${INCLUDES} cmd_hier.c -o cmd_hier.o
parser.o:parser.c
@echo "Building parser.o"
@ ${CC} ${CFLAGS} -c ${INCLUDES} parser.c -o parser.o
gluethread/glthread.o:gluethread/glthread.c
@echo "Building gluethread/glthread.o"
@ ${CC} ${CFLAGS} -c ${INCLUDES} gluethread/glthread.c -o gluethread/glthread.o
serialize.o:serialize.c
@echo "Building serialize.o"
@ ${CC} ${CFLAGS} -c ${INCLUDES} serialize.c -o serialize.o
string_util.o:string_util.c
@echo "Building string_util.o"
@ ${CC} ${CFLAGS} -c ${INCLUDES} string_util.c -o string_util.o
clistd.o:clistd.c
@echo "Building clistd.o"
@ ${CC} ${CFLAGS} -c ${INCLUDES} clistd.c -o clistd.o
clicbext.o:clicbext.c
@echo "Building clicbext.o"
@ ${CC} ${CFLAGS} -c ${INCLUDES} clicbext.c -o clicbext.o
testapp.o:testapp.c
@echo "Building testapp.o"
@ ${CC} ${CFLAGS} -c ${INCLUDES} testapp.c -o testapp.o
ut/utinfra/ut_parser.o:ut/utinfra/ut_parser.c
@echo "Building ut/utinfra/ut_parser.o"
@ ${CC} ${CFLAGS} -c ${INCLUDES} ut/utinfra/ut_parser.c -o ut/utinfra/ut_parser.o
${CLILIB}: ${OBJ}
@echo "Building Library ${CLILIB}"
ar rs ${CLILIB} ${OBJ}
clean:
rm -f exe
rm -f *.o
rm -f gluethread/*.o
rm -f ut/utinfra/*.o
rm -f ${CLILIB}
rm -f CMD_HIST_RECORD_FILE.txt
install:
cp ${CLILIB} /usr/local/lib/
cp libcli.h /usr/include/
cp cmdtlv.h /usr/include/

uninstall:
rm -f /usr/local/lib/${CLILIB}
rm -f /usr/local/lib/${FSMLIB}
rm -f /usr/include/libcli.h
rm -f /usr/include/cmdtlv.h
22 changes: 22 additions & 0 deletions CommandParser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# CommandParser
This project is about implementing the Command line interface in C for Developer custom C aplications. Developer can integrate the library with the application and registered his own customized commands to Interact with the application.
The CLI interface is in the form of library, hence, only one process is supported at a time. Currently, the communication between CLI interface and backend application is through callbacks. We shall extend this project to establish IPC between CLI interface and backend process. The CLI interface has support for show,debug,clear,config commands a developer can register. Library authenticate the command format and values, and if the cmd entered is one of the format of the registered command, the application registered callback for that command is triggered. Config command negation is also supported. On pressing "?", it also displays the list of feasible next suboptions to the user with help string.

This Project gives developer Linux like command like interface to interact with the application. This project closesly emulate the Routing devices interactive CLI shell.

See The testapp.c to learn the usage of the library.
#include libcli.h and cmdtlv.h in your application to use the library.
Compile your application by linking it with libcli.a library using -lcli. See Makefile for help.

Steps :

1. Run 'make' to compile the library.
2. Run test aplication executable (./exe) and enjoy the CLI.

TODO:
1. To place the validation checks for supported data types


How to make use of this Library in your projects :
=====================================================
See the doc LinuxLikeCommandLineInterface.docx present along with the src code.
53 changes: 53 additions & 0 deletions CommandParser/clicbext.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* =====================================================================================
*
* Filename: clicbext.c
*
* Description: This file contains all the functions which are extension to libcli default
* Callbacks
*
* Version: 1.0
* Created: Friday 18 August 2017 02:03:46 IST
* Revision: 1.0
* Compiler: gcc
*
* Author: Er. Abhishek Sagar, Networking Developer (AS), sachinites@gmail.com
* Company: Brocade Communications(Jul 2012- Mar 2016), Current : Juniper Networks(Apr 2017 - Present)
*
* This file is part of the CommandParser distribution (https://github.com/sachinites).
* Copyright (c) 2017 Abhishek Sagar.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* =====================================================================================
*/

#include <stdio.h>
#include <stdlib.h>
#include "clicbext.h"

void
terminate_signal_handler(){

/*-----------------------------------------------------------------------------
* Process has malfunctioned for some reason, user would like to see the memory
* state of the process for debugging. This function triggers all the show command
* one by one and write the output data to the file for future reference.
* -----------------------------------------------------------------------------*/
collect_supportsave_data();
exit(0);
}

void
collect_supportsave_data(){
printf("%s() is called ...\n", __FUNCTION__);
}
41 changes: 41 additions & 0 deletions CommandParser/clicbext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* =====================================================================================
*
* Filename: clicbext.h
*
* Description: Header file for cli Default Callback Extension functions
*
* Version: 1.0
* Created: Friday 18 August 2017 02:04:19 IST
* Revision: 1.0
* Compiler: gcc
*
* Author: Er. Abhishek Sagar, Networking Developer (AS), sachinites@gmail.com
* Company: Brocade Communications(Jul 2012- Mar 2016), Current : Juniper Networks(Apr 2017 - Present)
*
* This file is part of the CommandParser distribution (https://github.com/sachinites).
* Copyright (c) 2017 Abhishek Sagar.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* =====================================================================================
*/

#ifndef __CLICBEXTN__
#define __CLICBEXTN__

void
terminate_signal_handler();

void
collect_supportsave_data();
#endif /* __CLICBEXTN__ */
Loading