struct sniff_ip {
struct in_addr ip_src, ip_dst;
}
function{
const struct sniff_ip *ip;
ip = (struct sniff_ip*)(packet +SIZE_ETHERNET);
}
My goal here is to change the values of ip_src and ip_dst, but I can’t figure out the correct syntax to modify src or dst when it is in a struct within a struct. I know to access a member within a struct is normally ip->member or (*ip).member , but this doesn’t seem to be working for me here. What are the correct procedure(s) for accessing members in the event they are in a struct within a struct?
Edit: I want to change the ip addresses (values) for both src and dst. When using lines such as
“ip->ip_src=”
or
“ip->ip_src.s_addr=” , I get the error that
“assignment of read-only location ‘*ip’
1 Answer