To me it sounds like you may be looking for the C construct "union".
struct wccc_packet {
[common data]
enum wccp_type { WCCP_FOO, WCCP_BAR } type;
union {
struct wccp_foo foo;
struct wccp_bar bar;
} data;
};
Here "data" is either a wccp_foo or a wccp_bar.
What I don't get is why you have a length parameter in the structs.
-- Henrik Joe Cooper wrote: > By this, I mean, I have a struct foo, and a struct bar: > > struct foo { > uint16_t type; > uint16_t length; > }; > > struct bar{ > struct foo foostruct; > uint32_t length; > } > > Now, is there a way to (safely) unroll the values of either of these > structs into a packet buffer using the same function even though their > contents are dissimilar? Pointers to documentation would be fine, I'm > just not seeing any examples in any of my books. > > Feel free to ridicule me for going about it all wrong from the get go. > (Just offer up tips for the right direction.) > > Thanks! > -- > Joe Cooper <joe@swelltech.com> > Affordable Web Caching Proxy Appliances > http://www.swelltech.comReceived on Thu Jul 19 2001 - 15:42:43 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:07 MST