summaryrefslogtreecommitdiff
path: root/guile
diff options
context:
space:
mode:
authorpaul <paul>2002-12-13 20:15:29 +0000
committerpaul <paul>2002-12-13 20:15:29 +0000
commit718e3744195351130f4ce7dbe0613f4b3e23df93 (patch)
treebac2ad39971cd43f31241ef123bd4e470f695ac9 /guile
Initial revision
Diffstat (limited to 'guile')
-rw-r--r--guile/.cvsignore3
-rw-r--r--guile/ChangeLog26
-rw-r--r--guile/Makefile.am9
-rw-r--r--guile/Makefile.in299
-rw-r--r--guile/README17
-rw-r--r--guile/guile-bgp.c117
-rw-r--r--guile/zebra-guile.c71
-rw-r--r--guile/zebra-guile.h21
-rw-r--r--guile/zebra-support.c19
9 files changed, 582 insertions, 0 deletions
diff --git a/guile/.cvsignore b/guile/.cvsignore
new file mode 100644
index 00000000..bdcccd62
--- /dev/null
+++ b/guile/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+*.o
+zebra-guile
diff --git a/guile/ChangeLog b/guile/ChangeLog
new file mode 100644
index 00000000..751e952c
--- /dev/null
+++ b/guile/ChangeLog
@@ -0,0 +1,26 @@
+2000-10-02 Kunihiro Ishiguro <kunihiro@zebra.org>
+
+ * zebra-0.89 is released.
+
+2000-08-17 Kunihiro Ishiguro <kunihiro@zebra.org>
+
+ * zebra-0.88 is released.
+
+1999-04-18 Kunihiro Ishiguro <kunihiro@zebra.org>
+
+ * guile-bgp.c (scm_router_bgp): Allocate real struct bgp object.
+
+ * Makefile.am: Delete -DPACKAGE and -DVERSION.
+
+ * zebra-guile.h: File added.
+ * zebra-support.c: File added.
+ * guile-bgp.c: File added.
+
+1999-04-15 Kunihiro Ishiguro <kunihiro@zebra.org>
+
+ * guile/Makefile.am (INCLUDES): Use @GUILE_CFLAGS@ and
+ @GUILE_LDFLAGS@
+
+1999-04-14 Kunihiro Ishiguro <kunihiro@zebra.org>
+
+ * zebra-guile work restarted.
diff --git a/guile/Makefile.am b/guile/Makefile.am
new file mode 100644
index 00000000..58b0547f
--- /dev/null
+++ b/guile/Makefile.am
@@ -0,0 +1,9 @@
+## Process this file with Automake to create Makefile.in
+
+INCLUDES = @GUILE_CFLAGS@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib
+DEFS = @DEFS@ -I. -I$(srcdir)
+
+bin_PROGRAMS = zebra-guile
+zebra_guile_SOURCES = zebra-guile.c zebra-support.c guile-bgp.c
+noinst_HEADERS = zebra-guile.h
+zebra_guile_LDADD = @GUILE_LDFLAGS@ ../bgpd/libbgp.a ../lib/libzebra.a
diff --git a/guile/Makefile.in b/guile/Makefile.in
new file mode 100644
index 00000000..2773029b
--- /dev/null
+++ b/guile/Makefile.in
@@ -0,0 +1,299 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+AR = @AR@
+BGPD = @BGPD@
+CC = @CC@
+CPP = @CPP@
+CURSES = @CURSES@
+IF_METHOD = @IF_METHOD@
+IF_PROC = @IF_PROC@
+IPFORWARD = @IPFORWARD@
+KERNEL_METHOD = @KERNEL_METHOD@
+LIBPAM = @LIBPAM@
+LIB_IPV6 = @LIB_IPV6@
+LIB_REGEX = @LIB_REGEX@
+MAKEINFO = @MAKEINFO@
+MULTIPATH_NUM = @MULTIPATH_NUM@
+OSPF6D = @OSPF6D@
+OSPFD = @OSPFD@
+OTHER_METHOD = @OTHER_METHOD@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+RIPD = @RIPD@
+RIPNGD = @RIPNGD@
+RTREAD_METHOD = @RTREAD_METHOD@
+RT_METHOD = @RT_METHOD@
+VERSION = @VERSION@
+VTYSH = @VTYSH@
+ZEBRA = @ZEBRA@
+
+INCLUDES = @GUILE_CFLAGS@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib
+DEFS = @DEFS@ -I. -I$(srcdir)
+
+bin_PROGRAMS = zebra-guile
+zebra_guile_SOURCES = zebra-guile.c zebra-support.c guile-bgp.c
+noinst_HEADERS = zebra-guile.h
+zebra_guile_LDADD = @GUILE_LDFLAGS@ ../bgpd/libbgp.a ../lib/libzebra.a
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../config.h
+CONFIG_CLEAN_FILES =
+PROGRAMS = $(bin_PROGRAMS)
+
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+zebra_guile_OBJECTS = zebra-guile.o zebra-support.o guile-bgp.o
+zebra_guile_DEPENDENCIES = ../bgpd/libbgp.a ../lib/libzebra.a
+zebra_guile_LDFLAGS =
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+HEADERS = $(noinst_HEADERS)
+
+DIST_COMMON = README ChangeLog Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+SOURCES = $(zebra_guile_SOURCES)
+OBJECTS = $(zebra_guile_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps guile/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-binPROGRAMS:
+
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+distclean-binPROGRAMS:
+
+maintainer-clean-binPROGRAMS:
+
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ list='$(bin_PROGRAMS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ done
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+zebra-guile: $(zebra_guile_OBJECTS) $(zebra_guile_DEPENDENCIES)
+ @rm -f zebra-guile
+ $(LINK) $(zebra_guile_LDFLAGS) $(zebra_guile_OBJECTS) $(zebra_guile_LDADD) $(LIBS)
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = guile
+
+distdir: $(DISTFILES)
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-binPROGRAMS
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-binPROGRAMS
+uninstall: uninstall-am
+all-am: Makefile $(PROGRAMS) $(HEADERS)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
+ mostlyclean-tags mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-binPROGRAMS clean-compile clean-tags clean-generic \
+ mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \
+ distclean-generic clean-am
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-binPROGRAMS \
+ maintainer-clean-compile maintainer-clean-tags \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
+maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile tags mostlyclean-tags distclean-tags \
+clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
+check-am installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/guile/README b/guile/README
new file mode 100644
index 00000000..8e18fae5
--- /dev/null
+++ b/guile/README
@@ -0,0 +1,17 @@
+
+ zebra-guile
+
+ Kunihiro Ishiguro
+ 1999
+
+1. What is zebra-guile
+
+zebra-guile is GNU Zebra which linked with guile. Almost zebra's
+command can be called from guile interpreter. So you can use guile as
+a routing scripting language.
+
+2. How to use it.
+
+(define bgp (router-bgp 7675))
+
+3.
diff --git a/guile/guile-bgp.c b/guile/guile-bgp.c
new file mode 100644
index 00000000..fbd01ba0
--- /dev/null
+++ b/guile/guile-bgp.c
@@ -0,0 +1,117 @@
+/* Guile bgp interface.
+ Copyright (C) 1999 Kunihiro Ishiguro
+
+This file is part of GNU Zebra.
+
+GNU Zebra 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; either version 2, or (at your option) any
+later version.
+
+GNU Zebra 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 GNU Zebra; see the file COPYING. If not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#include <zebra.h>
+#include <guile/gh.h>
+
+#include "log.h"
+#include "bgpd/bgpd.h"
+
+/* static SCM scm_mark_bgp (SCM obj); */
+static size_t scm_free_bgp (SCM vect);
+static int scm_print_bgp (SCM vect, SCM port, scm_print_state *pstate);
+static SCM scm_equalp_bgp (SCM a, SCM b);
+
+/* Tag of scheme type of bgp. */
+long scm_tag_bgp;
+
+static scm_smobfuns bgp_funs =
+{
+ scm_mark0, scm_free_bgp, scm_print_bgp, scm_equalp_bgp
+};
+
+static int
+scm_print_bgp (SCM vect, SCM port, scm_print_state *pstate)
+{
+ unsigned short num;
+ struct bgp *bgp;
+
+ num = 0;
+ bgp = (struct bgp *) SCM_CDR (vect);
+ num = bgp->as;
+ scm_puts ("#<bgp ", port);
+ scm_intprint (num, 10, port);
+ scm_putc ('>', port);
+ return 1;
+}
+
+static size_t
+scm_free_bgp (SCM obj)
+{
+ /* dummy function. */
+ return 10;
+}
+
+static SCM
+scm_equalp_bgp (SCM a, SCM b)
+{
+
+ return SCM_BOOL_F;
+}
+
+/* Make bgp instance. */
+SCM
+scm_router_bgp (SCM as_number)
+{
+ SCM cell;
+ long num;
+ struct bgp *bgp;
+ struct bgp *bgp_create ();
+
+ SCM_ASSERT (SCM_INUMP (as_number), as_number, SCM_ARG1, "router-bgp");
+
+ SCM_DEFER_INTS;
+
+ num = gh_scm2long (as_number);
+
+ /* Make new bgp object. */
+ bgp = bgp_create ();
+ bgp->as = num;
+
+ SCM_NEWCELL (cell);
+ SCM_SETCAR (cell, scm_tag_bgp);
+ SCM_SETCDR (cell, bgp);
+
+ SCM_ALLOW_INTS;
+
+ return cell;
+}
+
+#if 0
+SCM
+scm_router_bgp_list ()
+{
+ return NULL;
+}
+#endif
+
+void
+init_bgp ()
+{
+ void bgp_init ();
+
+ bgp_init ();
+
+ /* Initi types. */
+ scm_tag_bgp = scm_newsmob (&bgp_funs);
+
+ gh_new_procedure ("router-bgp", scm_router_bgp, 1, 0, 0);
+ /* gh_new_procedure ("router-bgp-list", scm_router_bgp_list, 0, 0, 0); */
+}
diff --git a/guile/zebra-guile.c b/guile/zebra-guile.c
new file mode 100644
index 00000000..f618dbc5
--- /dev/null
+++ b/guile/zebra-guile.c
@@ -0,0 +1,71 @@
+/* Zebra guile interface.
+ Copyright (C) 1998, 99 Kunihiro Ishiguro
+
+This file is part of GNU Zebra.
+
+GNU Zebra 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; either version 2, or (at your option) any
+later version.
+
+GNU Zebra 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 GNU Zebra; see the file COPYING. If not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#include <libguile.h>
+#include "zebra-guile.h"
+
+#include "zebra.h"
+#include "thread.h"
+
+struct thread *master;
+
+static void
+init_libzebra ()
+{
+ void cmd_init();
+ void vty_init();
+ void memory_init();
+
+ cmd_init (1);
+ vty_init ();
+ memory_init ();
+}
+
+/* Install scheme procudures. */
+void
+init_zebra_guile ()
+{
+ init_libzebra ();
+
+ init_bgp ();
+
+#if 0
+ init_zebra ();
+ init_rip ();
+ init_ospf ();
+#endif /* 0 */
+}
+
+static void
+inner_main (void *closure, int argc, char **argv)
+{
+ /* Install zebra related scheme procedures. */
+ init_zebra_guile ();
+
+ /* Invoke interpreter. */
+ scm_shell (argc, argv);
+}
+
+int
+main (int argc, char **argv)
+{
+ scm_boot_guile (argc, argv, inner_main, 0);
+ return 0; /* Not reached */
+}
diff --git a/guile/zebra-guile.h b/guile/zebra-guile.h
new file mode 100644
index 00000000..f43e287d
--- /dev/null
+++ b/guile/zebra-guile.h
@@ -0,0 +1,21 @@
+/* Zebra guile header.
+ Copyright (C) 1999 Kunihiro Ishiguro
+
+This file is part of GNU Zebra.
+
+GNU Zebra 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; either version 2, or (at your option) any
+later version.
+
+GNU Zebra 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 GNU Zebra; see the file COPYING. If not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+void init_bgp ();
diff --git a/guile/zebra-support.c b/guile/zebra-support.c
new file mode 100644
index 00000000..9a6ef814
--- /dev/null
+++ b/guile/zebra-support.c
@@ -0,0 +1,19 @@
+/* Zebra guile interface support.
+ Copyright (C) 1999 Kunihiro Ishiguro
+
+This file is part of GNU Zebra.
+
+GNU Zebra 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; either version 2, or (at your option) any
+later version.
+
+GNU Zebra 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 GNU Zebra; see the file COPYING. If not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */