Import Upstream version 1.2.2
[quagga-debian.git] / ospfclient / ospf_apiclient.h
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
23 #ifndef _OSPF_APICLIENT_H
24 #define _OSPF_APICLIENT_H
25
26 #define MTYPE_OSPF_APICLIENT MTYPE_TMP
27
28 /* Structure for the OSPF API client */
29 struct ospf_apiclient
30 {
31
32   /* Sockets for sync requests and async notifications */
33   int fd_sync;
34   int fd_async;
35
36   /* Pointer to callback functions */
37   void (*ready_notify) (u_char lsa_type, u_char opaque_type,
38                         struct in_addr addr);
39   void (*new_if) (struct in_addr ifaddr, struct in_addr area_id);
40   void (*del_if) (struct in_addr ifaddr);
41   void (*ism_change) (struct in_addr ifaddr, struct in_addr area_id,
42                       u_char status);
43   void (*nsm_change) (struct in_addr ifaddr, struct in_addr nbraddr,
44                       struct in_addr router_id, u_char status);
45   void (*update_notify) (struct in_addr ifaddr, struct in_addr area_id,
46                          u_char self_origin,
47                          struct lsa_header * lsa);
48   void (*delete_notify) (struct in_addr ifaddr, struct in_addr area_id,
49                          u_char self_origin,
50                          struct lsa_header * lsa);
51 };
52
53
54 /* ---------------------------------------------------------
55  * API function prototypes.
56  * --------------------------------------------------------- */
57
58 /* Open connection to OSPF daemon. Two ports will be allocated on
59    client, sync channel at syncport and reverse channel at syncport+1 */
60 struct ospf_apiclient *ospf_apiclient_connect (char *host, int syncport);
61
62 /* Shutdown connection to OSPF daemon. */
63 int ospf_apiclient_close (struct ospf_apiclient *oclient);
64
65 /* Synchronous request to register opaque type. */
66 int ospf_apiclient_register_opaque_type (struct ospf_apiclient *oclient,
67                                          u_char ltype, u_char otype);
68
69 /* Synchronous request to register event mask. */
70 int ospf_apiclient_register_events (struct ospf_apiclient *oclient,
71                                     u_int32_t mask);
72
73 /* Register callback functions.*/
74 void ospf_apiclient_register_callback (struct ospf_apiclient *oclient,
75                                        void (*ready_notify) (u_char lsa_type,
76                                                              u_char
77                                                              opaque_type,
78                                                              struct in_addr
79                                                              addr),
80                                        void (*new_if) (struct in_addr ifaddr,
81                                                        struct in_addr
82                                                        area_id),
83                                        void (*del_if) (struct in_addr ifaddr),
84                                        void (*ism_change) (struct in_addr
85                                                            ifaddr,
86                                                            struct in_addr
87                                                            area_id,
88                                                            u_char status),
89                                        void (*nsm_change) (struct in_addr
90                                                            ifaddr,
91                                                            struct in_addr
92                                                            nbraddr,
93                                                            struct in_addr
94                                                            router_id,
95                                                            u_char status),
96                                        void (*update_notify) (struct in_addr
97                                                               ifaddr,
98                                                               struct in_addr
99                                                               area_id,
100                                                               u_char selforig,
101                                                               struct
102                                                               lsa_header *
103                                                               lsa),
104                                        void (*delete_notify) (struct in_addr
105                                                               ifaddr,
106                                                               struct in_addr
107                                                               area_id,
108                                                               u_char selforig,
109                                                               struct
110                                                               lsa_header *
111                                                               lsa));
112
113 /* Synchronous request to synchronize LSDB. */
114 int ospf_apiclient_sync_lsdb (struct ospf_apiclient *oclient);
115
116 /* Synchronous request to originate or update opaque LSA. */
117 int
118 ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient,
119                              struct in_addr ifaddr,
120                              struct in_addr area_id,
121                              u_char lsa_type,
122                              u_char opaque_type, u_int32_t opaque_id,
123                              void *opaquedata, int opaquelen);
124
125
126 /* Synchronous request to delete opaque LSA. Parameter opaque_id is in
127    host byte order */
128 int ospf_apiclient_lsa_delete (struct ospf_apiclient *oclient,
129                                struct in_addr area_id, u_char lsa_type,
130                                u_char opaque_type, u_int32_t opaque_id);
131
132 /* Fetch async message and handle it  */
133 int ospf_apiclient_handle_async (struct ospf_apiclient *oclient);
134
135 #endif /* _OSPF_APICLIENT_H */