]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_apiserver.h
pathd: some traces are added to 'debug pathd ted' command.
[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.
896014f4 6 *
2d33f157 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 *
896014f4
DL
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2d33f157 20 */
21
22#ifndef _OSPF_APISERVER_H
23#define _OSPF_APISERVER_H
24
149491af
CH
25#include <zebra.h>
26#include "ospf_api.h"
27#include "ospf_lsdb.h"
28
2d33f157 29/* MTYPE definition is not reflected to "memory.h". */
30#define MTYPE_OSPF_APISERVER MTYPE_TMP
31#define MTYPE_OSPF_APISERVER_MSGFILTER MTYPE_TMP
32
33/* List of opaque types that application registered */
d62a17ae 34struct registered_opaque_type {
d7c0a89a
QY
35 uint8_t lsa_type;
36 uint8_t opaque_type;
2d33f157 37};
38
39
40/* Server instance for each accepted client connection. */
d62a17ae 41struct ospf_apiserver {
42 /* Socket connections for synchronous commands and asynchronous
43 notifications */
44 int fd_sync; /* synchronous requests */
45 struct sockaddr_in peer_sync;
46
47 int fd_async; /* asynchronous notifications */
48 struct sockaddr_in peer_async;
49
50 /* List of all opaque types that application registers to use. Using
51 a single connection with the OSPF daemon, multiple
52 <lsa,opaque_type> pairs can be registered. However, each
53 combination can only be registered once by all applications. */
54 struct list *opaque_types; /* of type registered_opaque_type */
55
56 /* Temporary storage for LSA instances to be refreshed. */
57 struct ospf_lsdb reserve;
58
149491af
CH
59 /* Sync reachable routers */
60 bool reachable_sync;
61
d62a17ae 62 /* filter for LSA update/delete notifies */
63 struct lsa_filter_type *filter;
64
65 /* Fifo buffers for outgoing messages */
66 struct msg_fifo *out_sync_fifo;
67 struct msg_fifo *out_async_fifo;
68
69 /* Read and write threads */
70 struct thread *t_sync_read;
2d33f157 71#ifdef USE_ASYNC_READ
d62a17ae 72 struct thread *t_async_read;
2d33f157 73#endif /* USE_ASYNC_READ */
d62a17ae 74 struct thread *t_sync_write;
75 struct thread *t_async_write;
2d33f157 76};
77
14416b1f 78enum ospf_apiserver_event {
d62a17ae 79 OSPF_APISERVER_ACCEPT,
80 OSPF_APISERVER_SYNC_READ,
2d33f157 81#ifdef USE_ASYNC_READ
d62a17ae 82 OSPF_APISERVER_ASYNC_READ,
2d33f157 83#endif /* USE_ASYNC_READ */
d62a17ae 84 OSPF_APISERVER_SYNC_WRITE,
85 OSPF_APISERVER_ASYNC_WRITE
2d33f157 86};
87
88/* -----------------------------------------------------------
78dfa0c7 89 * Following are functions to manage client connections.
2d33f157 90 * -----------------------------------------------------------
91 */
92
d62a17ae 93extern unsigned short ospf_apiserver_getport(void);
94extern int ospf_apiserver_init(void);
95extern void ospf_apiserver_term(void);
96extern struct ospf_apiserver *ospf_apiserver_new(int fd_sync, int fd_async);
97extern void ospf_apiserver_free(struct ospf_apiserver *apiserv);
14416b1f 98extern void ospf_apiserver_event(enum ospf_apiserver_event event, int fd,
d62a17ae 99 struct ospf_apiserver *apiserv);
100extern int ospf_apiserver_serv_sock_family(unsigned short port, int family);
cc9f21da
DS
101extern void ospf_apiserver_accept(struct thread *thread);
102extern void ospf_apiserver_read(struct thread *thread);
103extern void ospf_apiserver_sync_write(struct thread *thread);
104extern void ospf_apiserver_async_write(struct thread *thread);
d62a17ae 105extern int ospf_apiserver_send_reply(struct ospf_apiserver *apiserv,
d7c0a89a 106 uint32_t seqnr, uint8_t rc);
2d33f157 107
108/* -----------------------------------------------------------
78dfa0c7 109 * Following are message handler functions
2d33f157 110 * -----------------------------------------------------------
111 */
112
d62a17ae 113extern int ospf_apiserver_lsa9_originator(void *arg);
114extern int ospf_apiserver_lsa10_originator(void *arg);
115extern int ospf_apiserver_lsa11_originator(void *arg);
116
117extern void ospf_apiserver_clients_notify_all(struct msg *msg);
118
119extern void
120ospf_apiserver_clients_notify_ready_type9(struct ospf_interface *oi);
121extern void ospf_apiserver_clients_notify_ready_type10(struct ospf_area *area);
122extern void ospf_apiserver_clients_notify_ready_type11(struct ospf *top);
123
124extern void ospf_apiserver_clients_notify_new_if(struct ospf_interface *oi);
125extern void ospf_apiserver_clients_notify_del_if(struct ospf_interface *oi);
126extern void ospf_apiserver_clients_notify_ism_change(struct ospf_interface *oi);
127extern void ospf_apiserver_clients_notify_nsm_change(struct ospf_neighbor *nbr);
44038c7a
CH
128extern void
129ospf_apiserver_clients_notify_router_id_change(struct in_addr router_id);
d62a17ae 130
131extern int ospf_apiserver_is_ready_type9(struct ospf_interface *oi);
132extern int ospf_apiserver_is_ready_type10(struct ospf_area *area);
133extern int ospf_apiserver_is_ready_type11(struct ospf *ospf);
134
135extern void ospf_apiserver_notify_ready_type9(struct ospf_apiserver *apiserv);
136extern void ospf_apiserver_notify_ready_type10(struct ospf_apiserver *apiserv);
137extern void ospf_apiserver_notify_ready_type11(struct ospf_apiserver *apiserv);
138
139extern int ospf_apiserver_handle_msg(struct ospf_apiserver *apiserv,
2d33f157 140 struct msg *msg);
d62a17ae 141extern int
142ospf_apiserver_handle_register_opaque_type(struct ospf_apiserver *apiserv,
143 struct msg *msg);
144extern int
145ospf_apiserver_handle_unregister_opaque_type(struct ospf_apiserver *apiserv,
146 struct msg *msg);
147extern int ospf_apiserver_handle_register_event(struct ospf_apiserver *apiserv,
148 struct msg *msg);
149extern int
150ospf_apiserver_handle_originate_request(struct ospf_apiserver *apiserv,
151 struct msg *msg);
152extern int ospf_apiserver_handle_delete_request(struct ospf_apiserver *apiserv,
153 struct msg *msg);
154extern int ospf_apiserver_handle_sync_lsdb(struct ospf_apiserver *apiserv,
155 struct msg *msg);
149491af
CH
156extern int ospf_apiserver_handle_sync_reachable(struct ospf_apiserver *apiserv,
157 struct msg *msg);
97355a6d
CH
158extern int ospf_apiserver_handle_sync_ism(struct ospf_apiserver *apiserv,
159 struct msg *msg);
160extern int ospf_apiserver_handle_sync_nsm(struct ospf_apiserver *apiserv,
161 struct msg *msg);
44038c7a
CH
162extern int ospf_apiserver_handle_sync_router_id(struct ospf_apiserver *apiserv,
163 struct msg *msg);
2d33f157 164
149491af
CH
165extern void ospf_apiserver_notify_reachable(struct route_table *ort,
166 struct route_table *nrt);
97355a6d 167
2d33f157 168/* -----------------------------------------------------------
78dfa0c7 169 * Following are functions for LSA origination/deletion
2d33f157 170 * -----------------------------------------------------------
171 */
172
d62a17ae 173extern int ospf_apiserver_register_opaque_type(struct ospf_apiserver *apiserver,
d7c0a89a
QY
174 uint8_t lsa_type,
175 uint8_t opaque_type);
d62a17ae 176extern int
177ospf_apiserver_unregister_opaque_type(struct ospf_apiserver *apiserver,
d7c0a89a 178 uint8_t lsa_type, uint8_t opaque_type);
d62a17ae 179extern struct ospf_lsa *
180ospf_apiserver_opaque_lsa_new(struct ospf_area *area, struct ospf_interface *oi,
181 struct lsa_header *protolsa);
182extern struct ospf_interface *
183ospf_apiserver_if_lookup_by_addr(struct in_addr address);
184extern struct ospf_interface *
185ospf_apiserver_if_lookup_by_ifp(struct interface *ifp);
5349121b
CH
186extern int ospf_apiserver_originate1(struct ospf_lsa *lsa,
187 struct ospf_lsa *old);
d62a17ae 188extern void ospf_apiserver_flood_opaque_lsa(struct ospf_lsa *lsa);
2d33f157 189
190
191/* -----------------------------------------------------------
78dfa0c7 192 * Following are callback functions to handle opaque types
2d33f157 193 * -----------------------------------------------------------
194 */
195
d62a17ae 196extern int ospf_apiserver_new_if(struct interface *ifp);
197extern int ospf_apiserver_del_if(struct interface *ifp);
198extern void ospf_apiserver_ism_change(struct ospf_interface *oi,
199 int old_status);
200extern void ospf_apiserver_nsm_change(struct ospf_neighbor *nbr,
201 int old_status);
202extern void ospf_apiserver_config_write_router(struct vty *vty);
203extern void ospf_apiserver_config_write_if(struct vty *vty,
204 struct interface *ifp);
3e63092b
RW
205extern void ospf_apiserver_show_info(struct vty *vty, struct json_object *json,
206 struct ospf_lsa *lsa);
d62a17ae 207extern int ospf_ospf_apiserver_lsa_originator(void *arg);
208extern struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa);
209extern void ospf_apiserver_flush_opaque_lsa(struct ospf_apiserver *apiserv,
d7c0a89a
QY
210 uint8_t lsa_type,
211 uint8_t opaque_type);
2d33f157 212
213/* -----------------------------------------------------------
78dfa0c7 214 * Following are hooks when LSAs are updated or deleted
2d33f157 215 * -----------------------------------------------------------
216 */
217
218
219/* Hooks that are invoked from ospf opaque module */
220
d62a17ae 221extern int ospf_apiserver_lsa_update(struct ospf_lsa *lsa);
222extern int ospf_apiserver_lsa_delete(struct ospf_lsa *lsa);
2d33f157 223
2d33f157 224#endif /* _OSPF_APISERVER_H */