[hipl-dev] Re: leftover typedefs

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-dev@xxxxxxxxxxxxx
  • Date: Thu, 13 Jan 2011 20:12:44 +0100

On Tue, Jan 04, 2011 at 07:06:24PM +0100, Diego Biurrun wrote:
> I removed most, but not yet all, typedefs and _t namespace pollution
> in HIPL.  Some of the remaining ones can possibly be kept, but of
> course we have to rename them to address the namespace pollution.
> 
> The remaining typedefs can be grouped into a few classes:
> 
>   hipd/oppipdb.h:typedef struct in6_addr hip_oppip_t;

This one will go away with Rene's oppremoval branch, so I won't bother
dealing with it.

>   lib/core/protodefs.h:typedef struct in6_addr hip_hit_t;
>   lib/core/protodefs.h:typedef struct in_addr hip_lsi_t;

These are likely useful to differentiate syntactically as well as
semantically from their aliases.  Right now the distinction should
be made in theory, but in practice the types are used and cast
interchangeably.

So I propose introducing separate unique types for HITs and LSIs so
that there is a syntactic difference and the compiler can notice that
an IPv6 address is used where a HIT is expected and similar.

There are two possibilities:

  struct hip_hit {
      uint8_t hit_addr[16];
  };

  struct hip_lsi {
      in_addr_t lsi_addr;
  };

or

  typedef uint8_t[16] hip_hit;
  typedef in_addr_t   hip_lsi;

I'm still somewhat undecided which variant is preferable.

Diego

Other related posts: