开发者

acessing data of a structure from another structure

开发者 https://www.devze.com 2023-02-10 21:23 出处:网络
Here src_addr is of type char[16], ptr->ip.ip_src.s_addr is used to access the source address of the packets that flows in the network when i assigned

Here src_addr is of type char[16], ptr->ip.ip_src.s_addr is used to access the source address of the packets that flows in the network when i assigned

keys.dst_addr =  ((ptr->ip.ip_dst.s_addr)&(0x0FF<<(i*8)))>>(i*8) ;

i used to get a error

error: incompatible types when assigning to type ‘char[16]’ from type ‘in_addr_t’

so i assigned it in this form converted the source address using inet_ntoa is this 开发者_如何学编程the right way? i still get errors in this line

 keys.src_addr = inet_ntoa (ptr->ip.ip_src.s_addr);


Try using:

keys.dst_addr = inet_ntoa(ptr->ip.ip_dst);
keys.src_addr = inet_ntoa(ptr->ip.ip_src);
0

精彩评论

暂无评论...
验证码 换一张
取 消