summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-11-29 15:58:43 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-12-02 05:48:27 +0100
commitda96ad5ae2bf3e9fd94d145c4b75fdf54a214350 (patch)
tree0c8be8c1b1c3bb562cc7fedaabb8d2e4b2b9fee5 /src/shared
parent5dd9527883e0aa8705cf81448bc4bdb0456382fb (diff)
downloadsystemd-da96ad5ae2bf3e9fd94d145c4b75fdf54a214350.tar.gz
util: rename socket_protocol_{from,to}_name() to ip_protocol_{from,to}_name()
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-unit-util.c6
-rwxr-xr-xsrc/shared/generate-ip-protocol-list.sh (renamed from src/shared/generate-socket-protocol-list.sh)0
-rw-r--r--src/shared/ip-protocol-list.c36
-rw-r--r--src/shared/ip-protocol-list.h5
-rw-r--r--src/shared/ip-protocol-to-name.awk (renamed from src/shared/socket-protocol-to-name.awk)2
-rw-r--r--src/shared/meson.build32
-rw-r--r--src/shared/socket-protocol-list.c36
-rw-r--r--src/shared/socket-protocol-list.h5
8 files changed, 61 insertions, 61 deletions
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index 78a2be341c..a50b9f416e 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -15,6 +15,7 @@
#include "hexdecoct.h"
#include "hostname-util.h"
#include "in-addr-util.h"
+#include "ip-protocol-list.h"
#include "list.h"
#include "locale-util.h"
#include "mountpoint-util.h"
@@ -25,7 +26,6 @@
#include "rlimit-util.h"
#include "securebits-util.h"
#include "signal-util.h"
-#include "socket-protocol-list.h"
#include "string-util.h"
#include "syslog-util.h"
#include "terminal-util.h"
@@ -103,7 +103,7 @@ DEFINE_BUS_APPEND_PARSE("i", parse_errno);
DEFINE_BUS_APPEND_PARSE("i", sched_policy_from_string);
DEFINE_BUS_APPEND_PARSE("i", secure_bits_from_string);
DEFINE_BUS_APPEND_PARSE("i", signal_from_string);
-DEFINE_BUS_APPEND_PARSE("i", socket_protocol_from_name);
+DEFINE_BUS_APPEND_PARSE("i", ip_protocol_from_name);
DEFINE_BUS_APPEND_PARSE_PTR("i", int32_t, int, ioprio_parse_priority);
DEFINE_BUS_APPEND_PARSE_PTR("i", int32_t, int, parse_nice);
DEFINE_BUS_APPEND_PARSE_PTR("i", int32_t, int, safe_atoi);
@@ -1466,7 +1466,7 @@ static int bus_append_socket_property(sd_bus_message *m, const char *field, cons
if (streq(field, "SocketProtocol"))
- return bus_append_socket_protocol_from_name(m, field, eq);
+ return bus_append_ip_protocol_from_name(m, field, eq);
if (STR_IN_SET(field,
"ListenStream", "ListenDatagram", "ListenSequentialPacket", "ListenNetlink",
diff --git a/src/shared/generate-socket-protocol-list.sh b/src/shared/generate-ip-protocol-list.sh
index a9b1e0fb57..a9b1e0fb57 100755
--- a/src/shared/generate-socket-protocol-list.sh
+++ b/src/shared/generate-ip-protocol-list.sh
diff --git a/src/shared/ip-protocol-list.c b/src/shared/ip-protocol-list.c
new file mode 100644
index 0000000000..9a1c11b0d8
--- /dev/null
+++ b/src/shared/ip-protocol-list.c
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include <errno.h>
+#include <netinet/in.h>
+#include <string.h>
+
+#include "ip-protocol-list.h"
+#include "macro.h"
+
+static const struct ip_protocol_name* lookup_ip_protocol(register const char *str, register GPERF_LEN_TYPE len);
+
+#include "ip-protocol-from-name.h"
+#include "ip-protocol-to-name.h"
+
+const char *ip_protocol_to_name(int id) {
+
+ if (id < 0)
+ return NULL;
+
+ if (id >= (int) ELEMENTSOF(ip_protocol_names))
+ return NULL;
+
+ return ip_protocol_names[id];
+}
+
+int ip_protocol_from_name(const char *name) {
+ const struct ip_protocol_name *sc;
+
+ assert(name);
+
+ sc = lookup_ip_protocol(name, strlen(name));
+ if (!sc)
+ return -EINVAL;
+
+ return sc->id;
+}
diff --git a/src/shared/ip-protocol-list.h b/src/shared/ip-protocol-list.h
new file mode 100644
index 0000000000..dfe346744f
--- /dev/null
+++ b/src/shared/ip-protocol-list.h
@@ -0,0 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
+
+const char *ip_protocol_to_name(int id);
+int ip_protocol_from_name(const char *name);
diff --git a/src/shared/socket-protocol-to-name.awk b/src/shared/ip-protocol-to-name.awk
index 4848a7631a..824f811f5c 100644
--- a/src/shared/socket-protocol-to-name.awk
+++ b/src/shared/ip-protocol-to-name.awk
@@ -1,5 +1,5 @@
BEGIN{
- print "static const char* const socket_protocol_names[] = { "
+ print "static const char* const ip_protocol_names[] = { "
}
!/HOPOPTS/ {
printf " [IPPROTO_%s] = \"%s\",\n", $1, tolower($1)
diff --git a/src/shared/meson.build b/src/shared/meson.build
index 85c546eb5b..ea8f959129 100644
--- a/src/shared/meson.build
+++ b/src/shared/meson.build
@@ -127,8 +127,8 @@ shared_sources = files('''
serialize.h
sleep-config.c
sleep-config.h
- socket-protocol-list.c
- socket-protocol-list.h
+ ip-protocol-list.c
+ ip-protocol-list.h
spawn-ask-password-agent.c
spawn-ask-password-agent.h
spawn-polkit-agent.c
@@ -188,39 +188,39 @@ if conf.get('HAVE_KMOD') == 1
shared_sources += files('module-util.c')
endif
-generate_socket_protocol_list = find_program('generate-socket-protocol-list.sh')
-socket_protocol_list_txt = custom_target(
- 'socket-protocol-list.txt',
- output : 'socket-protocol-list.txt',
- command : [generate_socket_protocol_list, cpp],
+generate_ip_protocol_list = find_program('generate-ip-protocol-list.sh')
+ip_protocol_list_txt = custom_target(
+ 'ip-protocol-list.txt',
+ output : 'ip-protocol-list.txt',
+ command : [generate_ip_protocol_list, cpp],
capture : true)
-fname = 'socket-protocol-from-name.gperf'
+fname = 'ip-protocol-from-name.gperf'
gperf_file = custom_target(
fname,
- input : socket_protocol_list_txt,
+ input : ip_protocol_list_txt,
output : fname,
- command : [generate_gperfs, 'socket_protocol', 'IPPROTO_', '@INPUT@'],
+ command : [generate_gperfs, 'ip_protocol', 'IPPROTO_', '@INPUT@'],
capture : true)
-fname = 'socket-protocol-from-name.h'
+fname = 'ip-protocol-from-name.h'
target1 = custom_target(
fname,
input : gperf_file,
output : fname,
command : [gperf,
'-L', 'ANSI-C', '-t', '--ignore-case',
- '-N', 'lookup_socket_protocol',
- '-H', 'hash_socket_protocol_name',
+ '-N', 'lookup_ip_protocol',
+ '-H', 'hash_ip_protocol_name',
'-p', '-C',
'@INPUT@'],
capture : true)
-fname = 'socket-protocol-to-name.h'
-awkscript = 'socket-protocol-to-name.awk'
+fname = 'ip-protocol-to-name.h'
+awkscript = 'ip-protocol-to-name.awk'
target2 = custom_target(
fname,
- input : [awkscript, socket_protocol_list_txt],
+ input : [awkscript, ip_protocol_list_txt],
output : fname,
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)
diff --git a/src/shared/socket-protocol-list.c b/src/shared/socket-protocol-list.c
deleted file mode 100644
index 0a8570b7be..0000000000
--- a/src/shared/socket-protocol-list.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-
-#include <errno.h>
-#include <netinet/in.h>
-#include <string.h>
-
-#include "socket-protocol-list.h"
-#include "macro.h"
-
-static const struct socket_protocol_name* lookup_socket_protocol(register const char *str, register GPERF_LEN_TYPE len);
-
-#include "socket-protocol-from-name.h"
-#include "socket-protocol-to-name.h"
-
-const char *socket_protocol_to_name(int id) {
-
- if (id < 0)
- return NULL;
-
- if (id >= (int) ELEMENTSOF(socket_protocol_names))
- return NULL;
-
- return socket_protocol_names[id];
-}
-
-int socket_protocol_from_name(const char *name) {
- const struct socket_protocol_name *sc;
-
- assert(name);
-
- sc = lookup_socket_protocol(name, strlen(name));
- if (!sc)
- return -EINVAL;
-
- return sc->id;
-}
diff --git a/src/shared/socket-protocol-list.h b/src/shared/socket-protocol-list.h
deleted file mode 100644
index 08b36e1767..0000000000
--- a/src/shared/socket-protocol-list.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-#pragma once
-
-const char *socket_protocol_to_name(int id);
-int socket_protocol_from_name(const char *name);