guile-bgp.c 2.3 KB

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