net_info_t 数据类型

net_info_t 变量是一个结构或组合变量,用于保存通过 sockfd_netinfo Vue 函数从特定套接字描述符获取的网络四元组(本地和远程 IP 地址及本地和远程端口号)信息。

可以像 Vue 脚本中的任何其他用户定义的结构一样访问 net_info_t 结构的成员。 net_info_t 类型是一种抽象数据类型,此变量不能直接与标准 C 一元运算符或二目运算符配合使用。 此变量是一种包含四元组信息的结构。 可以使用 "." 来访问此变量元素。 运算符,例如 C 结构元素。

net_info_t 数据类型的元素如下所示:
net_info_t 
{ 
    int local_port; 
    int remote_port; 
    ip_addr_t local_addr; 
    ip_addr_t remote_addr;
};

Vue 支持 net_info_t 类型变量的以下特征和操作:

net_info_t 类型变量的声明

net_info_t n1,n2                       
// n1 is variable of type net_info_t
sockfd_netinfo(fd, n1);           
// fd is socket descriptor and n1 contains network 
// four tuple information from sockfd_netinfo Vue function.                                   
n2.local_addr = __ip4hdr->src_addr; 
n2.remote_addr = __ip4hdr->dst_addr; 
n1.local_port = __tcphdr->src_port; 
n1.remote_port = __tcphdr->dst_port;
net_info_t 类型的变量不支持 signed、unsigned、register、static、thread、local、global 和 kernel 限定符。

net_info_t 类型变量的限制

  • 不能支持 structure 和 union 成员变量。
  • 不能声明指向 net_info_t 变量的指针。
  • 此变量在关联数组中不受支持。
  • 不能声明 net_info_t 变量的数组。
  • 不允许将 net_info_t 变量强制转换为任何其他类型或将任何其他类型强制转换为 net_info_t 类型。
  • 不能将算术运算符(+、-、*、/、++、-- 等等)与 net_info_t 类型变量配合使用。