summaryrefslogtreecommitdiff
path: root/src/basic/socket-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic/socket-util.c')
-rw-r--r--src/basic/socket-util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
index f47a8f04e..16646ff9d 100644
--- a/src/basic/socket-util.c
+++ b/src/basic/socket-util.c
@@ -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;
+}