| Connectivity Middleware Utilities Library

Functions
Network helper functions
Common middleware utilities » Network helper utilities

## General Description

This is a collection of network helper functions which would be used by various Cypress Middleware libraries.

## Functions
void | cy_nw_ip_initialize_status_change_callback (cy_nw_ip_status_change_callback_t *info, cy_nw_ip_status_change_callback_func_t *cbf, void *arg)
| Initialize status change callback. More...
bool | cy_nw_ip_get_ipv4_address (cy_nw_ip_interface_t iface, cy_nw_ip_address_t *addr)
| Retrieves the IPv4 address for an interface. More...
int | cy_nw_str_to_ipv4 (const char *ip_str, cy_nw_ip_address_t *address)
| Convert IPv4 string to an IP address structure. More...
void | cy_nw_ip_register_status_change_callback (cy_nw_ip_interface_t iface, cy_nw_ip_status_change_callback_t *info)
| Registers for callback function to be invoked during IP status change. More...
void | cy_nw_ip_unregister_status_change_callback (cy_nw_ip_interface_t iface, cy_nw_ip_status_change_callback_t *info)
| Un-registers IP status change callback. More...
int | cy_nw_host_arp_cache_clear (cy_nw_ip_interface_t iface)
| Clears the ARP cache for the interface NOTE: in LwIP, we need the netif (NetworkInterface) to do things, we can find using wifi interface. More...
int | cy_nw_host_arp_cache_get_list (cy_nw_ip_interface_t iface, cy_nw_arp_cache_entry_t *list, uint32_t count, uint32_t *filled)
| Gets the ARP cache list for the interface. More...
int | cy_nw_host_send_arp_request (cy_nw_ip_interface_t iface, const char *ip_string)
| Send ARP request NOTE: in LwIP, we need the netif (NetworkInterface) to do things, we can find using wifi interface. More...
uint32_t | cy_nw_get_time (void)
| GET time in milliseconds. More...
bool | cy_nw_aton (const char *char_ptr, cy_nw_ip_address_t *addr)
| GET IPv4 address in decimal notation. More...
bool | cy_nw_aton_ipv6 (const char *char_ptr, cy_nw_ip_address_t *addr)
| GET IPv6 address in decimal notation. More...
bool | cy_nw_ntoa (cy_nw_ip_address_t *addr, char *ip_str)
| GET IPv4 address in string format. More...
bool | cy_nw_ntoa_ipv6 (cy_nw_ip_address_t *addr, char *ip_str)
| GET IPv6 address in string format. More...

## Function Documentation

## ◆ cy_nw_ip_initialize_status_change_callback()

void cy_nw_ip_initialize_status_change_callback | ( | cy_nw_ip_status_change_callback_t * | info,
|  | cy_nw_ip_status_change_callback_func_t * | cbf,
|  | void * | arg
| ) |  |

Initialize status change callback.

Initialize cy_nw_ip_status_change_callback_t instead of directly manipulating the callback struct.

Parameters

  [in,out] | info | : Pointer to network IP status change callback information structure which would be filled upon return
  [in] | cbf | : Pointer to callback function to be invoked during network status change
  [in] | arg | : User data object to be sent sent in the callback function

Returns
  none

## ◆ cy_nw_ip_get_ipv4_address()

bool cy_nw_ip_get_ipv4_address | ( | cy_nw_ip_interface_t | iface,
|  | cy_nw_ip_address_t * | addr
| ) |  |

Retrieves the IPv4 address for an interface.

Retrieves the IPv4 address for an interface (AP or STA) if it exists.

Parameters

  [in] | iface | : Pointer to network interface object
  [out] | addr | : Pointer to the IP information sturcture in which the results to be stored

Returns
  true : if IP address is present
  false : otherwise

## ◆ cy_nw_str_to_ipv4()

int cy_nw_str_to_ipv4 | ( | const char * | ip_str,
|  | cy_nw_ip_address_t * | address
| ) |  |

Convert IPv4 string to an IP address structure.

Parameters

  [in] | ip_str | : IPv4 address string.
  [out] | address | : Pointer to the IP info structure in which the IPv4 address to be stored

Returns
  0 : if successful
  -1 : if failed

## ◆ cy_nw_ip_register_status_change_callback()

void cy_nw_ip_register_status_change_callback | ( | cy_nw_ip_interface_t | iface,
|  | cy_nw_ip_status_change_callback_t * | info
| ) |  |

Registers for callback function to be invoked during IP status change.

Parameters

  [in] | iface | : Pointer to network interface object
  [in] | info | : Pointer to the status change information structure

Returns
  none

## ◆ cy_nw_ip_unregister_status_change_callback()

void cy_nw_ip_unregister_status_change_callback | ( | cy_nw_ip_interface_t | iface,
|  | cy_nw_ip_status_change_callback_t * | info
| ) |  |

Un-registers IP status change callback.

Parameters

  [in] | iface | : Pointer to network interface object
  [in] | info | : Pointer to the status change information structure

Returns
  none

## ◆ cy_nw_host_arp_cache_clear()

int cy_nw_host_arp_cache_clear | ( | cy_nw_ip_interface_t | iface | ) |

Clears the ARP cache for the interface NOTE: in LwIP, we need the netif (NetworkInterface) to do things, we can find using wifi interface.

Parameters

  [in] | iface | : Pointer to network interface object

Returns
  0 : success 1 : fail

## ◆ cy_nw_host_arp_cache_get_list()

int cy_nw_host_arp_cache_get_list | ( | cy_nw_ip_interface_t | iface,
|  | cy_nw_arp_cache_entry_t * | list,
|  | uint32_t | count,
|  | uint32_t * | filled
| ) |  |

Gets the ARP cache list for the interface.

Parameters

  [in] | iface | : Pointer to network interface object
  [in,out] | list | : Pointer to cy_nw_arp_cache_entry_t array
  [in] | count | : Number of entries in the array passed in `list`
  [in,out] | filled | : Pointer to get the number of entries filled in the array pointed by 'list'

Returns
  0 : success 1 : fail

## ◆ cy_nw_host_send_arp_request()

int cy_nw_host_send_arp_request | ( | cy_nw_ip_interface_t | iface,
|  | const char * | ip_string
| ) |  |

Send ARP request NOTE: in LwIP, we need the netif (NetworkInterface) to do things, we can find using wifi interface.

Parameters

  [in] | iface | : Pointer to network interface object
  [in] | ip_string | : Pointer to the IPv4 address string (Ex: "192.168.1.1") to which the ARP request to be sent

Returns
  0 : success 1 : failed to send ARP request

## ◆ cy_nw_get_time()

uint32_t cy_nw_get_time | ( | void |  | ) |

GET time in milliseconds.

Returns
  time in milliseconds

## ◆ cy_nw_aton()

bool cy_nw_aton | ( | const char * | char_ptr,
|  | cy_nw_ip_address_t * | addr
| ) |  |

GET IPv4 address in decimal notation.

NOTE: dotted-decimal notation example (192.168.0.1)

Parameters

  [in] | char_ptr | : Pointer to the string containing the IPv4 address in dotted-decimal format.
  [out] | addr | : Pointer to the structure containing IPv4 address in decimal format.

Returns
  0 : success 1 : failed

## ◆ cy_nw_aton_ipv6()

bool cy_nw_aton_ipv6 | ( | const char * | char_ptr,
|  | cy_nw_ip_address_t * | addr
| ) |  |

GET IPv6 address in decimal notation.

NOTE: This API does not support shorthand representation of IPv6 address. Input string should be of the format X:X:X:X:X:X:X:X.

Parameters

  [in] | char_ptr | : Pointer to the string containing the IPv6 address.
  [out] | addr | : Pointer to the structure containing IPv6 address in decimal format.

Returns
  0 : success 1 : failed

## ◆ cy_nw_ntoa()

bool cy_nw_ntoa | ( | cy_nw_ip_address_t * | addr,
|  | char * | ip_str
| ) |  |

GET IPv4 address in string format.

Parameters

  [in] | addr | : Pointer to IPv4 address structure containing the IPv4 address.
  [out] | ip_str | : Pointer to the string containing IPv4 address in dotted-decimal notation. ip_str must be 16 bytes long.

Returns
  0 : success 1 : failed

## ◆ cy_nw_ntoa_ipv6()

bool cy_nw_ntoa_ipv6 | ( | cy_nw_ip_address_t * | addr,
|  | char * | ip_str
| ) |  |

GET IPv6 address in string format.

Parameters

  [in] | addr | : Pointer to IPv6 address structure containing the IPv6 address.
  [out] | ip_str | : Pointer to the string containing IPv6 address. ip_str must 39 bytes long.

Returns
  0 : success 1 : failed