Re: Casting (struct rtable*) to (struct dst_entry*)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



   From: N N Ashok <nalkunda@cse.msu.edu>
   Date: Thu, 20 Mar 2003 00:27:41 -0500

   I did see that. But however, I could not understand how "struct rtable" can be 
   casted to "struct dst_entry" and then back again, all the while accessing 
   fields of both structures.

You miss the point that they are the same structure.  It is allocated
the size of "struct rtable" but it may be casted back and forth
between rtable and dst_entry as desired.

void foo(void)
{
	struct rtable rt;
	struct dst_entry *dst;

	rt->u.dst.bar = 1;

	dst = (struct dst_entry *) &rt;
	ASSERT(dst->bar == 1);

	dst = &rt->u.dst;
	ASSERT(dst->bar == 1);
}
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux