]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_apiserver.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospfd / ospf_apiserver.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
2d33f157 2/*
3 * Server side of OSPF API.
4 * Copyright (C) 2001, 2002 Ralph Keller
2d33f157 5 */
6
7#ifndef _OSPF_APISERVER_H
8#define _OSPF_APISERVER_H
9
149491af
CH
10#include <zebra.h>
11#include "ospf_api.h"
12#include "ospf_lsdb.h"
13
2d33f157 14/* List of opaque types that application registered */
d62a17ae 15struct registered_opaque_type {
d7c0a89a
QY
16 uint8_t lsa_type;
17 uint8_t opaque_type;
2d33f157 18};
19
20
21/* Server instance for each accepted client connection. */
d62a17ae 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
149491af
CH
40 /* Sync reachable routers */
41 bool reachable_sync;
42
d62a17ae 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;
2d33f157 52#ifdef USE_ASYNC_READ
d62a17ae 53 struct thread *t_async_read;
2d33f157 54#endif /* USE_ASYNC_READ */
d62a17ae 55 struct thread *t_sync_write;
56 struct thread *t_async_write;
2d33f157 57};
58
14416b1f 59enum ospf_apiserver_event {
d62a17ae 60 OSPF_APISERVER_ACCEPT,
61 OSPF_APISERVER_SYNC_READ,
2d33f157 62#ifdef USE_ASYNC_READ
d62a17ae 63 OSPF_APISERVER_ASYNC_READ,
2d33f157 64#endif /* USE_ASYNC_READ */
d62a17ae 65 OSPF_APISERVER_SYNC_WRITE,
66 OSPF_APISERVER_ASYNC_WRITE
2d33f157 67};
68
69/* -----------------------------------------------------------
78dfa0c7 70 * Following are functions to manage client connections.
2d33f157 71 * -----------------------------------------------------------
72 */
73
d62a17ae 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);
14416b1f 79extern void ospf_apiserver_event(enum ospf_apiserver_event event, int fd,
d62a17ae 80 struct ospf_apiserver *apiserv);
81extern int ospf_apiserver_serv_sock_family(unsigned short port, int family);
cc9f21da
DS
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);
d62a17ae 86extern int ospf_apiserver_send_reply(struct ospf_apiserver *apiserv,
d7c0a89a 87 uint32_t seqnr, uint8_t rc);
2d33f157 88
89/* -----------------------------------------------------------
78dfa0c7 90 * Following are message handler functions
2d33f157 91 * -----------------------------------------------------------
92 */
93
d62a17ae 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);
44038c7a
CH
109extern void
110ospf_apiserver_clients_notify_router_id_change(struct in_addr router_id);
d62a17ae 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,
2d33f157 121 struct msg *msg);
d62a17ae 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);
149491af
CH
137extern int ospf_apiserver_handle_sync_reachable(struct ospf_apiserver *apiserv,
138 struct msg *msg);
97355a6d
CH
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);
44038c7a
CH
143extern int ospf_apiserver_handle_sync_router_id(struct ospf_apiserver *apiserv,
144 struct msg *msg);
2d33f157 145
149491af
CH
146extern void ospf_apiserver_notify_reachable(struct route_table *ort,
147 struct route_table *nrt);
97355a6d 148
2d33f157 149/* -----------------------------------------------------------
78dfa0c7 150 * Following are functions for LSA origination/deletion
2d33f157 151 * -----------------------------------------------------------
152 */
153
d62a17ae 154extern int ospf_apiserver_register_opaque_type(struct ospf_apiserver *apiserver,
d7c0a89a
QY
155 uint8_t lsa_type,
156 uint8_t opaque_type);
d62a17ae 157extern int
158ospf_apiserver_unregister_opaque_type(struct ospf_apiserver *apiserver,
d7c0a89a 159 uint8_t lsa_type, uint8_t opaque_type);
d62a17ae 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);
5349121b
CH
167extern int ospf_apiserver_originate1(struct ospf_lsa *lsa,
168 struct ospf_lsa *old);
d62a17ae 169extern void ospf_apiserver_flood_opaque_lsa(struct ospf_lsa *lsa);
2d33f157 170
171
172/* -----------------------------------------------------------
78dfa0c7 173 * Following are callback functions to handle opaque types
2d33f157 174 * -----------------------------------------------------------
175 */
176
d62a17ae 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);
3e63092b
RW
186extern void ospf_apiserver_show_info(struct vty *vty, struct json_object *json,
187 struct ospf_lsa *lsa);
d62a17ae 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,
d7c0a89a
QY
191 uint8_t lsa_type,
192 uint8_t opaque_type);
2d33f157 193
194/* -----------------------------------------------------------
78dfa0c7 195 * Following are hooks when LSAs are updated or deleted
2d33f157 196 * -----------------------------------------------------------
197 */
198
199
200/* Hooks that are invoked from ospf opaque module */
201
d62a17ae 202extern int ospf_apiserver_lsa_update(struct ospf_lsa *lsa);
203extern int ospf_apiserver_lsa_delete(struct ospf_lsa *lsa);
2d33f157 204
2d33f157 205#endif /* _OSPF_APISERVER_H */