chiark / gitweb /
core: add a concept of "dynamic" user ids, that are allocated as long as a service...
[elogind.git] / src / basic / socket-util.c
index f47a8f0..16646ff 100644 (file)
@@ -1052,3 +1052,17 @@ int flush_accept(int fd) {
         }
 }
 #endif // 0
+
+struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t length) {
+        struct cmsghdr *cmsg;
+
+        assert(mh);
+
+        CMSG_FOREACH(cmsg, mh)
+                if (cmsg->cmsg_level == level &&
+                    cmsg->cmsg_type == type &&
+                    (length == (socklen_t) -1 || length == cmsg->cmsg_len))
+                        return cmsg;
+
+        return NULL;
+}