注意:此 API 已从 FreeRTOS V4.0.0 起弃用
。请参阅
FreeRTOS_GetEndPointConfiguration()
了解支持 IPv6、多个端点和多个接口的新 API。如需使用已弃用的 API ,请将
FreeRTOSIPConfig.h 头文件中的 ipconfigIPv4_BACKWARD_COMPATIBLE 设置为 1。
FreeRTOS_sockets.h
void FreeRTOS_GetAddressConfiguration( uint32_t *pulIPAddress,
uint32_t *pulNetMask,
uint32_t *pulGatewayAddress,
uint32_t *pulDNSServerAddress );
从 TCP/IP 堆栈中获取端点列表中第一个可用 IPv4 端点的网络地址配置。
参数:
pulIPAddress
|
用于返回 IP 堆栈正在使用的
IP 地址。
IP 地址以网络字节顺序表示为 32 位数字
。
|
pulNetMask
|
用于返回 IP 堆栈正在使用的
网络掩码。
网络掩码以网络字节顺序表示为 32 位数字
。
|
pulGatewayAddress
|
用于返回 IP 堆栈正在使用的
网关的 IP 地址。
IP 地址以网络字节顺序表示为 32 位数字
。
|
pulDNSServerAddress
|
用于返回 IP 堆栈正在使用的 DNS 服务器
的 IP 地址。
IP 地址以网络字节顺序表示为 32 位数字
。
|
用法示例:
#include "FreeRTOS_sockets.h"
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
int8_t cBuffer[ 16 ];
if( eNetworkEvent == eNetworkUp )
{
FreeRTOS_GetAddressConfiguration( &ulIPAddress,
&ulNetMask,
&ulGatewayAddress,
&ulDNSServerAddress );
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
printf( "IP Address: %srn", cBuffer );
FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
printf( "Subnet Mask: %srn", cBuffer );
FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
printf( "Gateway IP Address: %srn", cBuffer );
FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
printf( "DNS server IP Address: %srn", cBuffer );
}
}
Example use of the FreeRTOS_GetAddressConfiguration() API function
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.