Factor out msghdr processing into paired helpers.