Afficher un message
Vieux 09/10/2007, 04h04   #2
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Why put the structures in a structure when assembling a TCP/IP Packet?

In article <1191893579.696576.127790@k79g2000hse.googlegroups .com>,
grocery_stocker <cdalten@gmail.com> wrote:

> Is there anykind of significance to putting a structure inside another
> stucture when assembling a TCP/IP packet by hand? In the following
> code snippet, struct iphdr and struct tcphdr are inside another
> stucture. The only thing I can think of is that it's to ensure some
> kind of memory alignmen
>
> struct tpack{
> struct iphdr ip;
> struct tcphdr tcp;
> }tpack; /*Why put the structures inside another structure?*/


Because that's how the packet is actually laid out. It also allows
applications that want to do stuff with the whole header to use a single
variable rather than two.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
  Réponse avec citation
 
Page generated in 0,05191 seconds with 9 queries