开发者

acessing data of a structure from another structure

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