]> git.ipfire.org Git - people/ms/libloc.git/blob - src/loc/network.h
Allow creating networks in memory
[people/ms/libloc.git] / src / loc / network.h
1 /*
2 libloc - A library to determine the location of someone on the Internet
3
4 Copyright (C) 2017 IPFire Development Team <info@ipfire.org>
5
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.
10
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.
15 */
16
17 #ifndef LIBLOC_NETWORK_H
18 #define LIBLOC_NETWORK_H
19
20 #include <netinet/in.h>
21
22 #include <loc/libloc.h>
23
24 struct loc_network;
25 int loc_network_new(struct loc_ctx* ctx, struct loc_network** network,
26 struct in6_addr start_address, unsigned int prefix);
27 int loc_network_new_from_string(struct loc_ctx* ctx, struct loc_network** network,
28 const char* address_string);
29 struct loc_network* loc_network_ref(struct loc_network* network);
30 struct loc_network* loc_network_unref(struct loc_network* network);
31 char* loc_network_str(struct loc_network* network);
32
33 const char* loc_network_get_country_code(struct loc_network* network);
34 int loc_network_set_country_code(struct loc_network* network, const char* country_code);
35
36 struct loc_network_tree;
37 int loc_network_tree_new(struct loc_ctx* ctx, struct loc_network_tree** tree);
38 struct loc_network_tree* loc_network_tree_unref(struct loc_network_tree* tree);
39 int loc_network_tree_dump(struct loc_network_tree* tree);
40 int loc_network_tree_add_network(struct loc_network_tree* tree, struct loc_network* network);
41
42 #endif