]>
git.ipfire.org Git - people/ms/libloc.git/blob - src/test-network.c
2 libloc - A library to determine the location of someone on the Internet
4 Copyright (C) 2017 IPFire Development Team <info@ipfire.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program 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
14 GNU General Public License for more details.
22 #include <loc/libloc.h>
23 #include <loc/network.h>
25 int main(int argc
, char** argv
) {
33 struct loc_network_tree
* tree
;
34 err
= loc_network_tree_new(ctx
, &tree
);
36 fprintf(stderr
, "Could not create the network tree\n");
41 struct loc_network
* network1
;
42 err
= loc_network_new_from_string(ctx
, &network1
, "2001:db8::/32");
44 fprintf(stderr
, "Could not create the network\n");
48 err
= loc_network_set_country_code(network1
, "XX");
50 fprintf(stderr
, "Could not set country code\n");
54 // Adding network to the tree
55 err
= loc_network_tree_add_network(tree
, network1
);
57 fprintf(stderr
, "Could not add network to the tree\n");
62 err
= loc_network_tree_dump(tree
);
64 fprintf(stderr
, "Error dumping tree: %d\n", err
);
68 loc_network_unref(network1
);
69 loc_network_tree_unref(tree
);