]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/network.c
Make package compile on Mac OS X
[people/ms/libloc.git] / src / network.c
index 87ae1c57bc6c4df8677c53f18a61ae37eb2deb7d..09f225e7138073204b444414eedbe659d6ee5a2e 100644 (file)
 
 #include <arpa/inet.h>
 #include <assert.h>
-#include <endian.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef HAVE_ENDIAN_H
+#  include <endian.h>
+#endif
+
 #include <loc/libloc.h>
+#include <loc/compat.h>
 #include <loc/country.h>
 #include <loc/network.h>
 #include <loc/private.h>
@@ -350,7 +354,7 @@ LOC_EXPORT int loc_network_to_database_v0(struct loc_network* network, struct lo
        dbobj->asn = htobe32(network->asn);
 
        // Flags
-       dbobj->flags = htobe32(network->flags);
+       dbobj->flags = htobe16(network->flags);
 
        return 0;
 }
@@ -376,7 +380,7 @@ LOC_EXPORT int loc_network_new_from_database_v0(struct loc_ctx* ctx, struct loc_
                return r;
 
        // Import flags
-       r = loc_network_set_flag(*network, be32toh(dbobj->flags));
+       r = loc_network_set_flag(*network, be16toh(dbobj->flags));
        if (r)
                return r;