chiark / gitweb /
change type for address family to "int"
authorLennart Poettering <lennart@poettering.net>
Fri, 18 Jul 2014 14:09:30 +0000 (16:09 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 18 Jul 2014 14:10:51 +0000 (16:10 +0200)
Let's settle on a single type for all address family values, even if
UNIX is very inconsitent on the precise type otherwise. Given that
socket() is the primary entrypoint for the sockets API, and that uses
"int", and "int" is relatively simple and generic, we settle on "int"
for this.

27 files changed:
src/libsystemd-network/network-internal.c
src/libsystemd-network/network-internal.h
src/libsystemd/sd-rtnl/local-addresses.h
src/libsystemd/sd-rtnl/rtnl-message.c
src/libsystemd/sd-rtnl/test-rtnl.c
src/machine/machine-dbus.c
src/machine/machinectl.c
src/network/networkd-address-pool.c
src/network/networkd-manager.c
src/network/networkd-netdev.h
src/network/networkd.h
src/nss-mymachines/nss-mymachines.c
src/nss-resolve/nss-resolve.c
src/resolve/resolved-bus.c
src/resolve/resolved-dns-packet.h
src/resolve/resolved-dns-query.h
src/resolve/resolved-dns-scope.c
src/resolve/resolved-dns-scope.h
src/resolve/resolved-dns-server.c
src/resolve/resolved-dns-server.h
src/resolve/resolved-link.c
src/resolve/resolved-link.h
src/resolve/resolved-manager.c
src/resolve/resolved.h
src/shared/in-addr-util.c
src/shared/in-addr-util.h
src/systemd/sd-rtnl.h

index e209b0f..3407537 100644 (file)
@@ -304,7 +304,7 @@ int config_parse_hwaddr(const char *unit,
         return 0;
 }
 
-int net_parse_inaddr(const char *address, unsigned char *family, void *dst) {
+int net_parse_inaddr(const char *address, int *family, void *dst) {
         int r;
 
         assert(address);
index 53c364a..765dff4 100644 (file)
@@ -62,7 +62,7 @@ int config_parse_ifalias(const char *unit, const char *filename, unsigned line,
                          const char *section, unsigned section_line, const char *lvalue,
                          int ltype, const char *rvalue, void *data, void *userdata);
 
-int net_parse_inaddr(const char *address, unsigned char *family, void *dst);
+int net_parse_inaddr(const char *address, int *family, void *dst);
 
 int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]);
 const char *net_get_name(struct udev_device *device);
index d3dff8b..c6e3559 100644 (file)
@@ -29,8 +29,8 @@
 #include "in-addr-util.h"
 
 struct local_address {
-        int ifindex;
-        unsigned char family, scope;
+        int family, ifindex;
+        unsigned char scope;
         union in_addr_union address;
 };
 
index c0a38e1..7f2e398 100644 (file)
@@ -133,7 +133,7 @@ int sd_rtnl_message_route_set_scope(sd_rtnl_message *m, unsigned char scope) {
 }
 
 int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret,
-                              uint16_t nlmsg_type, unsigned char rtm_family) {
+                              uint16_t nlmsg_type, int rtm_family) {
         struct rtmsg *rtm;
         int r;
 
@@ -275,7 +275,7 @@ int sd_rtnl_message_addr_set_scope(sd_rtnl_message *m, unsigned char scope) {
         return 0;
 }
 
-int sd_rtnl_message_addr_get_family(sd_rtnl_message *m, unsigned char *family) {
+int sd_rtnl_message_addr_get_family(sd_rtnl_message *m, int *family) {
         struct ifaddrmsg *ifa;
 
         assert_return(m, -EINVAL);
@@ -352,7 +352,7 @@ int sd_rtnl_message_addr_get_ifindex(sd_rtnl_message *m, int *ifindex) {
 
 int sd_rtnl_message_new_addr(sd_rtnl *rtnl, sd_rtnl_message **ret,
                              uint16_t nlmsg_type, int index,
-                             unsigned char family) {
+                             int family) {
         struct ifaddrmsg *ifa;
         int r;
 
@@ -383,7 +383,7 @@ int sd_rtnl_message_new_addr(sd_rtnl *rtnl, sd_rtnl_message **ret,
 }
 
 int sd_rtnl_message_new_addr_update(sd_rtnl *rtnl, sd_rtnl_message **ret,
-                             int index, unsigned char family) {
+                             int index, int family) {
         int r;
 
         r = sd_rtnl_message_new_addr(rtnl, ret, RTM_NEWADDR, index, family);
index cd81aca..082c9e4 100644 (file)
@@ -334,8 +334,8 @@ static void test_get_addresses(sd_rtnl *rtnl) {
 
         for (m = reply; m; m = sd_rtnl_message_next(m)) {
                 uint16_t type;
-                unsigned char family, scope, flags;
-                int ifindex;
+                unsigned char scope, flags;
+                int family, ifindex;
 
                 assert_se(sd_rtnl_message_get_type(m, &type) >= 0);
                 assert_se(type == RTM_NEWADDR);
index daa60d1..89c9377 100644 (file)
@@ -233,12 +233,12 @@ int bus_machine_method_get_addresses(sd_bus *bus, sd_bus_message *message, void
         if (r < 0)
                 return sd_bus_error_set_errno(error, r);
 
-        r = sd_bus_message_open_container(reply, 'a', "(yay)");
+        r = sd_bus_message_open_container(reply, 'a', "(iay)");
         if (r < 0)
                 return sd_bus_error_set_errno(error, r);
 
         for (;;) {
-                unsigned char family;
+                int family;
                 ssize_t n;
                 union in_addr_union in_addr;
                 struct iovec iov[2];
@@ -256,11 +256,11 @@ int bus_machine_method_get_addresses(sd_bus *bus, sd_bus_message *message, void
                 if ((size_t) n < sizeof(family))
                         break;
 
-                r = sd_bus_message_open_container(reply, 'r', "yay");
+                r = sd_bus_message_open_container(reply, 'r', "iay");
                 if (r < 0)
                         return sd_bus_error_set_errno(error, r);
 
-                r = sd_bus_message_append(reply, "y", family);
+                r = sd_bus_message_append(reply, "i", family);
                 if (r < 0)
                         return sd_bus_error_set_errno(error, r);
 
@@ -405,7 +405,7 @@ const sd_bus_vtable machine_vtable[] = {
         SD_BUS_PROPERTY("State", "s", property_get_state, 0, 0),
         SD_BUS_METHOD("Terminate", NULL, NULL, bus_machine_method_terminate, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)),
         SD_BUS_METHOD("Kill", "si", NULL, bus_machine_method_kill, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)),
-        SD_BUS_METHOD("GetAddresses", NULL, "a(yay)", bus_machine_method_get_addresses, SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD("GetAddresses", NULL, "a(iay)", bus_machine_method_get_addresses, SD_BUS_VTABLE_UNPRIVILEGED),
         SD_BUS_METHOD("GetOSRelease", NULL, "a{ss}", bus_machine_method_get_os_release, SD_BUS_VTABLE_UNPRIVILEGED),
         SD_BUS_VTABLE_END
 };
index 04c7c7c..cc3be98 100644 (file)
@@ -188,17 +188,17 @@ static int print_addresses(sd_bus *bus, const char *name, int ifi, const char *p
         if (r < 0)
                 return r;
 
-        r = sd_bus_message_enter_container(reply, 'a', "(yay)");
+        r = sd_bus_message_enter_container(reply, 'a', "(iay)");
         if (r < 0)
                 return bus_log_parse_error(r);
 
-        while ((r = sd_bus_message_enter_container(reply, 'r', "yay")) > 0) {
-                unsigned char family;
+        while ((r = sd_bus_message_enter_container(reply, 'r', "iay")) > 0) {
+                int family;
                 const void *a;
                 size_t sz;
                 char buffer[MAX(INET6_ADDRSTRLEN, INET_ADDRSTRLEN)];
 
-                r = sd_bus_message_read(reply, "y", &family);
+                r = sd_bus_message_read(reply, "i", &family);
                 if (r < 0)
                         return bus_log_parse_error(r);
 
index a5079ad..8abf82e 100644 (file)
@@ -26,7 +26,7 @@
 int address_pool_new(
                 Manager *m,
                 AddressPool **ret,
-                unsigned family,
+                int family,
                 const union in_addr_union *u,
                 unsigned prefixlen) {
 
@@ -54,7 +54,7 @@ int address_pool_new(
 int address_pool_new_from_string(
                 Manager *m,
                 AddressPool **ret,
-                unsigned family,
+                int family,
                 const char *p,
                 unsigned prefixlen) {
 
index e363fb0..b0e3191 100644 (file)
@@ -467,7 +467,7 @@ finish:
         return r;
 }
 
-int manager_address_pool_acquire(Manager *m, unsigned family, unsigned prefixlen, union in_addr_union *found) {
+int manager_address_pool_acquire(Manager *m, int family, unsigned prefixlen, union in_addr_union *found) {
         AddressPool *p;
         int r;
 
index a523522..042e160 100644 (file)
@@ -104,7 +104,7 @@ struct NetDev {
 
         unsigned ttl;
         unsigned tos;
-        unsigned char family;
+        int family;
         union in_addr_union local;
         union in_addr_union remote;
         union in_addr_union group;
index 9abc0d4..f1c7f20 100644 (file)
@@ -115,7 +115,7 @@ struct Address {
         Network *network;
         uint64_t section;
 
-        unsigned char family;
+        int family;
         unsigned char prefixlen;
         unsigned char scope;
         char *label;
@@ -133,7 +133,7 @@ struct Route {
         Network *network;
         uint64_t section;
 
-        unsigned char family;
+        int family;
         unsigned char dst_prefixlen;
         unsigned char scope;
         uint32_t metrics;
@@ -209,7 +209,7 @@ struct Link {
 struct AddressPool {
         Manager *manager;
 
-        unsigned family;
+        int family;
         unsigned prefixlen;
 
         union in_addr_union in_addr;
@@ -255,7 +255,7 @@ int manager_bus_listen(Manager *m);
 
 int manager_save(Manager *m);
 
-int manager_address_pool_acquire(Manager *m, unsigned family, unsigned prefixlen, union in_addr_union *found);
+int manager_address_pool_acquire(Manager *m, int family, unsigned prefixlen, union in_addr_union *found);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
 #define _cleanup_manager_free_ _cleanup_(manager_freep)
@@ -390,8 +390,8 @@ int config_parse_dhcp(const char *unit, const char *filename, unsigned line,
 
 /* Address Pool */
 
-int address_pool_new(Manager *m, AddressPool **ret, unsigned family, const union in_addr_union *u, unsigned prefixlen);
-int address_pool_new_from_string(Manager *m, AddressPool **ret, unsigned family, const char *p, unsigned prefixlen);
+int address_pool_new(Manager *m, AddressPool **ret, int family, const union in_addr_union *u, unsigned prefixlen);
+int address_pool_new_from_string(Manager *m, AddressPool **ret, int family, const char *p, unsigned prefixlen);
 void address_pool_free(AddressPool *p);
 
 int address_pool_acquire(AddressPool *p, unsigned prefixlen, union in_addr_union *found);
index 09c5d05..985ebb7 100644 (file)
@@ -32,7 +32,7 @@
 
 NSS_GETHOSTBYNAME_PROTOTYPES(mymachines);
 
-static int count_addresses(sd_bus_message *m, unsigned af, unsigned *ret) {
+static int count_addresses(sd_bus_message *m, int af, unsigned *ret) {
         unsigned c = 0;
         int r;
 
@@ -40,9 +40,9 @@ static int count_addresses(sd_bus_message *m, unsigned af, unsigned *ret) {
         assert(ret);
 
         while ((r = sd_bus_message_enter_container(m, 'r', "yay")) > 0) {
-                unsigned char family;
+                int family;
 
-                r = sd_bus_message_read(m, "y", &family);
+                r = sd_bus_message_read(m, "i", &family);
                 if (r < 0)
                         return r;
 
@@ -122,7 +122,7 @@ enum nss_status _nss_mymachines_gethostbyname4_r(
         if (r < 0)
                 goto fail;
 
-        r = sd_bus_message_enter_container(reply, 'a', "(yay)");
+        r = sd_bus_message_enter_container(reply, 'a', "(iay)");
         if (r < 0)
                 goto fail;
 
@@ -151,12 +151,12 @@ enum nss_status _nss_mymachines_gethostbyname4_r(
 
         /* Second, append addresses */
         r_tuple_first = (struct gaih_addrtuple*) (buffer + idx);
-        while ((r = sd_bus_message_enter_container(reply, 'r', "yay")) > 0) {
-                unsigned char family;
+        while ((r = sd_bus_message_enter_container(reply, 'r', "iay")) > 0) {
+                int family;
                 const void *a;
                 size_t sz;
 
-                r = sd_bus_message_read(reply, "y", &family);
+                r = sd_bus_message_read(reply, "i", &family);
                 if (r < 0)
                         goto fail;
 
@@ -267,7 +267,7 @@ enum nss_status _nss_mymachines_gethostbyname3_r(
         if (r < 0)
                 goto fail;
 
-        r = sd_bus_message_enter_container(reply, 'a', "(yay)");
+        r = sd_bus_message_enter_container(reply, 'a', "(iay)");
         if (r < 0)
                 goto fail;
 
@@ -307,12 +307,12 @@ enum nss_status _nss_mymachines_gethostbyname3_r(
 
         /* Third, append addresses */
         r_addr = buffer + idx;
-        while ((r = sd_bus_message_enter_container(reply, 'r', "yay")) > 0) {
-                unsigned char family;
+        while ((r = sd_bus_message_enter_container(reply, 'r', "iay")) > 0) {
+                int family;
                 const void *a;
                 size_t sz;
 
-                r = sd_bus_message_read(reply, "y", &family);
+                r = sd_bus_message_read(reply, "i", &family);
                 if (r < 0)
                         goto fail;
 
index c67f59e..c172022 100644 (file)
@@ -43,20 +43,20 @@ NSS_GETHOSTBYADDR_PROTOTYPES(resolve);
 
 #define DNS_CALL_TIMEOUT_USEC (45*USEC_PER_SEC)
 
-static int count_addresses(sd_bus_message *m, unsigned af, const char **canonical) {
+static int count_addresses(sd_bus_message *m, int af, const char **canonical) {
         int c = 0, r;
 
         assert(m);
         assert(canonical);
 
-        r = sd_bus_message_enter_container(m, 'a', "(yayi)");
+        r = sd_bus_message_enter_container(m, 'a', "(iayi)");
         if (r < 0)
                 return r;
 
-        while ((r = sd_bus_message_enter_container(m, 'r', "yayi")) > 0) {
-                unsigned char family;
+        while ((r = sd_bus_message_enter_container(m, 'r', "iayi")) > 0) {
+                int family;
 
-                r = sd_bus_message_read(m, "y", &family);
+                r = sd_bus_message_read(m, "i", &family);
                 if (r < 0)
                         return r;
 
@@ -178,17 +178,16 @@ enum nss_status _nss_resolve_gethostbyname4_r(
         /* Second, append addresses */
         r_tuple_first = (struct gaih_addrtuple*) (buffer + idx);
 
-        r = sd_bus_message_enter_container(reply, 'a', "(yayi)");
+        r = sd_bus_message_enter_container(reply, 'a', "(iayi)");
         if (r < 0)
                 goto fail;
 
-        while ((r = sd_bus_message_enter_container(reply, 'r', "yayi")) > 0) {
-                unsigned char family;
+        while ((r = sd_bus_message_enter_container(reply, 'r', "iayi")) > 0) {
+                int family, ifindex;
                 const void *a;
-                int ifindex;
                 size_t sz;
 
-                r = sd_bus_message_read(reply, "y", &family);
+                r = sd_bus_message_read(reply, "i", &family);
                 if (r < 0)
                         goto fail;
 
@@ -356,17 +355,16 @@ enum nss_status _nss_resolve_gethostbyname3_r(
         /* Third, append addresses */
         r_addr = buffer + idx;
 
-        r = sd_bus_message_enter_container(reply, 'a', "(yayi)");
+        r = sd_bus_message_enter_container(reply, 'a', "(iayi)");
         if (r < 0)
                 goto fail;
 
-        while ((r = sd_bus_message_enter_container(reply, 'r', "yayi")) > 0) {
-                unsigned char family;
+        while ((r = sd_bus_message_enter_container(reply, 'r', "iayi")) > 0) {
+                int family, ifindex;
                 const void *a;
-                int ifindex;
                 size_t sz;
 
-                r = sd_bus_message_read(reply, "y", &family);
+                r = sd_bus_message_read(reply, "i", &family);
                 if (r < 0)
                         goto fail;
 
@@ -487,7 +485,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
         if (r < 0)
                 goto fail;
 
-        r = sd_bus_message_append(req, "y", af);
+        r = sd_bus_message_append(req, "i", af);
         if (r < 0)
                 goto fail;
 
index f486fcd..11d94af 100644 (file)
@@ -98,18 +98,18 @@ static int append_address(sd_bus_message *reply, DnsResourceRecord *rr, int ifin
         assert(reply);
         assert(rr);
 
-        r = sd_bus_message_open_container(reply, 'r', "yayi");
+        r = sd_bus_message_open_container(reply, 'r', "iayi");
         if (r < 0)
                 return r;
 
         if (rr->key.type == DNS_TYPE_A) {
-                r = sd_bus_message_append(reply, "y", AF_INET);
+                r = sd_bus_message_append(reply, "i", AF_INET);
                 if (r < 0)
                         return r;
 
                 r = sd_bus_message_append_array(reply, 'y', &rr->a.in_addr, sizeof(struct in_addr));
         } else {
-                r = sd_bus_message_append(reply, "y", AF_INET6);
+                r = sd_bus_message_append(reply, "i", AF_INET6);
                 if (r < 0)
                         return r;
 
@@ -152,7 +152,7 @@ static void bus_method_resolve_hostname_complete(DnsQuery *q) {
         if (r < 0)
                 goto finish;
 
-        r = sd_bus_message_open_container(reply, 'a', "(yayi)");
+        r = sd_bus_message_open_container(reply, 'a', "(iayi)");
         if (r < 0)
                 goto finish;
 
@@ -265,7 +265,7 @@ finish:
 static int bus_method_resolve_hostname(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
         Manager *m = userdata;
         const char *hostname;
-        uint8_t family;
+        int family;
         DnsResourceKey keys[2];
         DnsQuery *q;
         unsigned n = 0;
@@ -275,12 +275,12 @@ static int bus_method_resolve_hostname(sd_bus *bus, sd_bus_message *message, voi
         assert(message);
         assert(m);
 
-        r = sd_bus_message_read(message, "sy", &hostname, &family);
+        r = sd_bus_message_read(message, "si", &hostname, &family);
         if (r < 0)
                 return r;
 
         if (!IN_SET(family, AF_INET, AF_INET6, AF_UNSPEC))
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %u", family);
+                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family);
 
         if (!hostname_is_valid(hostname))
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid hostname '%s'", hostname);
@@ -389,7 +389,7 @@ finish:
 static int bus_method_resolve_address(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
         _cleanup_(dns_resource_key_free) DnsResourceKey key = {};
         Manager *m = userdata;
-        uint8_t family;
+        int family;
         const void *d;
         int ifindex;
         DnsQuery *q;
@@ -400,19 +400,18 @@ static int bus_method_resolve_address(sd_bus *bus, sd_bus_message *message, void
         assert(message);
         assert(m);
 
-        r = sd_bus_message_read(message, "y", &family);
+        r = sd_bus_message_read(message, "i", &family);
         if (r < 0)
                 return r;
 
         if (!IN_SET(family, AF_INET, AF_INET6))
-                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %u", family);
+                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family);
 
         r = sd_bus_message_read_array(message, 'y', &d, &sz);
         if (r < 0)
                 return r;
 
-        if ((family == AF_INET && sz != sizeof(struct in_addr)) ||
-            (family == AF_INET6 && sz != sizeof(struct in6_addr)))
+        if (sz != FAMILY_ADDRESS_SIZE(family))
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid address size");
 
         r = sd_bus_message_read(message, "i", &ifindex);
index 565c67c..4fd2d40 100644 (file)
@@ -70,9 +70,9 @@ struct DnsPacket {
 
         /* Packet reception meta data */
         int ifindex;
-        unsigned char family;
+        int family;
         union in_addr_union sender, destination;
-        unsigned ttl;
+        uint32_t ttl;
 };
 
 static inline uint8_t* DNS_PACKET_DATA(DnsPacket *p) {
index aa20503..2b814cc 100644 (file)
@@ -90,7 +90,7 @@ struct DnsQuery {
 
         /* Bus client information */
         sd_bus_message *request;
-        unsigned char request_family;
+        int request_family;
         const char *request_hostname;
         union in_addr_union request_address;
 
index 373f5c3..38b6490 100644 (file)
@@ -28,7 +28,7 @@
 
 #define SEND_TIMEOUT_USEC (2*USEC_PER_SEC)
 
-int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol protocol, unsigned char family) {
+int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol protocol, int family) {
         DnsScope *s;
 
         assert(m);
@@ -106,7 +106,7 @@ void dns_scope_next_dns_server(DnsScope *s) {
 int dns_scope_send(DnsScope *s, DnsPacket *p) {
         union in_addr_union addr;
         int ifindex = 0, r;
-        unsigned char family;
+        int family;
         uint16_t port;
         uint32_t mtu;
         int fd;
index 32541f1..6c93fa8 100644 (file)
@@ -44,7 +44,7 @@ struct DnsScope {
         Manager *manager;
 
         DnsProtocol protocol;
-        unsigned char family;
+        int family;
 
         Link *link;
 
@@ -57,7 +57,7 @@ struct DnsScope {
         LIST_FIELDS(DnsScope, scopes);
 };
 
-int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, unsigned char family);
+int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family);
 DnsScope* dns_scope_free(DnsScope *s);
 
 int dns_scope_send(DnsScope *s, DnsPacket *p);
index 07754a0..734441b 100644 (file)
@@ -26,7 +26,7 @@ int dns_server_new(
                 DnsServer **ret,
                 DnsServerSource source,
                 Link *l,
-                unsigned char family,
+                int family,
                 const union in_addr_union *in_addr) {
 
         DnsServer *s, *tail;
index 781e237..2b0b996 100644 (file)
@@ -43,7 +43,7 @@ struct DnsServer {
 
         Link *link;
 
-        unsigned char family;
+        int family;
         union in_addr_union address;
 
         bool marked:1;
@@ -56,7 +56,7 @@ int dns_server_new(
                 DnsServer **s,
                 DnsServerSource source,
                 Link *l,
-                unsigned char family,
+                int family,
                 const union in_addr_union *address);
 
 DnsServer* dns_server_free(DnsServer *s);
index 804837c..078301a 100644 (file)
@@ -259,7 +259,7 @@ int link_update_monitor(Link *l) {
         return 0;
 }
 
-bool link_relevant(Link *l, unsigned char family) {
+bool link_relevant(Link *l, int family) {
         _cleanup_free_ char *state = NULL;
         LinkAddress *a;
 
@@ -282,7 +282,7 @@ bool link_relevant(Link *l, unsigned char family) {
         return false;
 }
 
-LinkAddress *link_find_address(Link *l, unsigned char family, union in_addr_union *in_addr) {
+LinkAddress *link_find_address(Link *l, int family, union in_addr_union *in_addr) {
         LinkAddress *a;
 
         assert(l);
@@ -294,7 +294,7 @@ LinkAddress *link_find_address(Link *l, unsigned char family, union in_addr_unio
         return NULL;
 }
 
-DnsServer* link_find_dns_server(Link *l, DnsServerSource source, unsigned char family, union in_addr_union *in_addr) {
+DnsServer* link_find_dns_server(Link *l, DnsServerSource source, int family, union in_addr_union *in_addr) {
         DnsServer *first, *s;
 
         assert(l);
@@ -352,7 +352,7 @@ void link_next_dns_server(Link *l) {
         }
 }
 
-int link_address_new(Link *l, LinkAddress **ret, unsigned char family, union in_addr_union *in_addr) {
+int link_address_new(Link *l, LinkAddress **ret, int family, union in_addr_union *in_addr) {
         LinkAddress *a;
 
         assert(l);
index d4e5c0a..bd32a70 100644 (file)
@@ -36,7 +36,7 @@ typedef struct LinkAddress LinkAddress;
 struct LinkAddress {
         Link *link;
 
-        unsigned char family;
+        int family;
         union in_addr_union in_addr;
 
         unsigned char flags, scope;
@@ -71,14 +71,14 @@ int link_new(Manager *m, Link **ret, int ifindex);
 Link *link_free(Link *l);
 int link_update_rtnl(Link *l, sd_rtnl_message *m);
 int link_update_monitor(Link *l);
-bool link_relevant(Link *l, unsigned char family);
-LinkAddress* link_find_address(Link *l, unsigned char family, union in_addr_union *in_addr);
+bool link_relevant(Link *l, int family);
+LinkAddress* link_find_address(Link *l, int family, union in_addr_union *in_addr);
 
-DnsServer* link_find_dns_server(Link *l, DnsServerSource source, unsigned char family, union in_addr_union *in_addr);
+DnsServer* link_find_dns_server(Link *l, DnsServerSource source, int family, union in_addr_union *in_addr);
 DnsServer* link_get_dns_server(Link *l);
 void link_next_dns_server(Link *l);
 
-int link_address_new(Link *l, LinkAddress **ret, unsigned char family, union in_addr_union *in_addr);
+int link_address_new(Link *l, LinkAddress **ret, int family, union in_addr_union *in_addr);
 LinkAddress *link_address_free(LinkAddress *a);
 int link_address_update_rtnl(LinkAddress *a, sd_rtnl_message *m);
 bool link_address_relevant(LinkAddress *l);
index 9f44bf1..9672843 100644 (file)
@@ -94,9 +94,8 @@ fail:
 static int manager_process_address(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userdata) {
         Manager *m = userdata;
         union in_addr_union address;
-        unsigned char family;
         uint16_t type;
-        int r, ifindex;
+        int r, ifindex, family;
         LinkAddress *a;
         Link *l;
 
@@ -311,7 +310,7 @@ static int parse_dns_server_string(Manager *m, const char *string) {
 
         FOREACH_WORD_QUOTED(word, length, string, state) {
                 char buffer[length+1];
-                unsigned family;
+                int family;
                 union in_addr_union addr;
 
                 memcpy(buffer, word, length);
@@ -860,7 +859,7 @@ static int manager_ipv6_send(Manager *m, int fd, int ifindex, struct in6_addr *a
         return sendmsg_loop(fd, &mh, 0);
 }
 
-int manager_send(Manager *m, int fd, int ifindex, unsigned char family, union in_addr_union *addr, uint16_t port, DnsPacket *p) {
+int manager_send(Manager *m, int fd, int ifindex, int family, union in_addr_union *addr, uint16_t port, DnsPacket *p) {
         assert(m);
         assert(fd >= 0);
         assert(addr);
@@ -876,7 +875,7 @@ int manager_send(Manager *m, int fd, int ifindex, unsigned char family, union in
 }
 
 
-DnsServer* manager_find_dns_server(Manager *m, unsigned char family, union in_addr_union *in_addr) {
+DnsServer* manager_find_dns_server(Manager *m, int family, union in_addr_union *in_addr) {
         DnsServer *s;
 
         assert(m);
index 0770bb5..35ef8bd 100644 (file)
@@ -89,12 +89,12 @@ Manager* manager_free(Manager *m);
 int manager_parse_config_file(Manager *m);
 int manager_write_resolv_conf(Manager *m);
 
-DnsServer* manager_find_dns_server(Manager *m, unsigned char family, union in_addr_union *in_addr);
+DnsServer* manager_find_dns_server(Manager *m, int family, union in_addr_union *in_addr);
 DnsServer *manager_get_dns_server(Manager *m);
 void manager_next_dns_server(Manager *m);
 uint32_t manager_find_mtu(Manager *m);
 
-int manager_send(Manager *m, int fd, int ifindex, unsigned char family, union in_addr_union *addr, uint16_t port, DnsPacket *p);
+int manager_send(Manager *m, int fd, int ifindex, int family, union in_addr_union *addr, uint16_t port, DnsPacket *p);
 int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret);
 
 int manager_dns_ipv4_fd(Manager *m);
index 0c6ebec..ffbaa74 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "in-addr-util.h"
 
-int in_addr_null(unsigned family, union in_addr_union *u) {
+int in_addr_null(int family, union in_addr_union *u) {
         assert(u);
 
         if (family == AF_INET)
@@ -40,7 +40,7 @@ int in_addr_null(unsigned family, union in_addr_union *u) {
 }
 
 
-int in_addr_equal(unsigned family, union in_addr_union *a, union in_addr_union *b) {
+int in_addr_equal(int family, union in_addr_union *a, union in_addr_union *b) {
         assert(a);
         assert(b);
 
@@ -58,7 +58,7 @@ int in_addr_equal(unsigned family, union in_addr_union *a, union in_addr_union *
 }
 
 int in_addr_prefix_intersect(
-                unsigned family,
+                int family,
                 const union in_addr_union *a,
                 unsigned aprefixlen,
                 const union in_addr_union *b,
@@ -114,7 +114,7 @@ int in_addr_prefix_intersect(
         return -EAFNOSUPPORT;
 }
 
-int in_addr_prefix_next(unsigned family, union in_addr_union *u, unsigned prefixlen) {
+int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen) {
         assert(u);
 
         /* Increases the network part of an address by one. Returns
@@ -167,7 +167,7 @@ int in_addr_prefix_next(unsigned family, union in_addr_union *u, unsigned prefix
         return -EAFNOSUPPORT;
 }
 
-int in_addr_to_string(unsigned family, const union in_addr_union *u, char **ret) {
+int in_addr_to_string(int family, const union in_addr_union *u, char **ret) {
         char *x;
         size_t l;
 
@@ -195,7 +195,7 @@ int in_addr_to_string(unsigned family, const union in_addr_union *u, char **ret)
         return 0;
 }
 
-int in_addr_from_string(unsigned family, const char *s, union in_addr_union *ret) {
+int in_addr_from_string(int family, const char *s, union in_addr_union *ret) {
 
         assert(s);
         assert(ret);
@@ -210,7 +210,7 @@ int in_addr_from_string(unsigned family, const char *s, union in_addr_union *ret
         return 0;
 }
 
-int in_addr_from_string_auto(const char *s, unsigned *family, union in_addr_union *ret) {
+int in_addr_from_string_auto(const char *s, int *family, union in_addr_union *ret) {
         int r;
 
         assert(s);
index 6cfdb14..d76ea9d 100644 (file)
@@ -31,13 +31,13 @@ union in_addr_union {
         struct in6_addr in6;
 };
 
-int in_addr_null(unsigned family, union in_addr_union *u);
-int in_addr_equal(unsigned family, union in_addr_union *a, union in_addr_union *b);
-int in_addr_prefix_intersect(unsigned family, const union in_addr_union *a, unsigned aprefixlen, const union in_addr_union *b, unsigned bprefixlen);
-int in_addr_prefix_next(unsigned family, union in_addr_union *u, unsigned prefixlen);
-int in_addr_to_string(unsigned family, const union in_addr_union *u, char **ret);
-int in_addr_from_string(unsigned family, const char *s, union in_addr_union *ret);
-int in_addr_from_string_auto(const char *s, unsigned *family, union in_addr_union *ret);
+int in_addr_null(int family, union in_addr_union *u);
+int in_addr_equal(int family, union in_addr_union *a, union in_addr_union *b);
+int in_addr_prefix_intersect(int family, const union in_addr_union *a, unsigned aprefixlen, const union in_addr_union *b, unsigned bprefixlen);
+int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen);
+int in_addr_to_string(int family, const union in_addr_union *u, char **ret);
+int in_addr_from_string(int family, const char *s, union in_addr_union *ret);
+int in_addr_from_string_auto(const char *s, int *family, union in_addr_union *ret);
 
 static inline size_t FAMILY_ADDRESS_SIZE(int family) {
         assert(family == AF_INET || family == AF_INET6);
index 497705d..5cd26d9 100644 (file)
@@ -68,11 +68,11 @@ int sd_rtnl_detach_event(sd_rtnl *nl);
 
 /* messages */
 int sd_rtnl_message_new_link(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t msg_type, int index);
-int sd_rtnl_message_new_addr_update(sd_rtnl *rtnl, sd_rtnl_message **ret, int index, unsigned char family);
+int sd_rtnl_message_new_addr_update(sd_rtnl *rtnl, sd_rtnl_message **ret, int index, int family);
 int sd_rtnl_message_new_addr(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t msg_type, int index,
-                             unsigned char family);
+                             int family);
 int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t nlmsg_type,
-                              unsigned char rtm_family);
+                              int rtm_family);
 
 sd_rtnl_message *sd_rtnl_message_ref(sd_rtnl_message *m);
 sd_rtnl_message *sd_rtnl_message_unref(sd_rtnl_message *m);
@@ -85,7 +85,7 @@ int sd_rtnl_message_is_broadcast(sd_rtnl_message *m);
 int sd_rtnl_message_addr_set_prefixlen(sd_rtnl_message *m, unsigned char prefixlen);
 int sd_rtnl_message_addr_set_scope(sd_rtnl_message *m, unsigned char scope);
 int sd_rtnl_message_addr_set_flags(sd_rtnl_message *m, unsigned char flags);
-int sd_rtnl_message_addr_get_family(sd_rtnl_message *m, unsigned char *family);
+int sd_rtnl_message_addr_get_family(sd_rtnl_message *m, int *family);
 int sd_rtnl_message_addr_get_prefixlen(sd_rtnl_message *m, unsigned char *prefixlen);
 int sd_rtnl_message_addr_get_scope(sd_rtnl_message *m, unsigned char *scope);
 int sd_rtnl_message_addr_get_flags(sd_rtnl_message *m, unsigned char *flags);