summaryrefslogtreecommitdiff
path: root/guile/guile-bgp.c
blob: fbd01ba0e1ad1bcb40bd0b58c8cf5d886569df34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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); */
}