mirror of
https://github.com/openharmony/communication_t2stack.git
synced 2026-07-21 16:55:24 -04:00
4cf8174d8c
Signed-off-by: yanming <1969986071@qq.com>
51 lines
1.7 KiB
C
51 lines
1.7 KiB
C
/*
|
|
* Copyright (C) 2021 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.
|
|
*/
|
|
|
|
#include "nstackx_dev.h"
|
|
#include "nstackx_error.h"
|
|
#include "nstackx_log.h"
|
|
#include "securec.h"
|
|
|
|
#define TAG "nStackXDev"
|
|
|
|
int32_t GetConnectionTypeByDev(const uint32_t sourceIp, uint16_t *connectType);
|
|
|
|
static int32_t GetConnectionTypeByIP(const uint32_t sourceIp, const uint32_t destinationIp, uint16_t *connectType)
|
|
{
|
|
if (sourceIp == htonl(SOFTAP_ADDR_KEY) || destinationIp == htonl(SOFTAP_ADDR_KEY) ||
|
|
sourceIp == htonl(P2P_ADDR_KEY) || destinationIp == htonl(P2P_ADDR_KEY)) {
|
|
*connectType = CONNECT_TYPE_P2P;
|
|
LOGI(TAG, "connType is P2P(%u)", *connectType);
|
|
return NSTACKX_EOK;
|
|
}
|
|
return NSTACKX_EFAILED;
|
|
}
|
|
|
|
int32_t GetConnectionType(const uint32_t sourceIp, const uint32_t destinationIp, uint16_t *connectType)
|
|
{
|
|
if (GetConnectionTypeByIP(sourceIp, destinationIp, connectType) == NSTACKX_EOK) {
|
|
return NSTACKX_EOK;
|
|
}
|
|
return GetConnectionTypeByDev(sourceIp, connectType);
|
|
}
|
|
|
|
uint8_t DFileGetDeviceBits(void)
|
|
{
|
|
if (TYPE_BITS_NUM(char *) == DEVICE_32_BITS) {
|
|
return DEVICE_32_BITS;
|
|
}
|
|
|
|
return DEVICE_64_BITS;
|
|
} |