]>
Commit | Line | Data |
---|---|---|
1 | // SPDX-License-Identifier: GPL-2.0-or-later | |
2 | /* | |
3 | * Client side of OSPF API. | |
4 | * Copyright (C) 2001, 2002, 2003 Ralph Keller | |
5 | */ | |
6 | ||
7 | #ifndef _OSPF_APICLIENT_H | |
8 | #define _OSPF_APICLIENT_H | |
9 | ||
10 | /* Structure for the OSPF API client */ | |
11 | struct ospf_apiclient { | |
12 | ||
13 | /* Sockets for sync requests and async notifications */ | |
14 | int fd_sync; | |
15 | int fd_async; | |
16 | ||
17 | /* Pointer to callback functions */ | |
18 | void (*ready_notify)(uint8_t lsa_type, uint8_t opaque_type, | |
19 | struct in_addr addr); | |
20 | void (*new_if)(struct in_addr ifaddr, struct in_addr area_id); | |
21 | void (*del_if)(struct in_addr ifaddr); | |
22 | void (*ism_change)(struct in_addr ifaddr, struct in_addr area_id, | |
23 | uint8_t status); | |
24 | void (*nsm_change)(struct in_addr ifaddr, struct in_addr nbraddr, | |
25 | struct in_addr router_id, uint8_t status); | |
26 | void (*update_notify)(struct in_addr ifaddr, struct in_addr area_id, | |
27 | uint8_t self_origin, struct lsa_header *lsa); | |
28 | void (*delete_notify)(struct in_addr ifaddr, struct in_addr area_id, | |
29 | uint8_t self_origin, struct lsa_header *lsa); | |
30 | }; | |
31 | ||
32 | ||
33 | /* --------------------------------------------------------- | |
34 | * API function prototypes. | |
35 | * --------------------------------------------------------- */ | |
36 | ||
37 | /* Open connection to OSPF daemon. Two ports will be allocated on | |
38 | client, sync channel at syncport and reverse channel at syncport+1 */ | |
39 | struct ospf_apiclient *ospf_apiclient_connect(char *host, int syncport); | |
40 | ||
41 | /* Shutdown connection to OSPF daemon. */ | |
42 | int ospf_apiclient_close(struct ospf_apiclient *oclient); | |
43 | ||
44 | /* Synchronous request to register opaque type. */ | |
45 | int ospf_apiclient_register_opaque_type(struct ospf_apiclient *oclient, | |
46 | uint8_t ltype, uint8_t otype); | |
47 | ||
48 | /* Synchronous request to register event mask. */ | |
49 | int ospf_apiclient_register_events(struct ospf_apiclient *oclient, | |
50 | uint32_t mask); | |
51 | ||
52 | /* Register callback functions.*/ | |
53 | void ospf_apiclient_register_callback( | |
54 | struct ospf_apiclient *oclient, | |
55 | void (*ready_notify)(uint8_t lsa_type, uint8_t opaque_type, | |
56 | struct in_addr addr), | |
57 | void (*new_if)(struct in_addr ifaddr, struct in_addr area_id), | |
58 | void (*del_if)(struct in_addr ifaddr), | |
59 | void (*ism_change)(struct in_addr ifaddr, struct in_addr area_id, | |
60 | uint8_t status), | |
61 | void (*nsm_change)(struct in_addr ifaddr, struct in_addr nbraddr, | |
62 | struct in_addr router_id, uint8_t status), | |
63 | void (*update_notify)(struct in_addr ifaddr, struct in_addr area_id, | |
64 | uint8_t selforig, struct lsa_header *lsa), | |
65 | void (*delete_notify)(struct in_addr ifaddr, struct in_addr area_id, | |
66 | uint8_t selforig, struct lsa_header *lsa)); | |
67 | ||
68 | /* Synchronous request to synchronize LSDB. */ | |
69 | int ospf_apiclient_sync_lsdb(struct ospf_apiclient *oclient); | |
70 | ||
71 | /* Synchronous request to originate or update opaque LSA. */ | |
72 | int ospf_apiclient_lsa_originate(struct ospf_apiclient *oclient, | |
73 | struct in_addr ifaddr, struct in_addr area_id, | |
74 | uint8_t lsa_type, uint8_t opaque_type, | |
75 | uint32_t opaque_id, void *opaquedata, | |
76 | int opaquelen); | |
77 | ||
78 | ||
79 | /* Synchronous request to delete opaque LSA. Parameter opaque_id is in | |
80 | host byte order */ | |
81 | int ospf_apiclient_lsa_delete(struct ospf_apiclient *oclient, | |
82 | struct in_addr addr, uint8_t lsa_type, | |
83 | uint8_t opaque_type, uint32_t opaque_id, | |
84 | uint8_t flags); | |
85 | ||
86 | /* Fetch async message and handle it */ | |
87 | int ospf_apiclient_handle_async(struct ospf_apiclient *oclient); | |
88 | ||
89 | #endif /* _OSPF_APICLIENT_H */ |