[openbeosnetteam] Re: mbuf.h

> Hi,
> why does mbuf.h define max_xxx variables like max_linkhdr?  This 
> creates the following problems:
>
> 1. The ppp interface module does not link against libkernelppp.a 
> because of multiple definitions of max_linkhdr, etc.

Oh, once again, here come globals variables *definitions* instead of *
declarations* in a header file.... Pfff.
Okay, that's buggy, you're right:

- The end of mbuf.h should be:

extern struct pool_ctl *mbpool;
extern struct pool_ctl *clpool;

extern int     max_hdr;         /* largest link+protocol header */
extern int      max_linkhdr;            /* largest link level header */
extern int      max_protohdr;           /* largest protocol header */

Notice the "extern", turning these miss-placed definitions into 
declarations.

Then, in mbuf.c these should be added at top:

struct pool_ctl *mbpool = NULL;
struct pool_ctl *clpool = NULL;
int max_hdr = 0;
int max_linkhdr = 0;
int max_protohdr = 0; 

Where these *definitions* belongs.

> 2. Those variables are never assigned a value, though, the tcp and 
> ipv4 modules use them.
> Where do their values come from?

From mbuf.c::mbinit().

> Can tcp and ipv4 use them? Does this not result in undefined values 
> for max_xxx?

No.
 
> If that is really a problem:
> How can we solve that? Should I add a new function to the core module 
> (as I will add a control() function anyway) 
> and define a new structure that will be used to retrieve the values 
> for those variables 

No, please, don't do that.
Do like other current tcp and ipv4 modules do, by including mbuf.h 
you'll get these mbuf-related globals defined.

> and can I remove the current definitions from the header?
> What about the other definitions like mbpool (or whatever they are 
> called)?

See on top.
Put shortly, yes you can and, please, feel free to do it :-)

- Philippe

--
Fortune Cookie Says:

A nuclear war can ruin your whole day.

Other related posts: