-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
in_someip: SOME/IP input plugin #9570
base: master
Are you sure you want to change the base?
Changes from 8 commits
98c94e6
b1e9803
a7e41f4
943391b
a2b46b3
0142e58
ded0e49
6763dde
3905bf5
3be318c
239b46b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
[SERVICE] | ||
# Flush | ||
# ===== | ||
# Set an interval of seconds before to flush records to a destination | ||
Flush 5 | ||
|
||
# Daemon | ||
# ====== | ||
# Instruct Fluent Bit to run in foreground or background mode. | ||
Daemon Off | ||
|
||
# Log_Level | ||
# ========= | ||
# Set the verbosity level of the service, values can be: | ||
# | ||
# - error | ||
# - warning | ||
# - info | ||
# - debug | ||
# - trace | ||
# | ||
# By default 'info' is set, that means it includes 'error' and 'warning'. | ||
Log_Level trace | ||
|
||
# HTTP Monitoring Server | ||
# ====================== | ||
# | ||
# HTTP_Monitor: enable/disable the HTTP Server to monitor | ||
# Fluent Bit internals. | ||
# HTTP_Port : specify the TCP port of the HTTP Server | ||
HTTP_Monitor Off | ||
HTTP_Port 2020 | ||
|
||
[INPUT] | ||
Name someip | ||
Tag in.someip | ||
|
||
# Events to subscribe to. | ||
# Each event should have form: | ||
# Event <service id>,<instance id>,<event id>,<event group 1>,... | ||
# | ||
# Each event must have at least one event group | ||
Event 4,1,32768,1 | ||
Event 4,1,32769,2 | ||
|
||
# RPC to send on startup | ||
# Each RPC entry should have form: | ||
# RPC <service id>,<instance id>,<method id>,<Request Payload> | ||
# | ||
# Request payload should be base64 encoded | ||
RPC 4,1,1,CgAQAw== | ||
[OUTPUT] | ||
Name stdout | ||
Match * |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,9 @@ RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/ | |
flex \ | ||
bison \ | ||
libyaml-dev \ | ||
libboost-system-dev \ | ||
libboost-thread-dev \ | ||
libboost-filesystem-dev \ | ||
patrick-stephens marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
@@ -141,6 +144,9 @@ RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/ | |
liblzma5 \ | ||
libyaml-0-2 \ | ||
libcap2 \ | ||
libboost-system-dev \ | ||
libboost-thread-dev \ | ||
libboost-filesystem-dev \ | ||
Comment on lines
+147
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is including the dev libraries in the runtime image - we should just have the minimal set of libraries needed for running fluent bit, not those for building it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @patrick-stephens, I tried to take these out, leaving only the entries above (line 57). But when I did, I was not able to build the SOME/IP input plugin and its dependent libraries from the dev container. Likewise when I tried to replace these in this section with the "non-dev" version ( Please advise if there is something I am doing wrong here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think you need to look at why, the dev libraries should only be in the build stage which is fine. At runtime we need the minimal set of dependencies required to run with, otherwise we end up opening a big bag of security worms with extra dependencies. Header files are not needed at runtime, they should not be in the runtime image. So I think you need to ensure the |
||
&& \ | ||
mkdir -p /dpkg/var/lib/dpkg/status.d/ && \ | ||
for deb in *.deb; do \ | ||
|
@@ -221,6 +227,9 @@ RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/ | |
libatomic1 \ | ||
libgcrypt20 \ | ||
libyaml-0-2 \ | ||
libboost-system-dev \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, do we really need the development libraries here or can we just use the runtime ones? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, I tried to change this section to the use the non-dev libs and was not able to build the SOME/IP plugin/libs from the dev container. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section is unrelated to building so changing it here should have no impact on compilation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but this is not compiling anything, this is the debug image so again should just have the minimum set of packages per the |
||
libboost-thread-dev \ | ||
libboost-filesystem-dev \ | ||
bash gdb valgrind build-essential \ | ||
git bash-completion vim tmux jq \ | ||
dnsutils iputils-ping iputils-arping iputils-tracepath iputils-clockdiff \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
project(someipc CXX) | ||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
vsomeip3 | ||
GIT_REPOSITORY https://github.com/COVESA/vsomeip | ||
GIT_TAG 0b83e24d16e1611958194e9b727136522f46556b # 3.5.1 | ||
) | ||
FetchContent_MakeAvailable(vsomeip3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dependencies are generally vendored into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I added the source for vsomeip 3.5.1 as a sub-directory here and updated CMake file to build it before the C wrapper code. |
||
|
||
find_package(vsomeip3 REQUIRED) | ||
|
||
add_library(someip-c SHARED src/someip_wrapper.cc) | ||
target_include_directories(someip-c PUBLIC include) | ||
target_link_libraries(someip-c PRIVATE vsomeip3 vsomeip3-sd vsomeip3-cfg vsomeip3-e2e) | ||
target_link_options(someip-c PUBLIC "-Wl,--disable-new-dtags") | ||
|
||
add_subdirectory(example) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
add_executable(someip_test_service test_service.cc) | ||
target_link_libraries(someip_test_service PRIVATE someip-c) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* Fluent Bit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a C++ file, is that just a standard example and/or can it be C only? It seems to require a C++ compiler by looking at the example cmake linkage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is a C++ file. I will re-write it in C. |
||
* ========== | ||
* Copyright (C) 2015-2024 The Fluent Bit Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "someip_api.h" | ||
#include <iostream> | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <chrono> | ||
#include <sstream> | ||
#include <thread> | ||
|
||
/* Class declaration */ | ||
class TestService { | ||
public: | ||
bool Initialize(); | ||
void Teardown(); | ||
void HandleRequest(const struct some_ip_request* request_ptr); | ||
void SendEvent(const int num); | ||
private: | ||
uint16_t client_id_{0}; | ||
}; | ||
|
||
namespace { | ||
constexpr auto NAME = "Test Service"; | ||
constexpr uint16_t SERVICE_ID = 4; | ||
constexpr uint16_t INSTANCE_ID = 1; | ||
constexpr uint16_t METHOD_ID = 1; | ||
constexpr uint16_t EVENT_ID = 0x8000U; | ||
constexpr uint16_t EVENT_GROUP_ID = 1; | ||
|
||
void RequestCallback(void* cookie, struct some_ip_request* request_ptr) { | ||
if (cookie == nullptr) { | ||
return; | ||
} | ||
auto service_pointer{static_cast<TestService*>(cookie)}; | ||
service_pointer->HandleRequest(request_ptr); | ||
} | ||
} | ||
|
||
bool TestService::Initialize() { | ||
auto ret = someip_initialize(NAME, &client_id_); | ||
if (ret != SOMEIP_RET_SUCCESS) { | ||
std::cout << "Failed to initialize SOME/IP: " << ret << std::endl; | ||
return false; | ||
} | ||
|
||
/* Register Request Handler */ | ||
auto request_handler{[this](struct some_ip_request* request_ptr) { | ||
HandleRequest(request_ptr); | ||
}}; | ||
ret = someip_register_request_handler(client_id_, SERVICE_ID, INSTANCE_ID, | ||
METHOD_ID, this, RequestCallback); | ||
|
||
if (ret != SOMEIP_RET_SUCCESS) { | ||
std::cout << "Failed to register request handler: " << ret << std::endl; | ||
someip_shutdown(client_id_); | ||
return false; | ||
} | ||
|
||
/* Offer Event */ | ||
ret = someip_offer_event(client_id_, SERVICE_ID, INSTANCE_ID, EVENT_ID, const_cast<uint16_t*>(&EVENT_GROUP_ID), 1); | ||
if (ret != SOMEIP_RET_SUCCESS) { | ||
std::cout << "Failed to Offer Event: " << ret << std::endl; | ||
someip_shutdown(client_id_); | ||
return false; | ||
} | ||
|
||
/* Offer Service */ | ||
ret = someip_offer_service(client_id_, SERVICE_ID, INSTANCE_ID); | ||
if (ret != SOMEIP_RET_SUCCESS) { | ||
std::cout << "Failed to Offer Service: " << ret << std::endl; | ||
someip_shutdown(client_id_); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void TestService::Teardown() { | ||
someip_shutdown(client_id_); | ||
} | ||
|
||
void TestService::HandleRequest(const struct some_ip_request* request_ptr) { | ||
if (request_ptr == nullptr) { | ||
return; | ||
} | ||
std::cout << "Received request (method = " << request_ptr->method_id << ")" << std::endl; | ||
std::cout << "Payload length = " << request_ptr->payload_len << std::endl; | ||
|
||
/* Normal service would Parse the request and perform/initiate some actions on it*/ | ||
/* For this example just send back a canned response */ | ||
auto response{"This is the response to the request"}; | ||
const auto ret = someip_send_response(client_id_, request_ptr->request_id.client_request_id, | ||
const_cast<char*>(response), strlen(response)); | ||
if (ret != SOMEIP_RET_SUCCESS) { | ||
std::cout << "Failed to send response: %d" << ret << std::endl; | ||
} | ||
} | ||
|
||
void TestService::SendEvent(const int num) { | ||
std::stringstream ss; | ||
ss << "Event Number " << num; | ||
const auto message = ss.str(); | ||
|
||
auto ret = someip_send_event(client_id_, SERVICE_ID, INSTANCE_ID, EVENT_ID, | ||
message.data(), message.size()); | ||
} | ||
|
||
|
||
int main() { | ||
TestService service; | ||
if (!service.Initialize()) { | ||
return EXIT_FAILURE; | ||
} | ||
|
||
auto num_events{10}; | ||
|
||
for (auto i = 0; i < num_events; ++i) { | ||
service.SendEvent(i); | ||
std::this_thread::sleep_for(std::chrono::seconds(2)); | ||
} | ||
|
||
service.Teardown(); | ||
return EXIT_SUCCESS; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you can enable this globally without considering all platforms that are supported including Windows and macOS configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @patrick-stephens , will remove this here.