]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_apiserver.h
Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster
[mirror_frr.git] / ospfd / ospf_apiserver.h
CommitLineData
2d33f157 1/*
2 * Server side of OSPF API.
3 * Copyright (C) 2001, 2002 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
23#ifndef _OSPF_APISERVER_H
24#define _OSPF_APISERVER_H
25
26/* MTYPE definition is not reflected to "memory.h". */
27#define MTYPE_OSPF_APISERVER MTYPE_TMP
28#define MTYPE_OSPF_APISERVER_MSGFILTER MTYPE_TMP
29
30/* List of opaque types that application registered */
31struct registered_opaque_type
32{
33 u_char lsa_type;
34 u_char opaque_type;
35};
36
37
38/* Server instance for each accepted client connection. */
39struct ospf_apiserver
40{
41 /* Socket connections for synchronous commands and asynchronous
42 notifications */
43 int fd_sync; /* synchronous requests */
44 struct sockaddr_in peer_sync;
45
46 int fd_async; /* asynchronous notifications */
47 struct sockaddr_in peer_async;
48
49 /* List of all opaque types that application registers to use. Using
50 a single connection with the OSPF daemon, multiple
51 <lsa,opaque_type> pairs can be registered. However, each
52 combination can only be registered once by all applications. */
87d6f87a 53 struct list *opaque_types; /* of type registered_opaque_type */
2d33f157 54
55 /* Temporary storage for LSA instances to be refreshed. */
56 struct ospf_lsdb reserve;
57
58 /* filter for LSA update/delete notifies */
59 struct lsa_filter_type *filter;
60
61 /* Fifo buffers for outgoing messages */
62 struct msg_fifo *out_sync_fifo;
63 struct msg_fifo *out_async_fifo;
64
65 /* Read and write threads */
66 struct thread *t_sync_read;
67#ifdef USE_ASYNC_READ
68 struct thread *t_async_read;
69#endif /* USE_ASYNC_READ */
70 struct thread *t_sync_write;
71 struct thread *t_async_write;
72};
73
74enum event
75{
76 OSPF_APISERVER_ACCEPT,
77 OSPF_APISERVER_SYNC_READ,
78#ifdef USE_ASYNC_READ
79 OSPF_APISERVER_ASYNC_READ,
80#endif /* USE_ASYNC_READ */
81 OSPF_APISERVER_SYNC_WRITE,
82 OSPF_APISERVER_ASYNC_WRITE
83};
84
85/* -----------------------------------------------------------
86 * Followings are functions to manage client connections.
87 * -----------------------------------------------------------
88 */
89
4dadc291 90extern unsigned short ospf_apiserver_getport (void);
91extern int ospf_apiserver_init (void);
92extern void ospf_apiserver_term (void);
93extern struct ospf_apiserver *ospf_apiserver_new (int fd_sync, int fd_async);
94extern void ospf_apiserver_free (struct ospf_apiserver *apiserv);
95extern void ospf_apiserver_event (enum event event, int fd,
2d33f157 96 struct ospf_apiserver *apiserv);
4dadc291 97extern int ospf_apiserver_serv_sock_family (unsigned short port, int family);
98extern int ospf_apiserver_accept (struct thread *thread);
99extern int ospf_apiserver_read (struct thread *thread);
100extern int ospf_apiserver_sync_write (struct thread *thread);
101extern int ospf_apiserver_async_write (struct thread *thread);
102extern int ospf_apiserver_send_reply (struct ospf_apiserver *apiserv,
2d33f157 103 u_int32_t seqnr, u_char rc);
104
105/* -----------------------------------------------------------
106 * Followings are message handler functions
107 * -----------------------------------------------------------
108 */
109
4dadc291 110extern int ospf_apiserver_lsa9_originator (void *arg);
111extern int ospf_apiserver_lsa10_originator (void *arg);
112extern int ospf_apiserver_lsa11_originator (void *arg);
2d33f157 113
4dadc291 114extern void ospf_apiserver_clients_notify_all (struct msg *msg);
2d33f157 115
4dadc291 116extern void ospf_apiserver_clients_notify_ready_type9 (struct ospf_interface *oi);
117extern void ospf_apiserver_clients_notify_ready_type10 (struct ospf_area *area);
118extern void ospf_apiserver_clients_notify_ready_type11 (struct ospf *top);
2d33f157 119
4dadc291 120extern void ospf_apiserver_clients_notify_new_if (struct ospf_interface *oi);
121extern void ospf_apiserver_clients_notify_del_if (struct ospf_interface *oi);
122extern void ospf_apiserver_clients_notify_ism_change (struct ospf_interface *oi);
123extern void ospf_apiserver_clients_notify_nsm_change (struct ospf_neighbor *nbr);
2d33f157 124
4dadc291 125extern int ospf_apiserver_is_ready_type9 (struct ospf_interface *oi);
126extern int ospf_apiserver_is_ready_type10 (struct ospf_area *area);
127extern int ospf_apiserver_is_ready_type11 (struct ospf *ospf);
2d33f157 128
4dadc291 129extern void ospf_apiserver_notify_ready_type9 (struct ospf_apiserver *apiserv);
130extern void ospf_apiserver_notify_ready_type10 (struct ospf_apiserver *apiserv);
131extern void ospf_apiserver_notify_ready_type11 (struct ospf_apiserver *apiserv);
2d33f157 132
4dadc291 133extern int ospf_apiserver_handle_msg (struct ospf_apiserver *apiserv,
2d33f157 134 struct msg *msg);
4dadc291 135extern int ospf_apiserver_handle_register_opaque_type (struct ospf_apiserver
2d33f157 136 *apiserv, struct msg *msg);
4dadc291 137extern int ospf_apiserver_handle_unregister_opaque_type (struct ospf_apiserver
2d33f157 138 *apiserv, struct msg *msg);
4dadc291 139extern int ospf_apiserver_handle_register_event (struct ospf_apiserver *apiserv,
2d33f157 140 struct msg *msg);
4dadc291 141extern int ospf_apiserver_handle_originate_request (struct ospf_apiserver *apiserv,
2d33f157 142 struct msg *msg);
4dadc291 143extern int ospf_apiserver_handle_delete_request (struct ospf_apiserver *apiserv,
2d33f157 144 struct msg *msg);
4dadc291 145extern int ospf_apiserver_handle_sync_lsdb (struct ospf_apiserver *apiserv,
2d33f157 146 struct msg *msg);
147
148
149/* -----------------------------------------------------------
150 * Followings are functions for LSA origination/deletion
151 * -----------------------------------------------------------
152 */
153
4dadc291 154extern int ospf_apiserver_register_opaque_type (struct ospf_apiserver *apiserver,
2d33f157 155 u_char lsa_type, u_char opaque_type);
4dadc291 156extern int ospf_apiserver_unregister_opaque_type (struct ospf_apiserver *apiserver,
2d33f157 157 u_char lsa_type,
158 u_char opaque_type);
4dadc291 159extern struct ospf_lsa *ospf_apiserver_opaque_lsa_new (struct ospf_area *area,
2d33f157 160 struct ospf_interface *oi,
161 struct lsa_header *protolsa);
4dadc291 162extern struct ospf_interface *ospf_apiserver_if_lookup_by_addr (struct in_addr
2d33f157 163 address);
4dadc291 164extern struct ospf_interface *ospf_apiserver_if_lookup_by_ifp (struct interface
2d33f157 165 *ifp);
4dadc291 166extern int ospf_apiserver_originate1 (struct ospf_lsa *lsa);
167extern void ospf_apiserver_flood_opaque_lsa (struct ospf_lsa *lsa);
2d33f157 168
169
170/* -----------------------------------------------------------
171 * Followings are callback functions to handle opaque types
172 * -----------------------------------------------------------
173 */
174
4dadc291 175extern int ospf_apiserver_new_if (struct interface *ifp);
176extern int ospf_apiserver_del_if (struct interface *ifp);
177extern void ospf_apiserver_ism_change (struct ospf_interface *oi, int old_status);
178extern void ospf_apiserver_nsm_change (struct ospf_neighbor *nbr, int old_status);
179extern void ospf_apiserver_config_write_router (struct vty *vty);
180extern void ospf_apiserver_config_write_if (struct vty *vty, struct interface *ifp);
181extern void ospf_apiserver_show_info (struct vty *vty, struct ospf_lsa *lsa);
182extern int ospf_ospf_apiserver_lsa_originator (void *arg);
072990e2 183extern struct ospf_lsa *ospf_apiserver_lsa_refresher (struct ospf_lsa *lsa);
4dadc291 184extern void ospf_apiserver_flush_opaque_lsa (struct ospf_apiserver *apiserv,
2d33f157 185 u_char lsa_type, u_char opaque_type);
186
187/* -----------------------------------------------------------
188 * Followings are hooks when LSAs are updated or deleted
189 * -----------------------------------------------------------
190 */
191
192
193/* Hooks that are invoked from ospf opaque module */
194
4dadc291 195extern int ospf_apiserver_lsa_update (struct ospf_lsa *lsa);
196extern int ospf_apiserver_lsa_delete (struct ospf_lsa *lsa);
2d33f157 197
4dadc291 198extern void ospf_apiserver_clients_lsa_change_notify (u_char msgtype,
2d33f157 199 struct ospf_lsa *lsa);
200
201#endif /* _OSPF_APISERVER_H */