]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/socket-protocol-list.c
tree-wide: remove various unused functions
[thirdparty/systemd.git] / src / shared / socket-protocol-list.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include <errno.h>
4 #include <netinet/in.h>
5 #include <string.h>
6
7 #include "socket-protocol-list.h"
8 #include "macro.h"
9
10 static const struct socket_protocol_name* lookup_socket_protocol(register const char *str, register GPERF_LEN_TYPE len);
11
12 #include "socket-protocol-from-name.h"
13 #include "socket-protocol-to-name.h"
14
15 const char *socket_protocol_to_name(int id) {
16
17 if (id < 0)
18 return NULL;
19
20 if (id >= (int) ELEMENTSOF(socket_protocol_names))
21 return NULL;
22
23 return socket_protocol_names[id];
24 }
25
26 int socket_protocol_from_name(const char *name) {
27 const struct socket_protocol_name *sc;
28
29 assert(name);
30
31 sc = lookup_socket_protocol(name, strlen(name));
32 if (!sc)
33 return -EINVAL;
34
35 return sc->id;
36 }