summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--Makefile.am8
-rw-r--r--configure.ac7
-rw-r--r--debian/control3
-rwxr-xr-xscripts/vyatta-show-interfaces6
-rw-r--r--src/render_xml.cc31
-rw-r--r--src/xsl_processor.cc76
-rw-r--r--src/xsl_processor.hh28
-rw-r--r--templates/show/interfaces/tunnel/node.tag/node.def2
9 files changed, 162 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index c0e9c47..17e104d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,9 @@
*~
.*.swp
+*.[oa]
+*.deps
+.dirstamp
+libtool
/aclocal.m4
/autom4te.cache
/build-stamp
@@ -19,3 +23,5 @@
/Makefile.in
/Makefile
+/src/render_xml
+
diff --git a/Makefile.am b/Makefile.am
index c9849cb..091e050 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,6 +20,14 @@ bin_sudo_users_SCRIPTS += scripts/vyatta-show-log-file
bin_sudo_users_SCRIPTS += scripts/vyatta-show-dmesg
bin_sudo_users_SCRIPTS += scripts/vyatta-show-dmesg-all
+sbin_PROGRAMS = src/render_xml
+
+src_render_xml_SOURCES = src/render_xml.cc
+src_render_xml_SOURCES += src/xsl_processor.cc
+src_render_xml_SOURCES += src/xsl_processor.hh
+src_render_xml_CPPFLAGS = -I$(srcdir)/src
+src_render_xml_LDADD = -lsablot
+
cpiop = find . ! -regex '\(.*~\|.*\.bak\|.*\.swp\|.*\#.*\#\)' -print0 | \
cpio -0pd
diff --git a/configure.ac b/configure.ac
index 30d16dd..c47e093 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,6 +15,13 @@ AC_CONFIG_AUX_DIR([config])
AM_INIT_AUTOMAKE([gnu no-dist-gzip dist-bzip2 subdir-objects])
AC_PREFIX_DEFAULT([/opt/vyatta])
+AC_PROG_CC
+AM_PROG_AS
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AC_PROG_LEX
+AC_PROG_YACC
+
AC_ARG_ENABLE([nostrip],
AC_HELP_STRING([--enable-nostrip],
[include -nostrip option during packaging]),
diff --git a/debian/control b/debian/control
index 074e6e5..63b5611 100644
--- a/debian/control
+++ b/debian/control
@@ -15,7 +15,8 @@ Depends: bash (>= 3.1),
pciutils,
lsof,
coreutils (>= 5.97-5.3),
- host
+ host,
+ libsablot0
Suggests: util-linux (>= 2.13-5),
net-tools,
ncurses-bin (>= 5.5-5),
diff --git a/scripts/vyatta-show-interfaces b/scripts/vyatta-show-interfaces
index 1a71c29..8f54923 100755
--- a/scripts/vyatta-show-interfaces
+++ b/scripts/vyatta-show-interfaces
@@ -25,7 +25,7 @@ shopt -s extglob
shopt -s nullglob
declare progname=${0##*/}
-declare -a full_itfs=( /sys/class/net/+(eth|vmnet|lo|sit|wan)* )
+declare -a full_itfs=( /sys/class/net/+(eth|vmnet|lo|tun|wan)* )
declare -a itfs
declare _do_show=_show_itf_stats
@@ -129,7 +129,7 @@ _usage ()
_add_itfs ()
{
for itf ; do
- if [[ $itf != +(eth|vmnet|lo|sit|wan)* ]] ; then
+ if [[ $itf != +(eth|vmnet|lo|tun|wan)* ]] ; then
_error 2 \""$itf"\" is not an interface name\!
elif [ ! -d /sys/class/net/$itf ] ; then
_error 2 $itf: no such interface\!
@@ -151,7 +151,7 @@ if [ $# -gt 0 ] ; then
loopback )
full_itfs=( /sys/class/net/lo* ) ;;
tunnel )
- full_itfs=( /sys/class/net/sit* ) ;;
+ full_itfs=( /sys/class/net/tun* ) ;;
esac
itfs=( ${full_itfs[@]##*/} )
else
diff --git a/src/render_xml.cc b/src/render_xml.cc
new file mode 100644
index 0000000..a213387
--- /dev/null
+++ b/src/render_xml.cc
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <iostream>
+#include <string>
+
+#include "xsl_processor.hh"
+
+using namespace std;
+
+int
+main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ printf("usage: %s <xsl_file>\n", argv[0]);
+ printf(" (takes XML from stdin)\n");
+ exit(1);
+ }
+
+ char buf[2048];
+ string xml_str = "";
+ while (fgets(buf, 2048, stdin) != NULL) {
+ xml_str += buf;
+ }
+
+ string xsl_file(argv[1]);
+ list<pair<string,string> > listParams;
+ XSLProcessor xsl_processor(false);
+ cout << xsl_processor.transform(xml_str, xsl_file, listParams) << endl;
+
+ exit(0);
+}
diff --git a/src/xsl_processor.cc b/src/xsl_processor.cc
new file mode 100644
index 0000000..f40b611
--- /dev/null
+++ b/src/xsl_processor.cc
@@ -0,0 +1,76 @@
+/**
+ * Module: xsl_processor.cc
+ *
+ * Author: Michael Larson
+ * Date: 2005
+ */
+#include <string>
+#include <iostream>
+#include <sablot.h>
+#include "xsl_processor.hh"
+
+using namespace std;
+
+/**
+ *
+ **/
+XSLProcessor::XSLProcessor(bool debug) : _debug(debug)
+{
+
+}
+
+/**
+ *
+ **/
+XSLProcessor::~XSLProcessor()
+{
+
+}
+
+/**
+ *
+ **/
+std::string
+XSLProcessor::transform(const string &input, const string &xsl, const list<pair<string,string> > & listParams)
+{
+ if (_debug) {
+ cout << "input to xsl processor: " << endl << input << endl << xsl << endl;
+ }
+
+ //for now we'll dump this into a file, but this will have to change soon.
+ string formatted_output;
+
+ //example below from http://www.gingerall.org/ga/html/sablot/sparse-frameset.html
+ SablotSituation S;
+ SablotHandle proc;
+ SDOM_Document xml;
+
+ SablotCreateSituation(&S);
+
+ SablotParseBuffer(S, input.c_str(), &xml);
+
+ SablotCreateProcessorForSituation(S, &proc);
+ SablotAddArgTree(S, proc, "data", xml);
+ list<pair<string, string> >::const_iterator i = listParams.begin();
+ list<pair<string, string> >::const_iterator iEnd = listParams.end();
+ while (i != iEnd) {
+ SablotAddParam(S, proc, i->first.c_str(), i->second.c_str());
+ i++;
+ }
+ SablotRunProcessorGen(S, proc, xsl.c_str(), "arg:/data", "arg:/out");
+
+ char *result;
+ SablotGetResultArg(proc, "arg:/out", &result);
+
+ formatted_output = result;
+
+ //now strip away the first line
+ int pos = formatted_output.find("\n");
+ formatted_output = formatted_output.substr(pos + 1, formatted_output.length() - pos - 1);
+
+ SablotFree(result);
+ SablotDestroyProcessor(proc);
+ SablotDestroySituation(S);
+
+ return formatted_output;
+}
diff --git a/src/xsl_processor.hh b/src/xsl_processor.hh
new file mode 100644
index 0000000..ac9b047
--- /dev/null
+++ b/src/xsl_processor.hh
@@ -0,0 +1,28 @@
+/**
+ * Module: xsl_processor.hh
+ *
+ * Author: Michael Larson
+ * Date: 2005
+ */
+#ifndef __XSL_PROCESSOR_HH__
+#define __XSL_PROCESSOR_HH__
+
+#include <list>
+#include <string>
+#include <utility>
+
+
+class XSLProcessor
+{
+public:
+ XSLProcessor(bool debug);
+ ~XSLProcessor();
+
+ std::string
+ transform(const std::string &input, const std::string &xsl, const std::list<std::pair<std::string, std::string> > & listParams);
+
+private:
+ bool _debug;
+};
+
+#endif //__XSL_PROCESSOR_HH__
diff --git a/templates/show/interfaces/tunnel/node.tag/node.def b/templates/show/interfaces/tunnel/node.tag/node.def
index 8dc252e..c119ab0 100644
--- a/templates/show/interfaces/tunnel/node.tag/node.def
+++ b/templates/show/interfaces/tunnel/node.tag/node.def
@@ -1,5 +1,5 @@
help: Show given tunnel interface information
allowed: local -a array ;
- array=( /sys/class/net/sit* ) ;
+ array=( /sys/class/net/tun* ) ;
echo -n ${array[@]##*/}
run: ${vyatta_bindir}/vyatta-show-interfaces tunnel $4