Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] add oonf_api to pkg #630

Merged
merged 1 commit into from
Mar 13, 2014
Merged

[RFC] add oonf_api to pkg #630

merged 1 commit into from
Mar 13, 2014

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Feb 6, 2014

This adds OLSRs oonf_api as a RIOT package. oonf_api provides a rfc5444 reader/writer as well as utilities such as an avl tree, a flexible buffer, a double linked list as well as address abstraction (IPv4/Ipv6/MAC - not very necessary on RIOT) and string functions.
The package provides three modules, oonf_common, oonf_rfc5444 (depends on oonf_common) and cunit for unit tests.
This package pulls in the whole of oonf_api from git, but the majority of the code (OS abstraction, config framework, telnet and webserver, …) is neither required nor functional on RIOT, so it's ignored by the build system.
The only folders of interest are:

dir use
src-api/common library functions
src-api/rfc5444 rfc5444 reader/writer
tests/cunit cunit test framework
tests/common unit tests for common (run generate_makefiles.sh)
tests/rfc5444 unit tests for rfc5444 (run generate_makefiles.sh)
examples/rfc5444_reader_writer example application

Usage is a bit cumbersome because of the include paths, as seen in https://github.com/benpicco/tiny_olsr2/blob/master/Makefile

EXTERNAL_MODULES +=$(RIOTBASE)/pkg/oonf_api
USEMODULE += oonf_common
USEMODULE += oonf_rfc5444
INCLUDES += -I$(RIOTBASE)/pkg/oonf_api/oonf_api/src-api

Also, build order is important, modules that depend on this won't find includes unless the pkg is build, aka checked out and patched.

I'm welcome for suggestions on how to improve this.

@OlegHahm OlegHahm added this to the Release NEXT MAJOR milestone Feb 6, 2014
@mehlis
Copy link
Contributor

mehlis commented Feb 6, 2014

@Lotterleben is this working for you? please check carefully for your use case.

@LudwigKnuepfer
Copy link
Member

I think it makes sense to wait for the outcome of #576 before merging this.

@Lotterleben
Copy link
Member

@mehlis seems to be working fine

@mehlis
Copy link
Contributor

mehlis commented Feb 9, 2014

👍 to wait until #576 is discussed and merged

@benpicco
Copy link
Contributor Author

rebased against #576

@mehlis
Copy link
Contributor

mehlis commented Feb 12, 2014

perhaps this is unrelated but: would it make sense to have a rfc5444 "service" running in its own thread. seems to me that olsr/aodv and nhdp need this parser.

Is this library thread safe? What is its footprint in terms of stack usage? Does it use malloc/free?

@OlegHahm
Copy link
Member

I wasn't able to build this. Can you provide an example application? master of https://github.com/benpicco/tiny_olsr2 seems to be not up-to-date.

@benpicco
Copy link
Contributor Author

I will move tiny_olsr2 to sys/net/routing/olsr2 and add an example application to projects, but for now you can run make patch in pkg/oonf_api and then build oonf_api/examples/rfc5444_reader_writer/ or oonf_api/tests/common/ and oonf_api/tests/rfc5444/ if you just want to try out oonf_api.

@benpicco
Copy link
Contributor Author

