[hipl-dev] Re: leftover typedefs

  • From: Samu Varjonen <samu.varjonen@xxxxxxx>
  • To: hipl-dev@xxxxxxxxxxxxx
  • Date: Fri, 14 Jan 2011 12:58:33 +0200

On 14/01/11 12:17, Miika Komu wrote:
Hi Diego,

On 01/13/2011 09:12 PM, Diego Biurrun wrote:
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.

I think the struct would be more modular (you can add flags etc there) but
perhaps a bit more work as well. We actually used to have something like this
earlier but I guess it has been removed.


The struct would be a bit more work but as Miika said more modular and IMO would be better suited into the socket API style.

BR,
Samu

Other related posts: