]>
git.ipfire.org Git - people/ms/libloc.git/blob - src/libloc/network-tree.h
2 libloc - A library to determine the location of someone on the Internet
4 Copyright (C) 2017-2024 IPFire Development Team <info@ipfire.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
17 #ifndef LIBLOC_NETWORK_TREE_H
18 #define LIBLOC_NETWORK_TREE_H
22 #include <libloc/libloc.h>
23 #include <libloc/network.h>
25 struct loc_network_tree
;
27 int loc_network_tree_new(struct loc_ctx
* ctx
, struct loc_network_tree
** tree
);
29 struct loc_network_tree
* loc_network_tree_unref(struct loc_network_tree
* tree
);
31 struct loc_network_tree_node
* loc_network_tree_get_root(struct loc_network_tree
* tree
);
33 int loc_network_tree_walk(struct loc_network_tree
* tree
,
34 int(*filter_callback
)(struct loc_network
* network
, void* data
),
35 int(*callback
)(struct loc_network
* network
, void* data
), void* data
);
37 int loc_network_tree_dump(struct loc_network_tree
* tree
);
39 int loc_network_tree_add_network(struct loc_network_tree
* tree
, struct loc_network
* network
);
41 size_t loc_network_tree_count_nodes(struct loc_network_tree
* tree
);
43 int loc_network_tree_cleanup(struct loc_network_tree
* tree
);
49 struct loc_network_tree_node
;
51 int loc_network_tree_node_new(struct loc_ctx
* ctx
, struct loc_network_tree_node
** node
);
53 struct loc_network_tree_node
* loc_network_tree_node_ref(struct loc_network_tree_node
* node
);
54 struct loc_network_tree_node
* loc_network_tree_node_unref(struct loc_network_tree_node
* node
);
56 struct loc_network_tree_node
* loc_network_tree_node_get(
57 struct loc_network_tree_node
* node
, unsigned int index
);
59 int loc_network_tree_node_is_leaf(struct loc_network_tree_node
* node
);
61 struct loc_network
* loc_network_tree_node_get_network(struct loc_network_tree_node
* node
);
63 #endif /* LIBLOC_PRIVATE */
65 #endif /* LIBLOC_NETWORK_TREE_H */