The rfc5444 reader/writer is based on callback functions for each action, so it might be possible to switch this over to message passing, but then again the library is not thread safe (however the portions used don't keep any state on their own) so additional efforts would be required. And I don't think the overhead of having another thread would be justified, in the most common case you won't run olsr2 and aodv2 in parallel.

size for the ARM build says

   text    data     bss     dec     hex filename
   1364       0       0    1364     554 autobuf.o (ex msba2/oonf_api.a)
   2540       0       0    2540     9ec avl.o (ex msba2/oonf_api.a)
    120       0       0     120      78 avl_comp.o (ex msba2/oonf_api.a)
      0       0       0       0       0 daemonize.o (ex msba2/oonf_api.a)
   4080       0       0    4080     ff0 netaddr.o (ex msba2/oonf_api.a)
   1136       0       0    1136     470 netaddr_acl.o (ex msba2/oonf_api.a)
    676       0       0     676     2a4 rfc5444.o (ex msba2/oonf_api.a)
    796       0       0     796     31c rfc5444_context.o (ex msba2/oonf_api.a)
     40       0       0      40      28 rfc5444_iana.o (ex msba2/oonf_api.a)
   8056       0       0    8056    1f78 rfc5444_msg_generator.o (ex msba2/oonf_api.a)
   1584       0       0    1584     630 rfc5444_pkt_generator.o (ex msba2/oonf_api.a)
   3288       0       0    3288     cd8 rfc5444_print.o (ex msba2/oonf_api.a)
   6080       0       0    6080    17c0 rfc5444_reader.o (ex msba2/oonf_api.a)
    512       0       0     512     200 rfc5444_tlv_writer.o (ex msba2/oonf_api.a)
   4152       0       0    4152    1038 rfc5444_writer.o (ex msba2/oonf_api.a)
   3728       0       0    3728     e90 string.o (ex msba2/oonf_api.a)
   1260       0       0    1260     4ec template.o (ex msba2/oonf_api.a)
  39412       0       0   39412    99f4 (TOTALS)

but calloc is used. After startup about 4k of autobuf buffers are allocated, they grow dynamically with realloc if more memory is needed. Their initial size is getpagesize() (arbitrarily set to 512 as it's not available on the msba2), but smaller values might be used.

@Lotterleben
Copy link
Member

The Makefile in RIOT/pkg/oonf_api/oonf_api/examples/rfc5444_reader_writer/ uses a path to the RIOTBASE that probably won't work for everybody:

export RIOTBASE =/home/benpicco/µkleos/riot/RIOT

@Lotterleben
Copy link
Member

After correcting the RIOTBASE to export RIOTBASE =../../../../../ I got the following error:

 gcc: error: /home/lotte/bachelor/riot/RIOT/pkg/oonf_api/oonf_api/examples/rfc5444_reader_writer/bin/native/oonf_common.a: No such file or directory
 gcc: error:  /home/lotte/bachelor/riot/RIOT/pkg/oonf_api/oonf_api/examples/rfc5444_reader_writer/bin/native/oonf_rfc5444.a: No such file or directory

@benpicco
Copy link
Contributor Author

oops, missed that one - should work now.

@Lotterleben
Copy link
Member

When I tried to compile des-testbed/RIOT-projects#98, I ran into the following errors:

make complained that it couldn't find the oonf api:

lotte@riot:~/bachelor/riot/projects/olsr2$ make
"make" -C /home/lotte/bachelor/riot/RIOT/pkg/oonf_api
make[1]: Entering directory `/home/lotte/bachelor/riot/RIOT/pkg/oonf_api'
make[1]: *** No targets specified and no makefile found.  Stop.
make[1]: Leaving directory `/home/lotte/bachelor/riot/RIOT/pkg/oonf_api'
make: *** [/home/lotte/bachelor/riot/projects/olsr2/bin/native/oonf_api.a] Error 2

After I copied all oonf files from RIOT/pkg/oonf_api/oonf_api to RIOT/pkg/oonf_api, I got the following errors:

autobuf.c:60:10: fatal error: 'common/autobuf.h' file not found
#include "common/autobuf.h"
         ^
1 error generated.
make[2]: *** [/home/lotte/bachelor/riot/projects/olsr2/bin/native/autobuf.o] Error 1
make[2]: Leaving directory `/home/lotte/bachelor/riot/RIOT/pkg/oonf_api/src-api/common'
make[2]: Entering directory `/home/lotte/bachelor/riot/RIOT/pkg/oonf_api/src-api/rfc5444'
clang -DRIOT -DENABLE_NAME -ggdb -DBOARD_NATIVE -DINIT_ON_START -DBOARD=NATIVE -DCPU_NATIVE -DMODULE_AUTO_INIT -DMODULE_RTC -DMODULE_UART0 -DMODULE_POSIX -DMODULE_PS -DMODULE_SHELL -DMODULE_SHELL_COMMANDS -DMODULE_RANDOM -DMODULE_CONFIG -DMODULE_OLSR2 -DMODULE_NATIVENET -DMODULE_CPU -DMODULE_CORE -DMODULE_SYS -DMODULE_LIB -DMODULE_VTIMER -DMODULE_DESTINY -DMODULE_SIXLOWPAN -DMODULE_OONF_COMMON -DMODULE_OONF_RFC5444 -DMODULE_NET_HELP -DMODULE_IEEE802154 -DMODULE_SEMAPHORE -DMODULE_TRANSCEIVER -DMODULE_HWTIMER -DMODULE_TIMEX -Wall -Wextra -pedantic -m32 -std=gnu99 -DVERSION=\"2014.01-301-g56c34-pr/765\" -I/home/lotte/bachelor/riot/RIOT/sys/net/include -I/home/lotte/bachelor/riot/RIOT/core/include -I/home/lotte/bachelor/riot/RIOT/drivers/include -I/home/lotte/bachelor/riot/RIOT/sys/include -I/home/lotte/bachelor/riot/RIOT/boards/native/include -I/home/lotte/bachelor/riot/RIOT/cpu/native/include -c rfc5444.c -o /home/lotte/bachelor/riot/projects/olsr2/bin/native/rfc5444.o
rfc5444.c:43:10: fatal error: 'common/common_types.h' file not found
#include "common/common_types.h"
         ^
1 error generated.
make[2]: *** [/home/lotte/bachelor/riot/projects/olsr2/bin/native/rfc5444.o] Error 1
make[2]: Leaving directory `/home/lotte/bachelor/riot/RIOT/pkg/oonf_api/src-api/rfc5444'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/lotte/bachelor/riot/RIOT/pkg/oonf_api'
make: *** [/home/lotte/bachelor/riot/projects/olsr2/bin/native/oonf_api.a] Error 2  

@benpicco
Copy link
Contributor Author

des-testbed/RIOT-projects#98 depends on #765

@Lotterleben
Copy link
Member

I know, that's why I made sure I checked it out in my RIOT folder before I tried to compile des-testbed/RIOT-projects#98. But you're right, this is not the right place for that comment (even though the double nesting of oonf_api/oonf_api struck me as odd).

@benpicco
Copy link
Contributor Author

When I do

git clone [email protected]:benpicco/RIOT.git && cd RIOT
git checkout -b oonf_api origin/oonf_api
git checkout -b olsr2 origin/olsr2
git merge oonf_api

and

git clone [email protected]:benpicco/projects.git && cd projects
git checkout -b olsr2 origin/olsr2
ln -s /path/to/RIOT/ .

projects/olsr2 does build

(the example project only calls USEMODULE for olsr2, Makefile.dep takes care of including oonf_rfc5444, oonf_common and the network stack)

@Lotterleben
Copy link
Member

Yup, when I do that, it builds on my computer as well. What I did was:
In RIOT/

git fetch origin
git checkout pr/765
git checkout -b oonftest2
git merge pr/630

in projects/

git fetch origin
git checkout pr/98

@Lotterleben
Copy link
Member

@benpicco Ping? I'm really interested in resolving this one...

@benpicco
Copy link
Contributor Author

benpicco commented Mar 4, 2014

Umm, are you sure that projects/RIOT is the same as the one where you merged the pr?

If I use the current upstream master and do

git fetch origin
git merge origin/pr/765 
git merge origin/pr/630

and

git fetch origin
git merge origin/pr/98

it builds just fine.

@Lotterleben
Copy link
Member

I'm pretty sure I did, but yup, with a clean slate it works for me too. Sorry about the fuss.

@Lotterleben
Copy link
Member

Seems to be working fine, if anyone wants to review & merge ;)

Lotterleben added a commit that referenced this pull request Mar 13, 2014
@Lotterleben Lotterleben merged commit 2755b69 into RIOT-OS:master Mar 13, 2014
@LudwigKnuepfer
Copy link
Member

@benpicco I created #884 for you but can not assign you (I guess that is because you are not part of the RIOT-OS orga..).

@OlegHahm
Copy link
Member

Added @benpicco to the Github RIOT developer team and assigned the issue to him.

@benpicco benpicco deleted the oonf_api branch March 17, 2014 15:39
@OlegHahm OlegHahm mentioned this pull request Jan 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants