29
8.连接网络用户信息 连接网络用户信息
1 8.1 获取内网主机信息
读取内网 IP 主机信息,可读取该主机 MAC 地址、设备名、所属用户组、NAT session
数量、当前速度、总上行/下行字节数、在线时长信息。
int dump_host_info(struct in_addr addr, struct host_info *flow)
参数 :
addr[in]: 需要查询的 IP 主机地址
flow[out]: 指向存储返回信息的空间,host_info 结构定义如下:
struct host_info {
uint32_t size_of_struct;
struct in_addr addr;
unsigned char mac[ETH_ALEN];
char name[32]; /* host name*/
char manu_name[32];/* manuhost name */
char dev_label[32];
user_group_mask_t grp; /* host belongs to whichgrpbitmap */
intconn_cnt; /* numberof NAT session */
intup_speed; /* Byte per second*/
intdown_speed;/* Byte per second*/
__u64 up_bytes;/* total upload bytes */
__u64 down_bytes; /* total downloadbytes */
unsigned long up_pkts; /* upload pkts */
unsigned long down_pkts; /*download pkts */
__u64 magic; /*magic number for web auth */
__u32 second; /* online second*/
intos_type;/*linux、windows…*/
intspeed_mx[IP_CT_DIR_MAX]; /*peak speed value */
intdevice_label; /* devicemanufacturer */
};
值 返回值 :
< 0 时,查询错误,为 ERR_NON_EXIST 时,查询的主机不存在。
=0 时,成功。
举例:
struct host_info info = { { 0,},};
struct in_addr addr;
NOS_STRUCT_INIT(&info);
addr.s_addr=htonl(0xc0a80102);
dump_host_info(addr, &info);