dsmi_get_device_ip_address
Prototype
int dsmi_get_device_ip_address (int device_id, int port_type, int port_id, ip_addr_t *ip_address, ip_addr_t *mask_address)
Description
Obtains the IP address and mask address.
For the Ascend 310 AI Processor, this API supports only standard PCIe cards.
Parameters
Parameter |
Input/Output |
Description |
---|---|---|
device_id |
Input |
Device ID For the Ascend 310 AI Processor, the value range is 0–63. Obtain the actual device ID by calling dsmi_list_device. |
port_type |
Input |
Port type For the Ascend 310 AI Processor, only 0x00 (vNIC) is supported. The following macro can be passed to the API call: DSMI_VNIC_PORT (0) |
port_id |
Input |
Port ID (reserved). Set it to 0. |
ip_address |
Input/Output |
#define DSMI_ARRAY_IPV4_NUM 4 #define DSMI_ARRAY_IPV6_NUM 16 typedef struct ip_addr { union { unsigned char ip6[DSMI_ARRAY_IPV6_NUM]; unsigned char ip4[DSMI_ARRAY_IPV4_NUM]; } u_addr; enum ip_addr_type ip_type; //An input } ip_addr_t; For Ascend 310 AI Processors, the ip_addr_type struct is defined as follows. enum ip_addr_type { IPADDR_TYPE_V4 = 0U, /**< IPv4 */ IPADDR_TYPE_V6 = 6U, /**< IPv6 */ IPADDR_TYPE_ANY = 46U /**< IPv4+IPv6 ("dual-stack") */ }; |
mask_address |
Input/Output |
#define DSMI_ARRAY_IPV4_NUM 4 #define DSMI_ARRAY_IPV6_NUM 16 typedef struct ip_addr { union { unsigned char ip6[DSMI_ARRAY_IPV6_NUM]; unsigned char ip4[DSMI_ARRAY_IPV4_NUM]; } u_addr; enum ip_addr_type ip_type; //An input } ip_addr_t; For Ascend 310 AI Processors, the ip_addr_type struct is defined as follows. enum ip_addr_type { IPADDR_TYPE_V4 = 0U, /**< IPv4 */ IPADDR_TYPE_V6 = 6U, /**< IPv6 */ IPADDR_TYPE_ANY = 46U /**< IPv4+IPv6 ("dual-stack") */ }; |
Returns
Type |
Description |
---|---|
int |
0 on success; else, failure |
Restrictions
None
Example
int ret = 0; int device_id = 0; int port_type = 0; int port_id = 0; ip_addr_t ip_address = {0}; ip_addr_t ip_mask_address={0}; ret = dsmi_get_device_ip_address(device_id, port_type, port_id, &ip_address, &mask_address); if(ret != 0) { //To-do: records logs. return ret;