1 /*
2 * junixsocket
3 *
4 * Copyright 2009-2024 Christian Kohlschütter
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.newsclub.net.unix;
19
20 import java.io.FileDescriptor;
21 import java.io.IOException;
22 import java.util.Objects;
23
24 /**
25 * AF_SYSTEM-specific code that resides in the native library. To be used by {@code AFSystemSocket}
26 * and {@code AFSystemDatagramSocket} only.
27 *
28 * @author Christian Kohlschütter
29 */
30 public final class AFSYSTEMSocketImplExtensions implements
31 AFSocketImplExtensions<AFSYSTEMSocketAddress> {
32
33 @SuppressWarnings("PMD.UnusedFormalParameter")
34 AFSYSTEMSocketImplExtensions(AncillaryDataSupport ancillaryDataSupport) {
35 }
36
37 /**
38 * Retrieves the kernel control ID given a kernel control name.
39 *
40 * @param fd The socket file descriptor.
41 * @param name The control name
42 * @return The control Id.
43 * @throws IOException on error.
44 */
45 public int getKernelControlId(FileDescriptor fd, String name) throws IOException {
46 return NativeUnixSocket.systemResolveCtlId(fd, Objects.requireNonNull(name));
47 }
48 }