LCOV - code coverage report
Current view: top level - src/jamidht/swarm - swarm_protocol.h (source / functions) Coverage Total Hit
Test: jami-coverage-filtered.info Lines: 100.0 % 4 4
Test Date: 2026-06-13 09:18:46 Functions: 100.0 % 8 8

            Line data    Source code
       1              : /*
       2              :  *  Copyright (C) 2004-2026 Savoir-faire Linux Inc.
       3              :  *
       4              :  *  This program is free software: you can redistribute it and/or modify
       5              :  *  it under the terms of the GNU General Public License as published by
       6              :  *  the Free Software Foundation, either version 3 of the License, or
       7              :  *  (at your option) any later version.
       8              :  *
       9              :  *  This program is distributed in the hope that it will be useful,
      10              :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      11              :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      12              :  *  GNU General Public License for more details.
      13              :  *
      14              :  *  You should have received a copy of the GNU General Public License
      15              :  *  along with this program. If not, see <https://www.gnu.org/licenses/>.
      16              :  */
      17              : #pragma once
      18              : 
      19              : #include <string>
      20              : #include <string_view>
      21              : #include <msgpack.hpp>
      22              : 
      23              : #include <opendht/infohash.h>
      24              : 
      25              : using namespace std::literals;
      26              : using NodeId = dht::h256;
      27              : 
      28              : namespace jami {
      29              : 
      30              : namespace swarm_protocol {
      31              : 
      32              : static constexpr int version = 1;
      33              : 
      34              : enum class Query : uint8_t { FIND = 1, FOUND = 2 };
      35              : 
      36              : using NodeId = dht::PkId;
      37              : 
      38              : struct Request
      39              : {
      40              :     Query q; // Type of query
      41              :     int num; // Number of nodes
      42              :     NodeId nodeId;
      43         2585 :     MSGPACK_DEFINE_MAP(q, num, nodeId);
      44              : };
      45              : 
      46              : struct Response
      47              : {
      48              :     Query q;
      49              :     std::vector<NodeId> nodes;
      50              :     std::vector<NodeId> mobile_nodes;
      51              : 
      52         2555 :     MSGPACK_DEFINE_MAP(q, nodes, mobile_nodes);
      53              : };
      54              : 
      55              : struct Message
      56              : {
      57              :     int v = version;
      58              :     bool is_mobile {false};
      59              :     std::optional<Request> request;
      60              :     std::optional<Response> response;
      61         5145 :     MSGPACK_DEFINE_MAP(v, is_mobile, request, response);
      62              : };
      63              : 
      64              : }; // namespace swarm_protocol
      65              : 
      66              : } // namespace jami
      67         7673 : MSGPACK_ADD_ENUM(jami::swarm_protocol::Query);
        

Generated by: LCOV version 2.0-1