#include <syslog.h>
#include <libloc/libloc.h>
+#include <libloc/address.h>
#include <libloc/database.h>
#include <libloc/network.h>
#include <libloc/private.h>
#endif
// Check if the first and last addresses are correct
- char* string = loc_network_format_first_address(network1);
+ const char* string = loc_network_format_first_address(network1);
if (!string) {
fprintf(stderr, "Did get NULL instead of a string for the first address\n");
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
- char* s = loc_network_str(subnet1);
+ const char* s = loc_network_str(subnet1);
printf("Received subnet1 = %s\n", s);
- free(s);
s = loc_network_str(subnet2);
printf("Received subnet2 = %s\n", s);
- free(s);
if (!loc_network_is_subnet(network1, subnet1)) {
fprintf(stderr, "Subnet1 is not a subnet\n");
// Try adding an invalid network
struct loc_network* network;
err = loc_writer_add_network(writer, &network, "xxxx:xxxx::/32");
- if (err != -EINVAL) {
+ if (!err) {
fprintf(stderr, "It was possible to add an invalid network (err = %d)\n", err);
exit(EXIT_FAILURE);
}
FILE* f = tmpfile();
if (!f) {
- fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno));
+ fprintf(stderr, "Could not open file for writing: %m\n");
exit(EXIT_FAILURE);
}
} bit_length_tests[] = {
{ "::/0", 0 },
{ "2001::/128", 126 },
+ { "1.0.0.0/32", 25 },
+ { "0.0.0.1/32", 1 },
+ { "255.255.255.255/32", 32 },
{ NULL, 0, },
};