paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* Guile bgp interface. |
| 2 | Copyright (C) 1999 Kunihiro Ishiguro |
| 3 | |
| 4 | This file is part of GNU Zebra. |
| 5 | |
| 6 | GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | under the terms of the GNU General Public License as published by the |
| 8 | Free Software Foundation; either version 2, or (at your option) any |
| 9 | later version. |
| 10 | |
| 11 | GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | 02111-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); */ |
| 28 | static size_t scm_free_bgp (SCM vect); |
| 29 | static int scm_print_bgp (SCM vect, SCM port, scm_print_state *pstate); |
| 30 | static SCM scm_equalp_bgp (SCM a, SCM b); |
| 31 | |
| 32 | /* Tag of scheme type of bgp. */ |
| 33 | long scm_tag_bgp; |
| 34 | |
| 35 | static scm_smobfuns bgp_funs = |
| 36 | { |
| 37 | scm_mark0, scm_free_bgp, scm_print_bgp, scm_equalp_bgp |
| 38 | }; |
| 39 | |
| 40 | static int |
| 41 | scm_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 | |
| 55 | static size_t |
| 56 | scm_free_bgp (SCM obj) |
| 57 | { |
| 58 | /* dummy function. */ |
| 59 | return 10; |
| 60 | } |
| 61 | |
| 62 | static SCM |
| 63 | scm_equalp_bgp (SCM a, SCM b) |
| 64 | { |
| 65 | |
| 66 | return SCM_BOOL_F; |
| 67 | } |
| 68 | |
| 69 | /* Make bgp instance. */ |
| 70 | SCM |
| 71 | scm_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 |
| 98 | SCM |
| 99 | scm_router_bgp_list () |
| 100 | { |
| 101 | return NULL; |
| 102 | } |
| 103 | #endif |
| 104 | |
| 105 | void |
| 106 | init_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 | } |