mirror of
https://github.com/systemd/systemd.git
synced 2024-10-28 11:55:44 +03:00
sd-ipv4ll: add a bit of logging to IPv4LL too
This commit is contained in:
parent
3aacc173e9
commit
703945c1dc
@ -34,6 +34,7 @@
|
||||
#include "random-util.h"
|
||||
#include "siphash24.h"
|
||||
#include "sparse-endian.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
|
||||
#define IPV4LL_NETWORK UINT32_C(0xA9FE0000)
|
||||
@ -63,6 +64,9 @@ struct sd_ipv4ll {
|
||||
void* userdata;
|
||||
};
|
||||
|
||||
#define log_ipv4ll_errno(ll, error, fmt, ...) log_internal(LOG_DEBUG, error, __FILE__, __LINE__, __func__, "IPV4LL: " fmt, ##__VA_ARGS__)
|
||||
#define log_ipv4ll(ll, fmt, ...) log_ipv4ll_errno(ll, 0, fmt, ##__VA_ARGS__)
|
||||
|
||||
static void ipv4ll_on_acd(sd_ipv4acd *ll, int event, void *userdata);
|
||||
|
||||
sd_ipv4ll *sd_ipv4ll_ref(sd_ipv4ll *ll) {
|
||||
@ -231,6 +235,7 @@ int sd_ipv4ll_set_address(sd_ipv4ll *ll, const struct in_addr *address) {
|
||||
#define PICK_HASH_KEY SD_ID128_MAKE(15,ac,82,a6,d6,3f,49,78,98,77,5d,0c,69,02,94,0b)
|
||||
|
||||
static int ipv4ll_pick_address(sd_ipv4ll *ll) {
|
||||
_cleanup_free_ char *address = NULL;
|
||||
be32_t addr;
|
||||
|
||||
assert(ll);
|
||||
@ -248,6 +253,9 @@ static int ipv4ll_pick_address(sd_ipv4ll *ll) {
|
||||
(be32toh(addr) & 0x0000FF00) == 0x0000 ||
|
||||
(be32toh(addr) & 0x0000FF00) == 0xFF00);
|
||||
|
||||
(void) in_addr_to_string(AF_INET, &(union in_addr_union) { .in.s_addr = addr }, &address);
|
||||
log_ipv4ll(ll, "Picked new IP address %s.", strna(address));
|
||||
|
||||
return sd_ipv4ll_set_address(ll, &(struct in_addr) { addr });
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user