5 This file is part of catta.
7 catta is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
12 catta is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15 Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with catta; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 typedef struct CattaInterfaceMonitor CattaInterfaceMonitor;
24 typedef struct CattaInterfaceAddress CattaInterfaceAddress;
25 typedef struct CattaInterface CattaInterface;
26 typedef struct CattaHwInterface CattaHwInterface;
28 #include <catta/llist.h>
29 #include <catta/address.h>
33 #include "response-sched.h"
34 #include "query-sched.h"
35 #include "probe-sched.h"
42 #include "iface-linux.h"
43 #elif defined(HAVE_PF_ROUTE)
44 #include "iface-pfroute.h"
46 typedef struct CattaInterfaceMonitorOSDep CattaInterfaceMonitorOSDep;
47 struct CattaInterfaceMonitorOSDep {
49 unsigned query_addr_seq, query_link_seq;
59 #define CATTA_MAC_ADDRESS_MAX 32
61 struct CattaInterfaceMonitor {
63 CattaHashmap *hashmap;
65 CATTA_LLIST_HEAD(CattaInterface, interfaces);
66 CATTA_LLIST_HEAD(CattaHwInterface, hw_interfaces);
69 CattaInterfaceMonitorOSDep osdep;
72 struct CattaHwInterface {
73 CattaInterfaceMonitor *monitor;
75 CATTA_LLIST_FIELDS(CattaHwInterface, hardware);
83 uint8_t mac_address[CATTA_MAC_ADDRESS_MAX];
84 size_t mac_address_size;
86 CattaSEntryGroup *entry_group;
88 /* Packet rate limiting */
89 struct timeval ratelimit_begin;
90 unsigned ratelimit_counter;
92 CATTA_LLIST_HEAD(CattaInterface, interfaces);
95 struct CattaInterface {
96 CattaInterfaceMonitor *monitor;
97 CattaHwInterface *hardware;
99 CATTA_LLIST_FIELDS(CattaInterface, iface);
100 CATTA_LLIST_FIELDS(CattaInterface, by_hardware);
102 CattaProtocol protocol;
104 CattaAddress local_mcast_address;
109 CattaQueryScheduler *query_scheduler;
110 CattaResponseScheduler * response_scheduler;
111 CattaProbeScheduler *probe_scheduler;
113 CATTA_LLIST_HEAD(CattaInterfaceAddress, addresses);
114 CATTA_LLIST_HEAD(CattaAnnouncer, announcers);
116 CattaHashmap *queriers_by_key;
117 CATTA_LLIST_HEAD(CattaQuerier, queriers);
120 struct CattaInterfaceAddress {
121 CattaInterfaceMonitor *monitor;
122 CattaInterface *iface;
124 CATTA_LLIST_FIELDS(CattaInterfaceAddress, address);
126 CattaAddress address;
132 CattaSEntryGroup *entry_group;
135 CattaInterfaceMonitor *catta_interface_monitor_new(CattaServer *server);
136 void catta_interface_monitor_free(CattaInterfaceMonitor *m);
138 int catta_interface_monitor_init_osdep(CattaInterfaceMonitor *m);
139 void catta_interface_monitor_free_osdep(CattaInterfaceMonitor *m);
140 void catta_interface_monitor_sync(CattaInterfaceMonitor *m);
142 typedef void (*CattaInterfaceMonitorWalkCallback)(CattaInterfaceMonitor *m, CattaInterface *i, void* userdata);
143 void catta_interface_monitor_walk(CattaInterfaceMonitor *m, CattaIfIndex idx, CattaProtocol protocol, CattaInterfaceMonitorWalkCallback callback, void* userdata);
144 int catta_dump_caches(CattaInterfaceMonitor *m, CattaDumpCallback callback, void* userdata);
146 void catta_interface_monitor_update_rrs(CattaInterfaceMonitor *m, int remove_rrs);
147 int catta_address_is_local(CattaInterfaceMonitor *m, const CattaAddress *a);
148 void catta_interface_monitor_check_relevant(CattaInterfaceMonitor *m);
150 /* CattaHwInterface */
152 CattaHwInterface *catta_hw_interface_new(CattaInterfaceMonitor *m, CattaIfIndex idx);
153 void catta_hw_interface_free(CattaHwInterface *hw, int send_goodbye);
155 void catta_hw_interface_update_rrs(CattaHwInterface *hw, int remove_rrs);
156 void catta_hw_interface_check_relevant(CattaHwInterface *hw);
158 CattaHwInterface* catta_interface_monitor_get_hw_interface(CattaInterfaceMonitor *m, int idx);
162 CattaInterface* catta_interface_new(CattaInterfaceMonitor *m, CattaHwInterface *hw, CattaProtocol protocol);
163 void catta_interface_free(CattaInterface *i, int send_goodbye);
165 void catta_interface_update_rrs(CattaInterface *i, int remove_rrs);
166 void catta_interface_check_relevant(CattaInterface *i);
167 int catta_interface_is_relevant(CattaInterface *i);
169 void catta_interface_send_packet(CattaInterface *i, CattaDnsPacket *p);
170 void catta_interface_send_packet_unicast(CattaInterface *i, CattaDnsPacket *p, const CattaAddress *a, uint16_t port);
172 int catta_interface_post_query(CattaInterface *i, CattaKey *k, int immediately, unsigned *ret_id);
173 int catta_interface_withraw_query(CattaInterface *i, unsigned id);
174 int catta_interface_post_response(CattaInterface *i, CattaRecord *record, int flush_cache, const CattaAddress *querier, int immediately);
175 int catta_interface_post_probe(CattaInterface *i, CattaRecord *p, int immediately);
177 int catta_interface_match(CattaInterface *i, CattaIfIndex idx, CattaProtocol protocol);
178 int catta_interface_address_on_link(CattaInterface *i, const CattaAddress *a);
179 int catta_interface_has_address(CattaInterfaceMonitor *m, CattaIfIndex iface, const CattaAddress *a);
181 CattaInterface* catta_interface_monitor_get_interface(CattaInterfaceMonitor *m, CattaIfIndex idx, CattaProtocol protocol);
183 /* CattaInterfaceAddress */
185 CattaInterfaceAddress *catta_interface_address_new(CattaInterfaceMonitor *m, CattaInterface *i, const CattaAddress *addr, unsigned prefix_len);
186 void catta_interface_address_free(CattaInterfaceAddress *a);
188 void catta_interface_address_update_rrs(CattaInterfaceAddress *a, int remove_rrs);
189 int catta_interface_address_is_relevant(CattaInterfaceAddress *a);
191 CattaInterfaceAddress* catta_interface_monitor_get_address(CattaInterfaceMonitor *m, CattaInterface *i, const CattaAddress *raddr);
193 CattaIfIndex catta_find_interface_for_address(CattaInterfaceMonitor *m, const CattaAddress *a);