chiark / gitweb /
Prep v233.2: Mask unneeded functions and definitions in src/basic
[elogind.git] / src / basic / socket-util.c
index 86177610d8db0d8de5ff361b75c3d02d89e6ec3f..d392da2a48ab69217d7b67b8e963d7c5b02c8835 100644 (file)
@@ -480,7 +480,6 @@ const char* socket_address_get_path(const SocketAddress *a) {
 
         return a->sockaddr.un.sun_path;
 }
-#endif // 0
 
 bool socket_ipv6_is_supported(void) {
         if (access("/proc/net/if_inet6", F_OK) != 0)
@@ -489,7 +488,6 @@ bool socket_ipv6_is_supported(void) {
         return true;
 }
 
-#if 0 /// UNNEEDED by elogind
 bool socket_address_matches_fd(const SocketAddress *a, int fd) {
         SocketAddress b;
         socklen_t solen;
@@ -866,7 +864,6 @@ static const char* const ip_tos_table[] = {
 };
 
 DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ip_tos, int, 0xff);
-#endif // 0
 
 bool ifname_valid(const char *p) {
         bool numeric = true;
@@ -881,7 +878,7 @@ bool ifname_valid(const char *p) {
         if (strlen(p) >= IFNAMSIZ)
                 return false;
 
-        if (STR_IN_SET(p, ".", ".."))
+        if (dot_or_dot_dot(p))
                 return false;
 
         while (*p) {
@@ -891,7 +888,7 @@ bool ifname_valid(const char *p) {
                 if ((unsigned char) *p <= 32U)
                         return false;
 
-                if (*p == '/')
+                if (*p == ':' || *p == '/')
                         return false;
 
                 numeric = numeric && (*p >= '0' && *p <= '9');
@@ -904,6 +901,27 @@ bool ifname_valid(const char *p) {
         return true;
 }
 
+bool address_label_valid(const char *p) {
+
+        if (isempty(p))
+                return false;
+
+        if (strlen(p) >= IFNAMSIZ)
+                return false;
+
+        while (*p) {
+                if ((uint8_t) *p >= 127U)
+                        return false;
+
+                if ((uint8_t) *p <= 31U)
+                        return false;
+                p++;
+        }
+
+        return true;
+}
+#endif // 0
+
 int getpeercred(int fd, struct ucred *ucred) {
         socklen_t n = sizeof(struct ucred);
         struct ucred u;
@@ -1120,7 +1138,6 @@ int flush_accept(int fd) {
                 close(cfd);
         }
 }
-#endif // 0
 
 struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t length) {
         struct cmsghdr *cmsg;
@@ -1136,7 +1153,6 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng
         return NULL;
 }
 
-#if 0 /// UNNEEDED by elogind
 int socket_ioctl_fd(void) {
         int fd;