Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a506939 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add tagSocket/untagSocket NDK APIs" am: 8fc5367b am: f3228818

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1940493

Change-Id: Id7812751888340962e9ab8c689da3dc80e9bef90
parents 55b2a873 f3228818
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -216,6 +216,61 @@ int android_res_nresult(int fd,
 */
void android_res_cancel(int nsend_fd) __INTRODUCED_IN(29);

/*
 * Set the socket tag and owning UID for traffic statistics on the specified
 * socket.
 *
 * Subsequent calls always replace any existing parameters. The socket tag and
 * uid (if set) are kept when the socket is sent to another process using binder
 * IPCs or other mechanisms such as UNIX socket fd passing. Any app can accept
 * blame for future traffic performed on a socket originally created by another
 * app by calling this method with its own UID (or calling
 * android_tag_socket(int sockfd, int tag)). However, only apps holding the
 * android.Manifest.permission#UPDATE_DEVICE_STATS permission may assign blame
 * to another UIDs. If unset (default) the socket tag is 0, and the uid is the
 * socket creator's uid.
 *
 * Returns 0 on success, or a negative POSIX error code (see errno.h) on
 * failure.
 *
 * Available since API level 33.
 */
int android_tag_socket_with_uid(int sockfd, int tag, uid_t uid) __INTRODUCED_IN(33);

/*
 * Set the socket tag for traffic statistics on the specified socket.
 *
 * This function tags the socket with the caller's UID (accepting blame for
 * future traffic performed on this socket) even if the socket was originally
 * opened by another UID or was previously tagged by another UID. Subsequent
 * calls always replace any existing parameters. The socket tag is kept when the
 * socket is sent to another process using binder IPCs or other mechanisms such
 * as UNIX socket fd passing.
 *
 * Returns 0 on success, or a negative POSIX error code (see errno.h) on
 * failure.
 *
 * Available since API level 33.
 */
int android_tag_socket(int sockfd, int tag) __INTRODUCED_IN(33);

/*
 * Untag a network socket.
 *
 * Future traffic on this socket will no longer be associated with any
 * previously configured tag and uid. If the socket was created by another UID
 * or was previously tagged by another UID, calling this function will clear the
 * statistics parameters, and thus the UID blamed for traffic on the socket will
 * be the UID that originally created the socket, even if the socket was
 * subsequently tagged by a different UID.
 *
 * Returns 0 on success, or a negative POSIX error code (see errno.h) on
 * failure.
 *
 * Available since API level 33.
 */
int android_untag_socket(int sockfd) __INTRODUCED_IN(33);

__END_DECLS

#endif  // ANDROID_MULTINETWORK_H