...
The first function aids the developer by converting a string format IPv4 address such as “192.168.1.2” to its hexadecimal equivalent. The second function is used to configure an interface with the specified IPv4, network mask and gateway addresses. An example is shown in listing Listing - IPv4 Address Configuration Example.
Anchor |
---|
| Listing - IPv4 Address Configuration Example |
---|
| Listing - IPv4 Address Configuration Example |
---|
|
Code Block |
---|
language | cpp |
---|
theme | Confluence |
---|
firstline | 1 |
---|
title | IPv4 Address Configuration Example |
---|
linenumbers | true |
---|
|
CPU_BOOLEAN cfg_success;
NET_IPv4_ADDR ipv4_addr;
NET_IPv4_ADDR ipv4_msk;
NET_IPv4_ADDR ipv4_gateway;
NET_ERR err;
(void)NetASCII_Str_to_IP((CPU_CHAR*)"192.168.1.2", &ipv4_addr, NET_IPv4_ADDR_SIZE, &err); /* See Note #1 */
(void)NetASCII_Str_to_IP((CPU_CHAR*)"255.255.255.0", &ipv4_msk, NET_IPv4_ADDR_SIZE, &err);
(void)NetASCII_Str_to_IP((CPU_CHAR*)"192.168.1.1", &ipv4_gateway, NET_IPv4_ADDR_SIZE, &err);
cfg_success = NetIPv4_CfgAddrAdd(if_nbr, /* See Note #2 */
ipv4_addr, /* See Note #3 */
ipv4_msk, /* See Note #4 */
ipv4_gateway, /* See Note #5 */
&err); /* See Note #6 */ |
...