/*
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
* 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.
*/
/**
* @addtogroup SoftBus
* @{
*
* @brief Provides secure, high-speed communications between devices.
*
* This module implements unified distributed communication management of nearby devices and provides link-independent
* device discovery and transmission interfaces to support service publishing and data transmission.
* @since 1.0
* @version 1.0
*/
/**
* @file inner_socket.h
*
* @brief Declare the function for getting the maximum transmission unit.
*
* @since 1.0
* @version 1.0
*/
#ifndef INNER_SOCKET_H
#define INNER_SOCKET_H
#include "socket.h"
#include "softbus_common.h"
#include "trans_type.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Get maximum transmission unit of socket
*
* @param socket Indicates the unique socket fd.
* @param size Indicates the maximum transmission unit.
*
* @return Returns SOFTBUS_INVALID_PARAM if invalid parameters are detected.
* @return Returns SOFTBUS_OK if the operation is successful; returns an error code otherwise.
*
* @since 1.0
* @version 1.0
*/
int32_t GetMtuSize(int32_t socket, uint32_t *mtuSize);
/**
* @brief Grant permission to socket with uid and pid.
*
* @param uid Indicates the uid of the process.
* @param pid Indicates the pid of the process.
* @param socketName Indicates the name of the socket to grant permission.
*
* @return Returns SOFTBUS_INVALID_PARAM if invalid parameters are detected.
* @return Returns SOFTBUS_OK if the operation is successful; returns an error code otherwise.
*
* @since 1.0
* @version 1.0
*/
int32_t DBinderGrantPermission(int32_t uid, int32_t pid, const char *socketName);
/**
* @brief Removes permissions for a specific socket
*
* @param socketName Indicates the name of the socket to remove permission.
*
* @return Returns SOFTBUS_INVALID_PARAM if invalid parameters are detected.
* @return Returns SOFTBUS_OK if the operation is successful; returns an error code otherwise.
*
* @since 1.0
* @version 1.0
*/
int32_t DBinderRemovePermission(const char *socketName);
/**
* @brief Bind for dfs.
*
* @param socket Indicates the the unique socket fd.
* @param listener Indicates the pointer to the socket callback.
* @return Returns SOFTBUS_TRANS_INVALID_PARAM if invalid parameters are detected.
* @return Returns INVALID_SOCKET if the operation fails.
* @return Returns SOFTBUS_OK if the socket is bind;
* returns an error code otherwise.
* @since 1.0
* @version 1.0
*/
int32_t DfsBind(int32_t socket, const ISocketListener *listener);
/**
* @brief Set socket option.
*
* @param socket Indicates the unique socket fd.
* @param level Indicates the level of option.
* @param optType Indicates the type of option.
* @param optValue Indicates the pointer to the option value to set, which cannot be NULL.
* @param optValueSize Indicates the length of the option value to set.
*
* @return Returns SOFTBUS_INVALID_PARAM if optValue is NULL or optValueSize is zero.
* @return Returns SOFTBUS_OK if the operation is successful; returns an error code otherwise.
* @since 2.0
* @version 2.0
*/
int32_t SetSocketOpt(int32_t socket, OptLevel level, OptType optType, void *optValue, int32_t optValueSize);
/**
* @brief Get socket option.
*
* @param socket Indicates the unique socket fd.
* @param level Indicates the level of option.
* @param optType Indicates the type of option.
* @param optValue Indicates the pointer to the option value to get, which cannot be NULL.
* @param optValueSize Indicates the pointer to the optValue size to get, which cannot be NULL.
*
* @return Returns SOFTBUS_INVALID_PARAM if optValue is NULL or optValueSize is NULL.
* @return Returns SOFTBUS_OK if the operation is successful; returns an error code otherwise.
* @since 2.0
* @version 2.0
*/
int32_t GetSocketOpt(int32_t socket, OptLevel level, OptType optType, void *optValue, int32_t *optValueSize);
#ifdef __cplusplus
}
#endif
#endif // INNER_SOCKET_H