1060ff233Sopenharmony_ci/*
2060ff233Sopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3060ff233Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4060ff233Sopenharmony_ci * you may not use this file except in compliance with the License.
5060ff233Sopenharmony_ci * You may obtain a copy of the License at
6060ff233Sopenharmony_ci *
7060ff233Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8060ff233Sopenharmony_ci *
9060ff233Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10060ff233Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11060ff233Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12060ff233Sopenharmony_ci * See the License for the specific language governing permissions and
13060ff233Sopenharmony_ci * limitations under the License.
14060ff233Sopenharmony_ci */
15060ff233Sopenharmony_ci
16060ff233Sopenharmony_ci/**
17060ff233Sopenharmony_ci * @addtogroup SoftBus
18060ff233Sopenharmony_ci * @{
19060ff233Sopenharmony_ci *
20060ff233Sopenharmony_ci * @brief Provides secure, high-speed communications between devices.
21060ff233Sopenharmony_ci *
22060ff233Sopenharmony_ci * This module implements unified distributed communication management of nearby devices and provides link-independent
23060ff233Sopenharmony_ci * device discovery and transmission interfaces to support service publishing and data transmission.
24060ff233Sopenharmony_ci * @since 1.0
25060ff233Sopenharmony_ci * @version 1.0
26060ff233Sopenharmony_ci */
27060ff233Sopenharmony_ci
28060ff233Sopenharmony_ci/**
29060ff233Sopenharmony_ci * @file inner_socket.h
30060ff233Sopenharmony_ci *
31060ff233Sopenharmony_ci * @brief Declare the function for getting the maximum transmission unit.
32060ff233Sopenharmony_ci *
33060ff233Sopenharmony_ci * @since 1.0
34060ff233Sopenharmony_ci * @version 1.0
35060ff233Sopenharmony_ci */
36060ff233Sopenharmony_ci#ifndef INNER_SOCKET_H
37060ff233Sopenharmony_ci#define INNER_SOCKET_H
38060ff233Sopenharmony_ci
39060ff233Sopenharmony_ci#include "socket.h"
40060ff233Sopenharmony_ci#include "softbus_common.h"
41060ff233Sopenharmony_ci#include "trans_type.h"
42060ff233Sopenharmony_ci
43060ff233Sopenharmony_ci#ifdef __cplusplus
44060ff233Sopenharmony_ciextern "C" {
45060ff233Sopenharmony_ci#endif
46060ff233Sopenharmony_ci/**
47060ff233Sopenharmony_ci * @brief Get maximum transmission unit of socket
48060ff233Sopenharmony_ci *
49060ff233Sopenharmony_ci * @param socket Indicates the unique socket fd.
50060ff233Sopenharmony_ci * @param size Indicates the maximum transmission unit.
51060ff233Sopenharmony_ci *
52060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
53060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
54060ff233Sopenharmony_ci *
55060ff233Sopenharmony_ci * @since 1.0
56060ff233Sopenharmony_ci * @version 1.0
57060ff233Sopenharmony_ci */
58060ff233Sopenharmony_ciint32_t GetMtuSize(int32_t socket, uint32_t *mtuSize);
59060ff233Sopenharmony_ci
60060ff233Sopenharmony_ci/**
61060ff233Sopenharmony_ci * @brief Grant permission to socket with uid and pid.
62060ff233Sopenharmony_ci *
63060ff233Sopenharmony_ci * @param uid Indicates the uid of the process.
64060ff233Sopenharmony_ci * @param pid Indicates the pid of the process.
65060ff233Sopenharmony_ci * @param socketName Indicates the name of the socket to grant permission.
66060ff233Sopenharmony_ci *
67060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
68060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
69060ff233Sopenharmony_ci *
70060ff233Sopenharmony_ci * @since 1.0
71060ff233Sopenharmony_ci * @version 1.0
72060ff233Sopenharmony_ci */
73060ff233Sopenharmony_ciint32_t DBinderGrantPermission(int32_t uid, int32_t pid, const char *socketName);
74060ff233Sopenharmony_ci
75060ff233Sopenharmony_ci/**
76060ff233Sopenharmony_ci * @brief Removes permissions for a specific socket
77060ff233Sopenharmony_ci *
78060ff233Sopenharmony_ci * @param socketName Indicates the name of the socket to remove permission.
79060ff233Sopenharmony_ci *
80060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected.
81060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
82060ff233Sopenharmony_ci *
83060ff233Sopenharmony_ci * @since 1.0
84060ff233Sopenharmony_ci * @version 1.0
85060ff233Sopenharmony_ci */
86060ff233Sopenharmony_ciint32_t DBinderRemovePermission(const char *socketName);
87060ff233Sopenharmony_ci
88060ff233Sopenharmony_ci/**
89060ff233Sopenharmony_ci * @brief Bind for dfs.
90060ff233Sopenharmony_ci *
91060ff233Sopenharmony_ci * @param socket Indicates the the unique socket fd.
92060ff233Sopenharmony_ci * @param listener Indicates the pointer to the socket callback.
93060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_INVALID_PARAM</b> if invalid parameters are detected.
94060ff233Sopenharmony_ci * @return Returns <b>INVALID_SOCKET</b> if the operation fails.
95060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the socket is bind;
96060ff233Sopenharmony_ci * returns an error code otherwise.
97060ff233Sopenharmony_ci * @since 1.0
98060ff233Sopenharmony_ci * @version 1.0
99060ff233Sopenharmony_ci */
100060ff233Sopenharmony_ciint32_t DfsBind(int32_t socket, const ISocketListener *listener);
101060ff233Sopenharmony_ci
102060ff233Sopenharmony_ci/**
103060ff233Sopenharmony_ci * @brief Set socket option.
104060ff233Sopenharmony_ci *
105060ff233Sopenharmony_ci * @param socket Indicates the unique socket fd.
106060ff233Sopenharmony_ci * @param level Indicates the level of option.
107060ff233Sopenharmony_ci * @param optType Indicates the type of option.
108060ff233Sopenharmony_ci * @param optValue Indicates the pointer to the option value to set, which cannot be <b>NULL</b>.
109060ff233Sopenharmony_ci * @param optValueSize Indicates the length of the option value to set.
110060ff233Sopenharmony_ci *
111060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>optValue</b> is <b>NULL</b> or <b>optValueSize</b> is zero.
112060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
113060ff233Sopenharmony_ci * @since 2.0
114060ff233Sopenharmony_ci * @version 2.0
115060ff233Sopenharmony_ci */
116060ff233Sopenharmony_ciint32_t SetSocketOpt(int32_t socket, OptLevel level, OptType optType, void *optValue, int32_t optValueSize);
117060ff233Sopenharmony_ci
118060ff233Sopenharmony_ci/**
119060ff233Sopenharmony_ci * @brief Get socket option.
120060ff233Sopenharmony_ci *
121060ff233Sopenharmony_ci * @param socket Indicates the unique socket fd.
122060ff233Sopenharmony_ci * @param level Indicates the level of option.
123060ff233Sopenharmony_ci * @param optType Indicates the type of option.
124060ff233Sopenharmony_ci * @param optValue Indicates the pointer to the option value to get, which cannot be <b>NULL</b>.
125060ff233Sopenharmony_ci * @param optValueSize Indicates the pointer to the optValue size to get, which cannot be <b>NULL</b>.
126060ff233Sopenharmony_ci *
127060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>optValue</b> is <b>NULL</b> or <b>optValueSize</b> is <b>NULL</b>.
128060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise.
129060ff233Sopenharmony_ci * @since 2.0
130060ff233Sopenharmony_ci * @version 2.0
131060ff233Sopenharmony_ci */
132060ff233Sopenharmony_ciint32_t GetSocketOpt(int32_t socket, OptLevel level, OptType optType, void *optValue, int32_t *optValueSize);
133060ff233Sopenharmony_ci#ifdef __cplusplus
134060ff233Sopenharmony_ci}
135060ff233Sopenharmony_ci#endif
136060ff233Sopenharmony_ci#endif // INNER_SOCKET_H