The best time to attach a BPF filter to a socket is before a socket starts receiving data. Netlink sockets start receiving data after bind() has been called. uevent_open_socket() calls socket() and bind(). Hence split uevent_open_socket() into two functions: one function that calls socket() and another function that calls bind(). Bug: 203462310 Change-Id: Ia41dee4683358cf9fbb6288fad863cd4f4ac9924 Signed-off-by: Bart Van Assche <bvanassche@google.com>
38 lines
1.2 KiB
C
38 lines
1.2 KiB
C
/*
|
|
* Copyright (C) 2011 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef __CUTILS_UEVENT_H
|
|
#define __CUTILS_UEVENT_H
|
|
|
|
#include <stdbool.h>
|
|
#include <sys/socket.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
int uevent_create_socket(int buf_sz, bool passcred);
|
|
int uevent_bind(int socket);
|
|
int uevent_open_socket(int buf_sz, bool passcred);
|
|
ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length);
|
|
ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid);
|
|
ssize_t uevent_kernel_recv(int socket, void *buffer, size_t length, bool require_group, uid_t *uid);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __CUTILS_UEVENT_H */
|