Welcome to the CSIR Meraka Institute's "COIN" Blog

Monday, September 06, 2004

Porting Mobilemesh From Linux To FreeBSD

First off the "Legal stuff", i.e. Limitations and Disclaimers!!!!


1.1 Limitation
At the time of writing this document, the ported implementation was not fully regress tested to make sure it performs exactly the same as the original Linux version. However, the minimal testing done did not reveal any differences in performance and/or functionality between the two ports.

1.2 Disclaimer
The Linux version is written in C++, so please take note that the writer is not a C++ expert and hence (possibly) some of the suggestions made could be amateurish. Certainly with rigorous testing and more time on the project such possible technical errors could have been spotted and fixed (hopefully).


3. Environment
3.1 Software Environment
The following table shows the software used during the porting.
Software Version
FreeBSD 5.2.1
Gmake 3.80
G++ 3.3.3


3.2 Make Utility Issues
From the start, if you get errors when running make using the provided Makefile, simply switch to gmake.

3.2.1 Compiler Isuues
3.2.1.1 Array Indexing Issues
The Linux version indexes arrays using char type. This causes at least warnings during compile time.
Suggested solution: Typecast all indices to unsigned char.
Reason: It appears that the ISO standard does allow/specify that type char can be used as an array index, however, leave it up to the compiler implementors to decided where such char is signed or unsigned. However, a char can either be unsigned or signed. In the case of signed char, this also includes negative numbers that cannot index array and hence a possible runtime error. So some compilers do insist/expect (at complie time) that the char index variable be qualified as either signed or unsigned.

3.2.1.2 Class Variables Initilisation
Ensure that class variables are initialised. Otherwise, calls to some system calls simply fail. E.g. the call to sysctl() function failed until all variables used in its call were properly initialised.

3.2.1.3 Errors and Warnings in File BoBorder.h
Error
: “ISO ++ standard ambiguity”.
Suggested solution: At every occurance of an expression where an addition between an object and an integeris performed, use the dot operator+.
E.g. use now.operator+(cAdPeriod) instead of now + cAdPeriod.

3.2.1.4 Errors and Warnings in File LnDiscover.h
Error
: “ISO ++ standard ambiguity”.
Suggested solution: At every occurance of an expression where an object is added to an integer, use the dor operator.
E.g. use pruneTime.operator+(cPrunePeriod) instead of pruneTime + cPrunePeriod.

3.2.1.5 Errors accessing member variables of rtentry structure in File MmRouter.h
Error: Variables rt_dst, rt_gateway, rt_genmask and rt_metric are not members of the structure rtentry.
Suggested solution: Comment them out and carry on. At least this stops the compiler errors.

NOTE: Please remember that I didn’t do regress testing and hence didn’t notice any errors as a result of commenting out this code. I however do realise that these commented lines are functional code and one could/should expect some issues either functional or performance related.

3.2.1.6 Errors in Parameter Arguments in File UtDebug.c
Error
: Some functions make variable assignments on the function parameters. This causes an error as the same assignments are already made in file UtDebug.h.
Suggested Solution: Comment out the variable assignment part of the function parameters.

3.2.1.7 Changes in File UtInterface.h
This file presented me with so many functional runtime problems that I had to “rewrite” a part of it. This mainly apply to Discover() method.
Suggested solution:
a) Replace all ioctl function calls with sysctl calls. Search the man pages for the sysctl documentation.
b) The Discover() method mainly extracts each interface’s information from the kernel, create an interface object using the extracted information and then pushes the interface object into a list. Replace the extraction of interface information code and a good reference is the source code of ifconfig.c (that’s part of the FreeBSD distribution).

3.2.1.8 Errors in Parameter Arguments in File UtString.C
Error: Some functions make variable assignments on the function parameters. This causes an error since the same assignments are already made in file UtString.h.
Suggested Solution: Comment out the assignment part of the function parameters.


1 comment:

:p said...

hello, i m having problem with the File UtInterface.h. coz i keep on getting the error msg stated:
Border::AddTunnel()'mmtunnel add bo0 -local- -dest- -new- failed : ioctl: No Such device
Can u give me a guide on this. Thank you :p