dsmi_get_gateway_addr
Prototype
int dsmi_get_gateway_addr (int device_id, int port_type, int port_id, ip_addr_t *gtw_address)
Description
Obtains the gateway 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. |
gtw_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 value } ip_addr_t; In Ascend 310 AI Processor scenarios, 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
Only IPv4 addresses are supported.
Example
int ret = 0; int device_id = 0; int port_type = 0; int port_id = 0; ip_addr_t gateway_address={0}; ret = dsmi_get_gateway_addr(device_id, port_type, port_id, &gateway_address); if(ret != 0) { //To-do: Records logs. return ret; } ...