summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-23 17:19:35 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-26 15:34:42 +0200
commit73e94c0dcb41c0924d506a329f874e69409437f6 (patch)
tree92badf3e16a733497db1e22c7a81b9fef564f1d1 /src
parenta48fc60a331803fcd4add17cdb5b3cae99bc2e80 (diff)
ipv4l-{acd,ll}: make sure ipv4 addresses are unsigned
And some other minor fixes.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-network/sd-ipv4acd.c4
-rw-r--r--src/libsystemd-network/sd-ipv4ll.c20
-rw-r--r--src/systemd/sd-ipv4ll.h2
3 files changed, 10 insertions, 16 deletions
diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c
index 2fc8651399..e78d8a04f2 100644
--- a/src/libsystemd-network/sd-ipv4acd.c
+++ b/src/libsystemd-network/sd-ipv4acd.c
@@ -48,8 +48,8 @@
#define RATE_LIMIT_INTERVAL 60
#define DEFEND_INTERVAL 10
-#define IPV4ACD_NETWORK 0xA9FE0000L
-#define IPV4ACD_NETMASK 0xFFFF0000L
+#define IPV4ACD_NETWORK 0xA9FE0000UL
+#define IPV4ACD_NETMASK 0xFFFF0000UL
#define log_ipv4acd_errno(ll, error, fmt, ...) log_internal(LOG_DEBUG, error, __FILE__, __LINE__, __func__, "ACD: " fmt, ##__VA_ARGS__)
#define log_ipv4acd(ll, fmt, ...) log_ipv4acd_errno(ll, 0, fmt, ##__VA_ARGS__)
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index ea6d9d22f1..1f6da4bb16 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -35,8 +35,8 @@
#include "sparse-endian.h"
#include "util.h"
-#define IPV4LL_NETWORK 0xA9FE0000L
-#define IPV4LL_NETMASK 0xFFFF0000L
+#define IPV4LL_NETWORK 0xA9FE0000UL
+#define IPV4LL_NETMASK 0xFFFF0000UL
#define IPV4LL_DONT_DESTROY(ll) \
_cleanup_(sd_ipv4ll_unrefp) _unused_ sd_ipv4ll *_dont_destroy_##ll = sd_ipv4ll_ref(ll)
@@ -161,15 +161,9 @@ int sd_ipv4ll_detach_event(sd_ipv4ll *ll) {
}
int sd_ipv4ll_attach_event(sd_ipv4ll *ll, sd_event *event, int64_t priority) {
- int r;
-
assert_return(ll, -EINVAL);
- r = sd_ipv4acd_attach_event(ll->acd, event, priority);
- if (r < 0)
- return r;
-
- return 0;
+ return sd_ipv4acd_attach_event(ll->acd, event, priority);
}
int sd_ipv4ll_set_callback(sd_ipv4ll *ll, sd_ipv4ll_callback_t cb, void *userdata) {
@@ -275,7 +269,7 @@ static int ipv4ll_pick_address(sd_ipv4ll *ll) {
r = random_r(ll->random_data, &random);
if (r < 0)
return r;
- addr = htonl((random & 0x0000FFFF) | IPV4LL_NETWORK);
+ addr = htobe32((random & 0x0000FFFF) | IPV4LL_NETWORK);
} while (addr == ll->address ||
(ntohl(addr) & 0x0000FF00) == 0x0000 ||
(ntohl(addr) & 0x0000FF00) == 0xFF00);
@@ -324,17 +318,17 @@ void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata) {
assert(ll);
switch (event) {
+
case SD_IPV4ACD_EVENT_STOP:
ipv4ll_client_notify(ll, SD_IPV4LL_EVENT_STOP);
-
ll->claimed_address = 0;
-
break;
+
case SD_IPV4ACD_EVENT_BIND:
ll->claimed_address = ll->address;
ipv4ll_client_notify(ll, SD_IPV4LL_EVENT_BIND);
-
break;
+
case SD_IPV4ACD_EVENT_CONFLICT:
/* if an address was already bound we must call up to the
user to handle this, otherwise we just try again */
diff --git a/src/systemd/sd-ipv4ll.h b/src/systemd/sd-ipv4ll.h
index 95ed972ffe..4682dd6605 100644
--- a/src/systemd/sd-ipv4ll.h
+++ b/src/systemd/sd-ipv4ll.h
@@ -51,7 +51,7 @@ int sd_ipv4ll_start(sd_ipv4ll *ll);
int sd_ipv4ll_stop(sd_ipv4ll *ll);
sd_ipv4ll *sd_ipv4ll_ref(sd_ipv4ll *ll);
sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll);
-int sd_ipv4ll_new (sd_ipv4ll **ret);
+int sd_ipv4ll_new(sd_ipv4ll **ret);
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ipv4ll, sd_ipv4ll_unref);