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

Generated by: LCOV version 1.14