summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/hexdecoct.c10
-rw-r--r--src/basic/hexdecoct.h1
-rw-r--r--src/nspawn/nspawn-network.c11
3 files changed, 12 insertions, 10 deletions
diff --git a/src/basic/hexdecoct.c b/src/basic/hexdecoct.c
index a5edccad20..da1add7c76 100644
--- a/src/basic/hexdecoct.c
+++ b/src/basic/hexdecoct.c
@@ -526,6 +526,16 @@ char base64char(int x) {
return table[x & 63];
}
+/* This is almost base64char(), but not entirely, as it uses the "url and filename safe" alphabet,
+ * since we don't want "/" appear in interface names (since interfaces appear in sysfs as filenames).
+ * See section #5 of RFC 4648. */
+char urlsafe_base64char(int x) {
+ static const char table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789-_";
+ return table[x & 63];
+}
+
int unbase64char(char c) {
unsigned offset;
diff --git a/src/basic/hexdecoct.h b/src/basic/hexdecoct.h
index 7e2a6892c0..4ace5b7a99 100644
--- a/src/basic/hexdecoct.h
+++ b/src/basic/hexdecoct.h
@@ -27,6 +27,7 @@ char base32hexchar(int x) _const_;
int unbase32hexchar(char c) _const_;
char base64char(int x) _const_;
+char urlsafe_base64char(int x) _const_;
int unbase64char(char c) _const_;
char *base32hexmem(const void *p, size_t l, bool padding);
diff --git a/src/nspawn/nspawn-network.c b/src/nspawn/nspawn-network.c
index d6b7d8e1d8..95e4b0213b 100644
--- a/src/nspawn/nspawn-network.c
+++ b/src/nspawn/nspawn-network.c
@@ -11,6 +11,7 @@
#include "alloc-util.h"
#include "ether-addr-util.h"
+#include "hexdecoct.h"
#include "lockfile-util.h"
#include "missing_network.h"
#include "netif-naming-scheme.h"
@@ -200,16 +201,6 @@ static int add_veth(
return 0;
}
-/* This is almost base64char(), but not entirely, as it uses the "url and filename safe" alphabet, since we
- * don't want "/" appear in interface names (since interfaces appear in sysfs as filenames). See section #5
- * of RFC 4648. */
-static char urlsafe_base64char(int x) {
- static const char table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789-_";
- return table[x & 63];
-}
-
static int shorten_ifname(char *ifname) {
char new_ifname[IFNAMSIZ];