-
Notifications
You must be signed in to change notification settings - Fork 1.7k
in_someip: SOME/IP input plugin #9570
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -63,6 +63,32 @@ | |
WORKDIR /src/fluent-bit/ | ||
COPY . ./ | ||
|
||
# to build for vsomeip but not add C++ dependencies to pro | ||
FROM builder-base AS builder-vsomeip | ||
|
||
WORKDIR /tmp | ||
|
||
# fetch and compile boost 1.74 (for vsomeip) | ||
RUN curl -Ls https://archives.boost.io/release/1.74.0/source/boost_1_74_0.tar.bz2 -o boost.tar.bz2 && \ | ||
Check warning on line 72 in dockerfiles/Dockerfile
|
||
echo "83bfc1507731a0906e387fc28b7ef5417d591429e51e788417fe9ff025e116b1 boost.tar.bz2" > boost-sha.txt && \ | ||
sha256sum --quiet -c boost-sha.txt && \ | ||
mkdir -p /opt/boost && \ | ||
tar --strip-components 1 --no-same-owner --directory /opt/boost -xjf boost.tar.bz2 && \ | ||
cd /opt/boost && \ | ||
./bootstrap.sh && \ | ||
./b2 --with-system --with-thread --with-filesystem cxxflags="-fPIC" install -j $(nproc) --variant=release link=static && \ | ||
rm -rf /tmp/* | ||
|
||
# fetch and compile vsomeip version 3.5.1 | ||
RUN curl -Ls https://github.com/COVESA/vsomeip/archive/refs/tags/3.5.1.tar.gz -o vsomeip.tar.gz && \ | ||
Check warning on line 83 in dockerfiles/Dockerfile
|
||
echo "220ff5f105ac5f7eb33071986a12505526415217b28d4dd75164b38087dc9bcc vsomeip.tar.gz" > vsomeip-sha.txt && \ | ||
sha256sum --quiet -c vsomeip-sha.txt && \ | ||
mkdir -p /opt/vsomeip && \ | ||
tar --strip-components 1 --no-same-owner --directory /opt/vsomeip -xzf vsomeip.tar.gz && \ | ||
cd /opt/vsomeip && \ | ||
cmake -Bbuild -H. && cd build && make -j "$(getconf _NPROCESSORS_ONLN)" install && \ | ||
rm -rf /tmp/* | ||
Comment on lines
+83
to
+90
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. We should be vendoring this code in I think under |
||
|
||
# We split the builder setup out so people can target it or use as a base image without doing a full build. | ||
FROM builder-base AS builder | ||
WORKDIR /src/fluent-bit/build/ | ||
|
@@ -78,6 +104,7 @@ | |
cmake -DFLB_RELEASE=On \ | ||
-DFLB_JEMALLOC=On \ | ||
-DFLB_TLS=On \ | ||
-DFLB_IN_SOMEIP=On \ | ||
-DFLB_SHARED_LIB=Off \ | ||
-DFLB_EXAMPLES=Off \ | ||
-DFLB_HTTP_SERVER=On \ | ||
|
@@ -198,6 +225,12 @@ | |
# Copy certificates | ||
COPY --from=builder /etc/ssl/certs /etc/ssl/certs | ||
|
||
# Copy vsomeip | ||
COPY --from=builder-vsomeip /usr/local/lib/libvsomeip* /usr/local/lib/ | ||
COPY --from=builder-vsomeip /usr/local/lib/cmake/vsomeip3/* /usr/local/lib/cmake/vsomeip3/ | ||
COPY --from=builder-vsomeip /usr/local/lib/pkgconfig/vsomeip3.pc /usr/local/lib/pkgconfig/ | ||
COPY --from=builder-vsomeip ./usr/local/include/vsomeip/. /usr/local/include/vsomeip/ | ||
|
||
Comment on lines
+228
to
+233
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. If we vendor the code in then it removes this brittle copying as the library should be packaged ideally statically or as a direct dependency, plus with all its dependencies identified. A |
||
# Finally the binaries as most likely to change | ||
COPY --from=builder /fluent-bit /fluent-bit | ||
|
||
|
@@ -262,6 +295,12 @@ | |
RUN rm -f /usr/bin/qemu-*-static | ||
COPY --from=builder /fluent-bit /fluent-bit | ||
|
||
# Copy vsomeip | ||
COPY --from=builder-vsomeip /usr/local/lib/libvsomeip* /usr/local/lib/ | ||
COPY --from=builder-vsomeip /usr/local/lib/cmake/vsomeip3/* /usr/local/lib/cmake/vsomeip3/ | ||
COPY --from=builder-vsomeip /usr/local/lib/pkgconfig/vsomeip3.pc /usr/local/lib/pkgconfig/ | ||
COPY --from=builder-vsomeip ./usr/local/include/vsomeip/. /usr/local/include/vsomeip/ | ||
|
||
EXPOSE 2020 | ||
|
||
# No entry point so we can just shell in | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
project(someipc CXX) | ||
|
||
find_package(vsomeip3 QUIET) | ||
|
||
if(NOT(vsomeip3_FOUND)) | ||
MESSAGE(STATUS "vsomeip not found disabling SOMEIP input plugin") | ||
set(FLB_IN_SOMEIP OFF PARENT_SCOPE) | ||
else() | ||
MESSAGE(DEBUG "Found vsomeip package. Adding in someip-c library.") | ||
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) | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
add_executable(someip_test_service test_service.c) | ||
target_link_libraries(someip_test_service PRIVATE someip-c) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* Fluent Bit | ||
* ========== | ||
* 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 <stdint.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
#include "someip_api.h" | ||
|
||
|
||
static const char* NAME = "Test Service"; | ||
static const uint16_t SERVICE_ID = 4; | ||
static const uint16_t INSTANCE_ID = 1; | ||
static const uint16_t METHOD_ID = 1; | ||
static const uint16_t EVENT_ID = 0x8000U; | ||
static const uint16_t EVENT_GROUP_ID = 1; | ||
|
||
static uint16_t client_id = 0; | ||
|
||
/* | ||
* Function to handle callback when a request is received. | ||
* @param request_ptr Pointer to the structure that has the request details. | ||
*/ | ||
void HandleRequest(void*, struct some_ip_request *request_ptr) { | ||
static const char* response = "This is the response to the request"; | ||
int ret = 0; | ||
if (request_ptr == NULL) { | ||
return; | ||
} | ||
printf("Received request (method = %d)\n", request_ptr->method_id); | ||
printf("Payload length = %ld\n", request_ptr->payload_len); | ||
|
||
/* Normal service would Parse the request and perform/initiate some actions on it*/ | ||
/* For this example just send back a canned response */ | ||
|
||
ret = someip_send_response(client_id, request_ptr->request_id.client_request_id, | ||
(void*)response, strlen(response)); | ||
if (ret != SOMEIP_RET_SUCCESS) { | ||
printf("Failed to send response: %d\n", ret); | ||
} | ||
} | ||
|
||
/* | ||
* Function to initialize the test service with the SOME/IP library. | ||
* @return 0 on success, -1 on failure. | ||
*/ | ||
int Initialize() { | ||
int ret = someip_initialize(NAME, &client_id); | ||
if (ret != SOMEIP_RET_SUCCESS) { | ||
printf("Failed to initialize SOME/IP: %d\n", ret); | ||
return -1; | ||
} | ||
|
||
/* Register Request Handler */ | ||
ret = someip_register_request_handler(client_id, SERVICE_ID, INSTANCE_ID, | ||
METHOD_ID, NULL, HandleRequest); | ||
|
||
if (ret != SOMEIP_RET_SUCCESS) { | ||
printf("Failed to register request handler: %d\n", ret); | ||
someip_shutdown(client_id); | ||
return -1; | ||
} | ||
|
||
/* Offer Event */ | ||
ret = someip_offer_event(client_id, SERVICE_ID, INSTANCE_ID, EVENT_ID, (uint16_t*)&EVENT_GROUP_ID, 1); | ||
if (ret != SOMEIP_RET_SUCCESS) { | ||
printf("Failed to Offer Event: %d\n", ret); | ||
someip_shutdown(client_id); | ||
return -1; | ||
} | ||
|
||
/* Offer Service */ | ||
ret = someip_offer_service(client_id, SERVICE_ID, INSTANCE_ID); | ||
if (ret != SOMEIP_RET_SUCCESS) { | ||
printf("Failed to Offer Service: %d\n", ret); | ||
someip_shutdown(client_id); | ||
return -1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void Teardown() { | ||
someip_shutdown(client_id); | ||
} | ||
|
||
void SendEvent(const int num) { | ||
const char* base_msg = "Event Number "; | ||
char buffer[128]; | ||
int ret = 0; | ||
strcpy(buffer, base_msg); | ||
sprintf(buffer + strlen(base_msg), "%d", num); | ||
|
||
printf("Sending event with message %s\n", buffer); | ||
|
||
ret = someip_send_event(client_id, SERVICE_ID, INSTANCE_ID, EVENT_ID, | ||
buffer, strlen(buffer)); | ||
if (ret != SOMEIP_RET_SUCCESS) { | ||
printf ("Failed to send event, %d\n", ret); | ||
} | ||
} | ||
|
||
|
||
int main() { | ||
int num_events = 10; | ||
if (Initialize() != 0) { | ||
return EXIT_FAILURE; | ||
} | ||
|
||
|
||
for (int i = 0; i <= num_events; ++i) { | ||
SendEvent(i); | ||
sleep(2); | ||
} | ||
|
||
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.
Are we doing static builds only and limiting this to just the components we want?
Why can't we use the Debian built versions?