[PATCH 3/7] comm, site: pass a new "struct comm_addr" rather than sockaddr_in

Ian Jackson ijackson at chiark.greenend.org.uk
Thu Aug 4 15:10:16 BST 2011


Richard Kettlewell writes ("Re: [PATCH 3/7] comm, site: pass a new "struct comm_addr" rather than sockaddr_in"):
> > -	memcpy(sa,&dest->sin_addr,4);
> > +	memcpy(sa,&dest->sin.sin_addr,4);
> >   	memset(sa+4,0,4);
> > -	memcpy(sa+6,&dest->sin_port,2);
> > +	memcpy(sa+6,&dest->sin.sin_port,2);
> >   	sendto(st->fd,sa,buf->size+8,0,(struct sockaddr *)&st->proxy,
> >   	       sizeof(st->proxy));
> 
> This is a tangential point to the patch, which seems fine to me, but I 
> wonder if we can do better than the magic number offsets in there? 
> udp_afterpoll() too.

The whole of secnet is full of this kind of non-declarative definition
of its protocol syntax.  Unless we want to introduce a formal
marshalling system, I think this approach will have to do.

Ian.



More information about the sgo-software-discuss mailing list