mirror of
https://github.com/systemd/systemd.git
synced 2025-01-23 02:04:32 +03:00
timesyncd: split up into multiple source file
The source file got much too large, hence split up the sources into multiple per-object files, similar in style to resolved.
This commit is contained in:
parent
f7d68aa8c9
commit
84e51726a3
10
Makefile.am
10
Makefile.am
@ -2441,7 +2441,8 @@ libsystemd_internal_la_SOURCES = \
|
||||
src/libsystemd/sd-login/sd-login.c \
|
||||
src/libsystemd/sd-path/sd-path.c \
|
||||
src/libsystemd/sd-network/sd-network.c \
|
||||
src/libsystemd/sd-network/network-util.h
|
||||
src/libsystemd/sd-network/network-util.h \
|
||||
src/libsystemd/sd-network/network-util.c
|
||||
|
||||
nodist_libsystemd_internal_la_SOURCES = \
|
||||
src/libsystemd/libsystemd.sym \
|
||||
@ -4593,7 +4594,12 @@ EXTRA_DIST += \
|
||||
if ENABLE_TIMESYNCD
|
||||
systemd_timesyncd_SOURCES = \
|
||||
src/timesync/timesyncd.c \
|
||||
src/timesync/timesyncd.h
|
||||
src/timesync/timesyncd-manager.c \
|
||||
src/timesync/timesyncd-manager.h \
|
||||
src/timesync/timesyncd-conf.c \
|
||||
src/timesync/timesyncd-conf.h \
|
||||
src/timesync/timesyncd-server.c \
|
||||
src/timesync/timesyncd-server.h
|
||||
|
||||
nodist_systemd_timesyncd_SOURCES = \
|
||||
src/timesync/timesyncd-gperf.c
|
||||
|
37
src/libsystemd/sd-network/network-util.c
Normal file
37
src/libsystemd/sd-network/network-util.c
Normal file
@ -0,0 +1,37 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2014 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "strv.h"
|
||||
#include "network-util.h"
|
||||
|
||||
bool network_is_online(void) {
|
||||
_cleanup_free_ char *state = NULL;
|
||||
int r;
|
||||
|
||||
r = sd_network_get_operational_state(&state);
|
||||
if (r < 0) /* if we don't know anything, we consider the system online */
|
||||
return true;
|
||||
|
||||
if (STR_IN_SET(state, "routable", "degraded"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
@ -25,5 +25,6 @@
|
||||
#include "sd-network.h"
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_network_monitor*, sd_network_monitor_unref);
|
||||
|
||||
#define _cleanup_network_monitor_unref_ _cleanup_(sd_network_monitor_unrefp)
|
||||
|
||||
bool network_is_online(void);
|
||||
|
49
src/timesync/timesyncd-conf.c
Normal file
49
src/timesync/timesyncd-conf.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2014 Kay Sievers, Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "timesyncd-manager.h"
|
||||
#include "timesyncd-conf.h"
|
||||
|
||||
int config_parse_servers(
|
||||
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) {
|
||||
|
||||
Manager *m = userdata;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
|
||||
if (isempty(rvalue))
|
||||
manager_flush_names(m);
|
||||
|
||||
manager_add_server_string(m, rvalue);
|
||||
|
||||
return 0;
|
||||
}
|
28
src/timesync/timesyncd-conf.h
Normal file
28
src/timesync/timesyncd-conf.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2014 Kay Sievers, Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "conf-parser.h"
|
||||
|
||||
const struct ConfigPerfItem* timesyncd_gperf_lookup(const char *key, unsigned length);
|
||||
|
||||
int config_parse_servers(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);
|
@ -1,7 +1,7 @@
|
||||
%{
|
||||
#include <stddef.h>
|
||||
#include "conf-parser.h"
|
||||
#include "timesyncd.h"
|
||||
#include "timesyncd-conf.h"
|
||||
%}
|
||||
struct ConfigPerfItem;
|
||||
%null_strings
|
||||
|
1083
src/timesync/timesyncd-manager.c
Normal file
1083
src/timesync/timesyncd-manager.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,7 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
@ -19,38 +21,23 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "list.h"
|
||||
#include "socket-util.h"
|
||||
#include "ratelimit.h"
|
||||
#include "sd-event.h"
|
||||
#include "sd-resolve.h"
|
||||
#include "sd-network.h"
|
||||
#include "list.h"
|
||||
#include "socket-util.h"
|
||||
#include "ratelimit.h"
|
||||
#include "timesyncd-server.h"
|
||||
|
||||
typedef struct Manager Manager;
|
||||
typedef struct ServerAddress ServerAddress;
|
||||
typedef struct ServerName ServerName;
|
||||
|
||||
struct ServerAddress {
|
||||
union sockaddr_union sockaddr;
|
||||
socklen_t socklen;
|
||||
LIST_FIELDS(ServerAddress, addresses);
|
||||
};
|
||||
|
||||
struct ServerName {
|
||||
char *string;
|
||||
LIST_HEAD(ServerAddress, addresses);
|
||||
LIST_FIELDS(ServerName, names);
|
||||
};
|
||||
|
||||
static inline int server_address_pretty(ServerAddress *a, char **pretty) {
|
||||
return sockaddr_pretty(&a->sockaddr.sa, a->socklen, true, pretty);
|
||||
}
|
||||
|
||||
struct Manager {
|
||||
sd_event *event;
|
||||
sd_resolve *resolve;
|
||||
|
||||
LIST_HEAD(ServerName, link_servers);
|
||||
LIST_HEAD(ServerName, servers);
|
||||
LIST_HEAD(ServerName, fallback_servers);
|
||||
|
||||
RateLimit ratelimit;
|
||||
|
||||
@ -102,6 +89,13 @@ struct Manager {
|
||||
bool rtc_local_time;
|
||||
};
|
||||
|
||||
const struct ConfigPerfItem* timesyncd_gperf_lookup(const char *key, unsigned length);
|
||||
int manager_new(Manager **ret);
|
||||
void manager_free(Manager *m);
|
||||
|
||||
int config_parse_servers(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);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
|
||||
|
||||
int manager_parse_config_file(Manager *m);
|
||||
int manager_add_server_string(Manager *m, const char *string);
|
||||
void manager_flush_names(Manager *m);
|
||||
int manager_connect(Manager *m);
|
||||
void manager_disconnect(Manager *m);
|
22
src/timesync/timesyncd-server.c
Normal file
22
src/timesync/timesyncd-server.c
Normal file
@ -0,0 +1,22 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2014 Kay Sievers, Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "timesyncd-server.h"
|
44
src/timesync/timesyncd-server.h
Normal file
44
src/timesync/timesyncd-server.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2014 Kay Sievers, Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
typedef struct ServerAddress ServerAddress;
|
||||
typedef struct ServerName ServerName;
|
||||
|
||||
#include "socket-util.h"
|
||||
#include "list.h"
|
||||
|
||||
struct ServerAddress {
|
||||
union sockaddr_union sockaddr;
|
||||
socklen_t socklen;
|
||||
LIST_FIELDS(ServerAddress, addresses);
|
||||
};
|
||||
|
||||
struct ServerName {
|
||||
char *string;
|
||||
LIST_HEAD(ServerAddress, addresses);
|
||||
LIST_FIELDS(ServerName, names);
|
||||
};
|
||||
|
||||
static inline int server_address_pretty(ServerAddress *a, char **pretty) {
|
||||
return sockaddr_pretty(&a->sockaddr.sa, a->socklen, true, pretty);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user