blob: fbd01ba0e1ad1bcb40bd0b58c8cf5d886569df34 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* Guile bgp interface.
2 Copyright (C) 1999 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22#include <guile/gh.h>
23
24#include "log.h"
25#include "bgpd/bgpd.h"
26
27/* static SCM scm_mark_bgp (SCM obj); */
28static size_t scm_free_bgp (SCM vect);
29static int scm_print_bgp (SCM vect, SCM port, scm_print_state *pstate);
30static SCM scm_equalp_bgp (SCM a, SCM b);
31
32/* Tag of scheme type of bgp. */
33long scm_tag_bgp;
34
35static scm_smobfuns bgp_funs =
36{
37 scm_mark0, scm_free_bgp, scm_print_bgp, scm_equalp_bgp
38};
39
40static int
41scm_print_bgp (SCM vect, SCM port, scm_print_state *pstate)
42{
43 unsigned short num;
44 struct bgp *bgp;
45
46 num = 0;
47 bgp = (struct bgp *) SCM_CDR (vect);
48 num = bgp->as;
49 scm_puts ("#<bgp ", port);
50 scm_intprint (num, 10, port);
51 scm_putc ('>', port);
52 return 1;
53}
54
55static size_t
56scm_free_bgp (SCM obj)
57{
58 /* dummy function. */
59 return 10;
60}
61
62static SCM
63scm_equalp_bgp (SCM a, SCM b)
64{
65
66 return SCM_BOOL_F;
67}
68
69/* Make bgp instance. */
70SCM
71scm_router_bgp (SCM as_number)
72{
73 SCM cell;
74 long num;
75 struct bgp *bgp;
76 struct bgp *bgp_create ();
77
78 SCM_ASSERT (SCM_INUMP (as_number), as_number, SCM_ARG1, "router-bgp");
79
80 SCM_DEFER_INTS;
81
82 num = gh_scm2long (as_number);
83
84 /* Make new bgp object. */
85 bgp = bgp_create ();
86 bgp->as = num;
87
88 SCM_NEWCELL (cell);
89 SCM_SETCAR (cell, scm_tag_bgp);
90 SCM_SETCDR (cell, bgp);
91
92 SCM_ALLOW_INTS;
93
94 return cell;
95}
96
97#if 0
98SCM
99scm_router_bgp_list ()
100{
101 return NULL;
102}
103#endif
104
105void
106init_bgp ()
107{
108 void bgp_init ();
109
110 bgp_init ();
111
112 /* Initi types. */
113 scm_tag_bgp = scm_newsmob (&bgp_funs);
114
115 gh_new_procedure ("router-bgp", scm_router_bgp, 1, 0, 0);
116 /* gh_new_procedure ("router-bgp-list", scm_router_bgp_list, 0, 0, 0); */
117}