下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

最新资讯
简化任何设备的身份验证云连接。
利用 CoAP 设计节能型云连接 IoT 解决方案。
11.0.0 版 FreeRTOS 内核简介:
FreeRTOS 路线图和代码贡献流程。
使用 FreeRTOS 实现 OPC-UA over TSN。
注意:此 API 已从 FreeRTOS V4.0.0 起弃用 。请参阅 FreeRTOS_GetEndPointConfiguration() 了解支持 IPv6、多个端点和多个接口的新 API。如需使用已弃用的 API ,请将 FreeRTOSIPConfig.h 头文件中的 ipconfigIPv4_BACKWARD_COMPATIBLE 设置为 1。

FreeRTOS_GetAddressConfiguration()

[FreeRTOS-Plus-TCP API 引用]

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 位数字 。

用法示例:


/* FreeRTOS-Plus-TCP sockets include. */
#include "FreeRTOS_sockets.h"

void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
int8_t cBuffer[ 16 ];

if( eNetworkEvent == eNetworkUp )
{
/* The network is up and configured. Print out the configuration
obtained from the DHCP server. */

FreeRTOS_GetAddressConfiguration( &ulIPAddress,
&ulNetMask,
&ulGatewayAddress,
&ulDNSServerAddress );

/* Convert the IP address to a string then print it out. */
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
printf( "IP Address: %srn", cBuffer );

/* Convert the net mask to a string then print it out. */
FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
printf( "Subnet Mask: %srn", cBuffer );

/* Convert the IP address of the gateway to a string then print it out. */
FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
printf( "Gateway IP Address: %srn", cBuffer );

/* Convert the IP address of the DNS server to a string then print it out. */
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.