ipt_ACCOUNT Archives

Subject: Re: BIG ENDIAN patches

From: Leonardo Secci <leonardo.secci@xxxxxxxxxx>
To: ipt_ACCOUNT@xxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 22 Oct 2009 12:26:04 +0200
Hi Thomas,

Sorry but I'm not a kernel developer, so I can't answer on question like 
"which is better way for".

I choose to approach endianness support in kernel module with preprocessor 
directives because computational irrelevant.

From kernel sorces (include/linux/byteorder/generic.h):
/*
 * The following macros are to be defined by <asm/byteorder.h>:
 *
 * Conversion of long and short int between network and host format
 *      ntohl(__u32 x)
 *      ntohs(__u16 x)
 *      htonl(__u32 x)
 *      htons(__u16 x)
 * It seems that some programs (which? where? or perhaps a standard? POSIX?)
 * might like the above to be functions, not macros (why?).
 * if that's true, then detect them, and take measures.
 * Anyway, the measure is: define only ___ntohl as a macro instead,
 * and in a separate file, have
 * unsigned long inline ntohl(x){return ___ntohl(x);}
 *
 * The same for constant arguments
 *      __constant_ntohl(__u32 x)
 *      __constant_ntohs(__u16 x)
 *      __constant_htonl(__u32 x)
 *      __constant_htons(__u16 x)

So I suppose,if you have to manage constant netmaks, and you like to use htonl 
approach, I suggest to look at  __constant_htonl instead.

I wish I'll be useful, ad if you need support on testing new code I will be 
happy to help.

Congratulations for your work.

Bye



In data giovedì 22 ottobre 2009 11:52:15, Thomas Jarosch ha scritto:
: > Hello Leonardo,
> 
> On Tuesday, 13. October 2009 15:14:35 Leonardo Secci wrote:
> > Solving some problem on porting ipt_ACCOUNT on OpenWRT for a mips
> >  architecture with "Big Endian" byte-order, I developed two patches that
> >  can be usefull for someone.
> >
> > The first patch apply on ipt_ACCOUNT kernel module for linux-2.6 and use
> > preprocessor directives to support both byte-order.
> >
> > Second patch apply on iptaccount tool.
> 
> Thanks for your patches! Just returned from vacation.
> 
> I took an intensive look at them and was wondering if we could
> solve this in a way without all those #ifdefs?
> 
> Would it be possible to change the internal u_int32_t types
> f.e. to __be32 and use htonl() on the bitmasks/shift operations?
> 
> What do you think?
> 
> Cheers,
> Thomas
> 
> --
> ipt_ACCOUNT - see http://www.intra2net.com/en/developer/ipt_ACCOUNT for
>  details. To unsubscribe send a mail to
>  ipt_ACCOUNT+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
> 

-- 
--------------------------------------------------------------------------
Leonardo Secci
mailto:leonardo.secci@xxxxxxxxxx

UniRel s.r.l.
Via Volturno località Osmannoro
Sesto Fiorentino - 50019 Firenze
Tel: +39.055.340773
Fax: +39.055.318525
Web: http://www.unirel.com

--------------------------------------------------------------------------
Avviso di riservatezza 
  Le informazioni contenute nella presente comunicazione e i relativi allegati
  possono essere riservate e sono, comunque, destinate esclusivamente alle
  persone o alla Società sopraindicati. La diffusione, distribuzione e/o
  copiatura del documento trasmesso da parte di qualsiasi soggetto diverso dal
  destinatario è proibita, sia ai sensi dell’art. 616 c.p., che ai sensi del
  D.Lgs. 196/2003. Se avete ricevuto questo messaggio per errore, Vi preghiamo
  di distruggerlo o di informarci immediatamente.

  The information in this e-mail (which includes any files transmitted with 
it)
  is confidential and may also be legally privileged. It is intended for the
  addressee only. Access to this e-mail by anyone else is unauthorised. It is 
  not to be relied upon by any person other than the addresse, except with our
  prior written approval. If no such approval is given, we will not accept any
  liability (in negligense or otherwise) rising from any third acting, or
  refraining from acting on such information. Unauthorised recipients are
  required to mantain confidentiality. If you have received this e-mail in
  error please notify immediately, destroy any copies ad delete it from your
  computer system. Any use, dissemination, forwarding, printing or copying of
  this e-mail is prohibited. Copyright in this e-mail and any document created
  by us will be remain vested in us and will not be transferred to you. We
  assert the right to be identified as the author of and to object to any 
  misuses of the contents of this e-mail or such documents.

--
ipt_ACCOUNT - see http://www.intra2net.com/en/developer/ipt_ACCOUNT for details.
To unsubscribe send a mail to ipt_ACCOUNT+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx

Current Thread