
|
[openbeosnetteam]
||
[Date Prev]
[05-2003 Date Index]
[Date Next]
||
[Thread Prev]
[05-2003 Thread Index]
[Thread Next]
[openbeosnetteam] Re: PPP API
- From: "Ingo Weinhold" <bonefish@xxxxxxxxxxxxxxx>
- To: openbeosnetteam@xxxxxxxxxxxxx
- Date: Sat, 17 May 2003 15:55:58 +0200 CEST
"Waldemar Kornewald" <Waldemar.Kornewald@xxxxxx> wrote:
> > I've been busy lately, so I haven't had to time to look at it.
> > However,
> > as my response has been requested, I feel obliged to at least say
> > something. Perhaps I can remedy the situation by dumping lots of
> > code
> > at you guys: http://members.verizon.net/~vze236yf/
> > net_server_stuff.zip
> > This code was written in another context, and (for a variety of
> > reasons) is probably slow as hell, but it does illustrate some of
> > the
> > ideas I've mentioned. It also (as far as it goes -- which is a
> > generic
> > ethernet driver and a PPPoE stack) actually works, and does so
> > quite
> > well. I have omitted all of the support libraries, however. If you
> > want
> > them, e-mail me. Maybe that will delay you long enough for me to be
> > able to take a look at yours.
>
> I like the idea, really. Unfortunately, it is too inefficient.
> Strings are
> flexible, but too slow for this. Int32 is not felxible enough because
> you
> cannot define codes that say what they do (like "pppoe/ethernet").
> There must be a better solution....
A string together with a hash value may do. Something like:
class HashString {
public:
HashString(const char *str)
: fString(str),
fHash(_ComputeHash(fString))
{
}
...
inline const char *String() { return fString; }
inline uint32 Hash() { return fHash; }
...
inline int Compare(const HashString& other)
{
int cmp = (int)fHash - (int)other.fHash;
if (cmp == 0)
cmp = strcmp(fString, other.fString);
return cmp;
}
inline operator==()(const HashString& other)
{
return (Compare(other) == 0);
}
...
private:
uint32 fHash;
const char *fString;
};
Given a good hash function comparissons are O(1) for virtually all but
identical strings. Furthermore objects of this class are supposed to be
good citizens of hash tables.
> Anyway, I want to produce some code now, so I will not write many
> mails in
> that time.
Have fun!
CU, Ingo
|

|