{"action":"created","issue":{"url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/606","labels_url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/606/labels{/name}","comments_url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/606/comments","events_url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/606/events","html_url":"https://github.com/SnabbCo/snabbswitch/pull/606","id":103918321,"number":606,"title":"SnabbSwitch build as dynamic library","user":{"login":"pavel-odintsov","id":2744166,"avatar_url":"https://avatars.githubusercontent.com/u/2744166?v=3","gravatar_id":"","url":"https://api.github.com/users/pavel-odintsov","html_url":"https://github.com/pavel-odintsov","followers_url":"https://api.github.com/users/pavel-odintsov/followers","following_url":"https://api.github.com/users/pavel-odintsov/following{/other_user}","gists_url":"https://api.github.com/users/pavel-odintsov/gists{/gist_id}","starred_url":"https://api.github.com/users/pavel-odintsov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavel-odintsov/subscriptions","organizations_url":"https://api.github.com/users/pavel-odintsov/orgs","repos_url":"https://api.github.com/users/pavel-odintsov/repos","events_url":"https://api.github.com/users/pavel-odintsov/events{/privacy}","received_events_url":"https://api.github.com/users/pavel-odintsov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-08-30T10:59:59Z","updated_at":"2015-09-17T08:13:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SnabbCo/snabbswitch/pulls/606","html_url":"https://github.com/SnabbCo/snabbswitch/pull/606","diff_url":"https://github.com/SnabbCo/snabbswitch/pull/606.diff","patch_url":"https://github.com/SnabbCo/snabbswitch/pull/606.patch"},"body":"Hello, folks!\r\n\r\nI have implemented ability to build Snabb Switch as dynamic library, please review this pull request and offer some feedback. \r\n\r\nWhy I need this? I want to use SnabbSwitch as traffic capture backend for my C/C++ application because it's really fast. So with current implementation as stand alone binary I could not integrate it. Actually I want to use SnabbSwitch in similar to Netmap/PF_RING way.\r\n\r\nSo I decided to build SnabbSwitch as dynamic library and link it with my app.\r\n\r\nFor tests I have used Firehose app.\r\n\r\nI built .so for callback code:\r\n```C\r\ngcc -O3 -shared capturecallback.c -o capturecallback.so -fPIC\r\n-o/root/capturecallback.so\r\n```\r\n\r\nAnd build test app which linked against SnabbSwitch:\r\n ```C\r\ngcc test_app_linked_to_libsnabb.c -Lsrc -lsnabb\r\n```\r\n\r\nSo finally I could run it:```LD_LIBRARY_PATH=src ./a.out```\r\n\r\nAnd get output like this:\r\n```bash\r\nLoading shared object: /root/capturecallback.so\r\nInitializing NIC: 0000:02:00.0\r\nInitializing NIC: 0000:02:00.1\r\nInitializing callback library\r\nProcessing traffic...\r\nWe process: 153059 pps\r\nWe process: 572443 pps\r\nWe process: 564516 pps\r\n```\r\n\r\nI will be very glad if you could help me with integrating this code to\r\nSnabb Switch master. Because I haven't idea how we could build Snabb binary and libsnabb.so with same Makefile without breaking anything. "},"comment":{"url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/comments/140999731","html_url":"https://github.com/SnabbCo/snabbswitch/pull/606#issuecomment-140999731","issue_url":"https://api.github.com/repos/SnabbCo/snabbswitch/issues/606","id":140999731,"user":{"login":"pavel-odintsov","id":2744166,"avatar_url":"https://avatars.githubusercontent.com/u/2744166?v=3","gravatar_id":"","url":"https://api.github.com/users/pavel-odintsov","html_url":"https://github.com/pavel-odintsov","followers_url":"https://api.github.com/users/pavel-odintsov/followers","following_url":"https://api.github.com/users/pavel-odintsov/following{/other_user}","gists_url":"https://api.github.com/users/pavel-odintsov/gists{/gist_id}","starred_url":"https://api.github.com/users/pavel-odintsov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavel-odintsov/subscriptions","organizations_url":"https://api.github.com/users/pavel-odintsov/orgs","repos_url":"https://api.github.com/users/pavel-odintsov/repos","events_url":"https://api.github.com/users/pavel-odintsov/events{/privacy}","received_events_url":"https://api.github.com/users/pavel-odintsov/received_events","type":"User","site_admin":false},"created_at":"2015-09-17T08:13:48Z","updated_at":"2015-09-17T08:13:48Z","body":"Hello!\r\n\r\nWill be fine to get libfirehose.so too. It will be PoC for this idea. So if it success we could move forward. "}}