ospf_apiclient.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Client side of OSPF API.
  3. * Copyright (C) 2001, 2002, 2003 Ralph Keller
  4. *
  5. * This file is part of GNU Zebra.
  6. *
  7. * GNU Zebra is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published
  9. * by the Free Software Foundation; either version 2, or (at your
  10. * option) any later version.
  11. *
  12. * GNU Zebra is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Zebra; see the file COPYING. If not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. #ifndef _OSPF_APICLIENT_H
  23. #define _OSPF_APICLIENT_H
  24. #define MTYPE_OSPF_APICLIENT MTYPE_TMP
  25. /* Structure for the OSPF API client */
  26. struct ospf_apiclient
  27. {
  28. /* Sockets for sync requests and async notifications */
  29. int fd_sync;
  30. int fd_async;
  31. /* Pointer to callback functions */
  32. void (*ready_notify) (u_char lsa_type, u_char opaque_type,
  33. struct in_addr addr);
  34. void (*new_if) (struct in_addr ifaddr, struct in_addr area_id);
  35. void (*del_if) (struct in_addr ifaddr);
  36. void (*ism_change) (struct in_addr ifaddr, struct in_addr area_id,
  37. u_char status);
  38. void (*nsm_change) (struct in_addr ifaddr, struct in_addr nbraddr,
  39. struct in_addr router_id, u_char status);
  40. void (*update_notify) (struct in_addr ifaddr, struct in_addr area_id,
  41. u_char self_origin,
  42. struct lsa_header * lsa);
  43. void (*delete_notify) (struct in_addr ifaddr, struct in_addr area_id,
  44. u_char self_origin,
  45. struct lsa_header * lsa);
  46. };
  47. /* ---------------------------------------------------------
  48. * API function prototypes.
  49. * --------------------------------------------------------- */
  50. /* Open connection to OSPF daemon. Two ports will be allocated on
  51. client, sync channel at syncport and reverse channel at syncport+1 */
  52. struct ospf_apiclient *ospf_apiclient_connect (char *host, int syncport);
  53. /* Shutdown connection to OSPF daemon. */
  54. int ospf_apiclient_close (struct ospf_apiclient *oclient);
  55. /* Synchronous request to register opaque type. */
  56. int ospf_apiclient_register_opaque_type (struct ospf_apiclient *oclient,
  57. u_char ltype, u_char otype);
  58. /* Synchronous request to register event mask. */
  59. int ospf_apiclient_register_events (struct ospf_apiclient *oclient,
  60. u_int32_t mask);
  61. /* Register callback functions.*/
  62. void ospf_apiclient_register_callback (struct ospf_apiclient *oclient,
  63. void (*ready_notify) (u_char lsa_type,
  64. u_char
  65. opaque_type,
  66. struct in_addr
  67. addr),
  68. void (*new_if) (struct in_addr ifaddr,
  69. struct in_addr
  70. area_id),
  71. void (*del_if) (struct in_addr ifaddr),
  72. void (*ism_change) (struct in_addr
  73. ifaddr,
  74. struct in_addr
  75. area_id,
  76. u_char status),
  77. void (*nsm_change) (struct in_addr
  78. ifaddr,
  79. struct in_addr
  80. nbraddr,
  81. struct in_addr
  82. router_id,
  83. u_char status),
  84. void (*update_notify) (struct in_addr
  85. ifaddr,
  86. struct in_addr
  87. area_id,
  88. u_char selforig,
  89. struct
  90. lsa_header *
  91. lsa),
  92. void (*delete_notify) (struct in_addr
  93. ifaddr,
  94. struct in_addr
  95. area_id,
  96. u_char selforig,
  97. struct
  98. lsa_header *
  99. lsa));
  100. /* Synchronous request to synchronize LSDB. */
  101. int ospf_apiclient_sync_lsdb (struct ospf_apiclient *oclient);
  102. /* Synchronous request to originate or update opaque LSA. */
  103. int
  104. ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
  105. struct in_addr ifaddr,
  106. struct in_addr area_id,
  107. u_char lsa_type,
  108. u_char opaque_type, u_int32_t opaque_id,
  109. void *opaquedata, int opaquelen);
  110. /* Synchronous request to delete opaque LSA. Parameter opaque_id is in
  111. host byte order */
  112. int ospf_apiclient_lsa_delete (struct ospf_apiclient *oclient,
  113. struct in_addr area_id, u_char lsa_type,
  114. u_char opaque_type, u_int32_t opaque_id);
  115. /* Fetch async message and handle it */
  116. int ospf_apiclient_handle_async (struct ospf_apiclient *oclient);
  117. #endif /* _OSPF_APICLIENT_H */