LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/sandesh/library/cpp - sandesh_util.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 14 30 46.7 %
Date: 2026-08-03 02:19:58 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : //
       6             : // sandesh_util.cc
       7             : //
       8             : 
       9             : #include <boost/tokenizer.hpp>
      10             : 
      11             : #include <base/string_util.h>
      12             : #include <base/address_util.h>
      13             : 
      14             : #include "sandesh_util.h"
      15             : 
      16             : using boost::asio::ip::address;
      17             : 
      18          54 : bool MakeEndpoint(TcpServer::Endpoint* ep, const std::string& epstr) {
      19             :     typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
      20          54 :     boost::char_separator<char> sep(":");
      21             : 
      22          54 :     tokenizer tokens(epstr, sep);
      23          54 :     tokenizer::iterator it = tokens.begin();
      24          54 :     std::string sip(*it);
      25          54 :     ++it;
      26          54 :     std::string sport(*it);
      27             :     int port;
      28          54 :     stringToInteger(sport, port);
      29          54 :     boost::system::error_code ec;
      30          54 :     address addr = AddressFromString(sip, &ec);
      31          54 :     if (ec) {
      32           0 :         return false;
      33             :     }
      34          54 :     *ep = TcpServer::Endpoint(addr, port);
      35          54 :     return true;
      36          54 : }
      37             : 
      38           0 : bool MakeEndpoint(UdpServer::Endpoint* ep, const std::string& epstr) {
      39             :     typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
      40           0 :     boost::char_separator<char> sep(":");
      41             : 
      42           0 :     tokenizer tokens(epstr, sep);
      43           0 :     tokenizer::iterator it = tokens.begin();
      44           0 :     std::string sip(*it);
      45           0 :     ++it;
      46           0 :     std::string sport(*it);
      47             :     int port;
      48           0 :     stringToInteger(sport, port);
      49           0 :     boost::system::error_code ec;
      50           0 :     address addr = AddressFromString(sip, &ec);
      51           0 :     if (ec) {
      52           0 :         return false;
      53             :     }
      54           0 :     *ep = UdpServer::Endpoint(addr, port);
      55           0 :     return true;
      56           0 : }

Generated by: LCOV version 1.14