File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,7 @@ module Network.Socket
229
229
,CmsgIdIPv6PktInfo )
230
230
-- ** APIs for control message
231
231
, lookupCmsg
232
+ , filterCmsg
232
233
, decodeCmsg
233
234
, encodeCmsg
234
235
-- ** Class and yypes for control message
Original file line number Diff line number Diff line change @@ -75,9 +75,13 @@ pattern CmsgIdFd = CmsgId (#const SOL_SOCKET) (#const SCM_RIGHTS)
75
75
-- > (lookupCmsg CmsgIdIPv4TOS cmsgs >>= decodeCmsg) :: Maybe IPv4TOS
76
76
lookupCmsg :: CmsgId -> [Cmsg ] -> Maybe Cmsg
77
77
lookupCmsg _ [] = Nothing
78
- lookupCmsg aid (cmsg@ (Cmsg cid _): cmsgs)
79
- | aid == cid = Just cmsg
80
- | otherwise = lookupCmsg aid cmsgs
78
+ lookupCmsg cid (cmsg: cmsgs)
79
+ | cmsgId cmsg == cid = Just cmsg
80
+ | otherwise = lookupCmsg cid cmsgs
81
+
82
+ -- | Filtering control message.
83
+ filterCmsg :: CmsgId -> [Cmsg ] -> [Cmsg ]
84
+ filterCmsg cid cmsgs = filter (\ cmsg -> cmsgId cmsg == cid) cmsgs
81
85
82
86
----------------------------------------------------------------
83
87
You can’t perform that action at this time.
0 commit comments