networkd: add basic LLDP transmission support

Let's add some minimalistic LLDP sender support. The idea is that this is
either on or off, and all fields determined automatically rather than
configured explicitly.
This commit is contained in:
Lennart Poettering
2016-02-21 20:58:59 +01:00
parent b553a6b13c
commit 8e1ad1eaf7
9 changed files with 439 additions and 4 deletions
+28
View File
@@ -48,6 +48,9 @@ bool hostname_is_set(void) {
char* gethostname_malloc(void) {
struct utsname u;
/* This call tries to return something useful, either the actual hostname or it makes something up. The only
* reason it might mail is OOM. It might even return "localhost" if that's set. */
assert_se(uname(&u) >= 0);
if (isempty(u.nodename) || streq(u.nodename, "(none)"))
@@ -56,6 +59,31 @@ char* gethostname_malloc(void) {
return strdup(u.nodename);
}
int gethostname_strict(char **ret) {
struct utsname u;
char *k;
/* This call will rather fail than make up a name. It will not return "localhost" either. */
assert_se(uname(&u) >= 0);
if (isempty(u.nodename))
return -ENXIO;
if (streq(u.nodename, "(none)"))
return -ENXIO;
if (is_localhost(u.nodename))
return -ENXIO;
k = strdup(u.nodename);
if (!k)
return -ENOMEM;
*ret = k;
return 0;
}
static bool hostname_valid_char(char c) {
return
(c >= 'a' && c <= 'z') ||
+1
View File
@@ -26,6 +26,7 @@
bool hostname_is_set(void);
char* gethostname_malloc(void);
int gethostname_strict(char **ret);
bool hostname_is_valid(const char *s, bool allow_trailing_dot) _pure_;
char* hostname_cleanup(char *s);