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