LCOV - code coverage report
Current view: top level - libs/bsw/cpp2someip/include/someip - SdMessageBuilder.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-09-11 12:05:06 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /********************************************************************************
       2              :  * Copyright (c) 2026 Accenture
       3              :  *
       4              :  * This program and the accompanying materials are made available under the
       5              :  * terms of the Apache License Version 2.0 which is available at
       6              :  * https://www.apache.org/licenses/LICENSE-2.0
       7              :  *
       8              :  * SPDX-License-Identifier: Apache-2.0
       9              :  ********************************************************************************/
      10              : 
      11              : #pragma once
      12              : 
      13              : #include <ip/IPEndpoint.h>
      14              : 
      15              : #include "someip/SomeIpConstants.h"
      16              : #include <etl/span.h>
      17              : #include <etl/vector.h>
      18              : 
      19              : namespace someip
      20              : {
      21              : enum class SdMessageReturnCode : uint8_t
      22              : {
      23              :     SD_MESSAGE_OK,
      24              :     SD_MESSAGE_BUFFER_TOO_SMALL, // provided buffer is too small to fit even a shortest message
      25              :     SD_MESSAGE_NOT_ENOUGH_SPACE, // not enough free space left
      26              :     SD_MESSAGE_INVALID_ADDRESS,  // IP address is unspecified / broken
      27              :     SD_MESSAGE_IS_FULL           // no more space for another entry / option
      28              : };
      29              : 
      30              : namespace internal
      31              : {
      32              : struct Message final
      33              : {
      34           47 :     Message()  = default;
      35              :     ~Message() = default;
      36              : 
      37              :     ::etl::span<uint8_t> data;
      38              :     size_t divider = 0U; // ...a delimiter between entries section and options section
      39              : };
      40              : } // namespace internal
      41              : 
      42              : class SdMessageBuilder final
      43              : {
      44              : public:
      45           47 :     SdMessageBuilder()  = default;
      46              :     ~SdMessageBuilder() = default;
      47              : 
      48              :     SdMessageReturnCode startMessage(::etl::span<uint8_t> const& buffer);
      49              : 
      50              :     SdMessageReturnCode addFind(
      51              :         service_id::type,
      52              :         instance_id::type,
      53              :         major_version::type,
      54              :         minor_version::type,
      55              :         ttl::type ttl);
      56              : 
      57              :     SdMessageReturnCode addOffer(
      58              :         service_id::type,
      59              :         instance_id::type,
      60              :         major_version::type,
      61              :         minor_version::type,
      62              :         ttl::type,
      63              :         ::ip::IPAddress const&,
      64              :         port::type,
      65              :         proto::type);
      66              : 
      67              :     SdMessageReturnCode addDenounce(
      68              :         service_id::type,
      69              :         instance_id::type,
      70              :         major_version::type,
      71              :         minor_version::type,
      72              :         ttl::type,
      73              :         ::ip::IPAddress const&,
      74              :         port::type,
      75              :         proto::type);
      76              : 
      77              :     SdMessageReturnCode addFindEventgroup(
      78              :         service_id::type, instance_id::type, eventgroup_id::type, major_version::type, ttl::type);
      79              : 
      80              :     SdMessageReturnCode addPublish(
      81              :         service_id::type,
      82              :         instance_id::type,
      83              :         eventgroup_id::type,
      84              :         major_version::type,
      85              :         ttl::type,
      86              :         ::ip::IPAddress const&,
      87              :         port::type,
      88              :         proto::type);
      89              : 
      90              :     SdMessageReturnCode addUnpublish(
      91              :         service_id::type,
      92              :         instance_id::type,
      93              :         eventgroup_id::type,
      94              :         major_version::type,
      95              :         ttl::type,
      96              :         ::ip::IPAddress const&,
      97              :         port::type,
      98              :         proto::type);
      99              : 
     100              :     SdMessageReturnCode addSubscribe(
     101              :         service_id::type,
     102              :         instance_id::type,
     103              :         eventgroup_id::type,
     104              :         major_version::type,
     105              :         ttl::type,
     106              :         ::ip::IPAddress const&,
     107              :         port::type,
     108              :         proto::type);
     109              : 
     110              :     SdMessageReturnCode addUnsubscribe(
     111              :         service_id::type,
     112              :         instance_id::type,
     113              :         eventgroup_id::type,
     114              :         major_version::type,
     115              :         ttl::type,
     116              :         ::ip::IPAddress const&,
     117              :         port::type,
     118              :         proto::type);
     119              : 
     120              :     SdMessageReturnCode addSubscribeAck(
     121              :         service_id::type,
     122              :         instance_id::type,
     123              :         eventgroup_id::type,
     124              :         major_version::type,
     125              :         minor_version::type,
     126              :         ttl::type);
     127              : 
     128              :     SdMessageReturnCode addSubscribeNack(
     129              :         service_id::type,
     130              :         instance_id::type,
     131              :         eventgroup_id::type,
     132              :         major_version::type,
     133              :         minor_version::type,
     134              :         ttl::type);
     135              : 
     136              :     SdMessageReturnCode addSubscribeAckMulticast(
     137              :         service_id::type,
     138              :         instance_id::type,
     139              :         eventgroup_id::type,
     140              :         major_version::type,
     141              :         minor_version::type,
     142              :         ttl::type,
     143              :         ::ip::IPAddress const&,
     144              :         port::type,
     145              :         proto::type);
     146              : 
     147              :     ::etl::span<uint8_t const> finishMessage(uint16_t sessionId, bool reboot);
     148              :     void discardMessage();
     149              :     bool isEmpty() const;
     150              : 
     151              : private:
     152              :     internal::Message _message;
     153              : };
     154              : 
     155              : } // namespace someip
        

Generated by: LCOV version 2.0-1