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 IPv6 address such as “fe80::1111:1111” to its network equivalent. The second function is used to configure an interface with the specified IPv6 address. An example is shown in listing Listing - IPv6 Address Configuration Example.

Anchor
Listing - IPv6 Address Configuration Example
Listing - IPv6 Address Configuration Example

Code Block
languagecpp
themeConfluence
firstline1
titleIPv6 Address Configuration Example
linenumberstrue
CPU_BOOLEAN    cfg_success;
NET_IPv6_ADDR  ipv6_addr;
NET_FLAGS      ipv6_flags;
NET_ERR        err;
           
           
(void)NetASCII_Str_to_IP((CPU_CHAR *)"fe80::1111:1111", 	/* See Note #1 */
                                     &ipv6_addr, 
                                      NET_IPv6_ADDR_SIZE, 
                                     &err);
 
ipv6_flags = 0;                                             
DEF_BIT_SET(ipv6_flags, NET_IPv6_FLAG_BLOCK_EN);            /* See Note #2 */
DEF_BIT_SET(ipv6_flags, NET_IPv6_FLAG_DAD_EN);              /* See Note #3 */
 
cfg_success = NetIPv6_CfgAddrAdd(if_nbr,         			/* See Note #4 */
                                &ipv6_addr,      			/* See Note #5 */
                                 64,             			/* See Note #6 */
                                 ipv6_flags,                /* See Note #7 */  
                                &err);           			/* See Note #8 */


Panel
bgColor#f0f0f0
  1. See NetASCII_Str_to_IP for more details.
  2. Set Address Configuration as blocking.

  3. Enable DAD with Address Configuration.

  4. The first argument is the number representing the network interface that is to be configured. This value is obtained as the result of a successful call to NetIF_Add().
  5. The second argument is the pointer to the NET_IPv6_ADDR value representing the IPv6 address to be configured.
  6. The third argument is the IPv6 prefix length of the address to be configured.
  7. The fourth argument is a set of network flags holding options specific to the address configuration process.
  8. The fifth argument is a pointer to a NET_ERR variable containing the return error code for the function. If the interface address information is configured successfully, then the return error code will contain the value NET_IPv6_ERR_NONE. Additionally, function returns a Boolean value of DEF_OK or DEF_FAIL depending on the result. Either the return value or the NET_ERR variable may be checked for return status; however, the NET_ERR contains more detailed information and should therefore be the preferred check.


As shown in  Listing - IPv6 Address Configuration Example, the NetIPv6_CfgAddrAdd() function can take as argument a set of network flags. The following options are available :

...

If the function is made none blocking, it is possible to set a hook function to advertise the application when the address configuration process has finished. The API function NetIPv6_CfgAddrHookSet can be used to set the hook function. Refer to section IPv6 Static Address Configuration Hook Function for all the details on the hook function format and usage. Listing - Non-Blocking IPv6 Address Configuration Example shows an example of a non-blocking IPv6 static address configuration.

Anchor
Listing - Non-Blocking IPv6 Address Configuration Example
Listing - Non-Blocking IPv6 Address Configuration Example

Code Block
languagecpp
themeConfluence
firstline1
titleListing - Non-Blocking IPv6 Address Configuration Example
linenumberstrue
CPU_BOOLEAN    cfg_success;
NET_IPv6_ADDR  ipv6_addr;
NET_FLAGS      ipv6_flags;
NET_ERR        err;
           
           
(void)NetASCII_Str_to_IP((CPU_CHAR *)"fe80::1111:1111", 	/* Convert IPv6 string address to 128 bit address.      */
                                     &ipv6_addr, 
                                      NET_IPv6_ADDR_SIZE, 
                                     &err);

NetIPv6_AddrAutoCfgHookSet(if_nbr,                          /* Set hook function to received addr cfg result.       */
                          &App_AddrCfgResult,				/* TODO update pointer to hook fnct implemented in App. */
                          &err);  
 
ipv6_flags = 0;                                             
DEF_BIT_CLR(ipv6_flags, NET_IPv6_FLAG_BLOCK_EN);            /* Set Address Configuration as non-blocking.           */
DEF_BIT_SET(ipv6_flags, NET_IPv6_FLAG_DAD_EN);              /* Enable DAD with Address Configuration.               */
 
cfg_success = NetIPv6_CfgAddrAdd(if_nbr,         			/* Add a statically-configured IPv6 host address to ... */
                                &ipv6_addr,      			/* ... the interface.                                   */
                                 64,             			
                                 ipv6_flags,               
                                &err);      


Stateless Address Auto-Configuration

...