Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.


Code Block
languagecpp
themeConfluence
firstline1
titleIPv4 Address Configuration Example
linenumberstrue
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 */

...