LCOV - code coverage report
Current view: top level - asiolink - io_endpoint.cc (source / functions) Hit Total Coverage
Test: report.info Lines: 14 14 100.0 %
Date: 2012-05-15 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 20 80.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
       2                 :            : //
       3                 :            : // Permission to use, copy, modify, and/or distribute this software for any
       4                 :            : // purpose with or without fee is hereby granted, provided that the above
       5                 :            : // copyright notice and this permission notice appear in all copies.
       6                 :            : //
       7                 :            : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
       8                 :            : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
       9                 :            : // AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
      10                 :            : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      11                 :            : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
      12                 :            : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      13                 :            : // PERFORMANCE OF THIS SOFTWARE.
      14                 :            : 
      15                 :            : #include <config.h>
      16                 :            : 
      17                 :            : #include <unistd.h>             // for some IPC/network system calls
      18                 :            : #include <sys/socket.h>
      19                 :            : #include <netinet/in.h>
      20                 :            : 
      21                 :            : #include <asio.hpp>
      22                 :            : 
      23                 :            : #include <asiolink/io_address.h>
      24                 :            : #include <asiolink/io_error.h>
      25                 :            : #include <asiolink/io_endpoint.h>
      26                 :            : #include <asiolink/tcp_endpoint.h>
      27                 :            : #include <asiolink/udp_endpoint.h>
      28                 :            : 
      29                 :            : using namespace std;
      30                 :            : 
      31                 :            : namespace isc {
      32                 :            : namespace asiolink {
      33                 :            : 
      34                 :            : const IOEndpoint*
      35                 :        202 : IOEndpoint::create(const int protocol, const IOAddress& address,
      36                 :            :                    const unsigned short port)
      37                 :            : {
      38         [ +  + ]:        202 :     if (protocol == IPPROTO_UDP) {
      39                 :        312 :         return (new UDPEndpoint(address, port));
      40         [ +  + ]:         46 :     } else if (protocol == IPPROTO_TCP) {
      41                 :         90 :         return (new TCPEndpoint(address, port));
      42                 :            :     }
      43 [ +  - ][ +  - ]:        203 :     isc_throw(IOError,
      44                 :            :               "IOEndpoint creation attempt for unsupported protocol: " <<
      45                 :            :               protocol);
      46                 :            : }
      47                 :            : 
      48                 :            : bool
      49                 :        536 : IOEndpoint::operator==(const IOEndpoint& other) const {
      50                 :        536 :     return (getProtocol() == other.getProtocol() &&
      51                 :        280 :             getPort() == other.getPort() &&
      52                 :        152 :             getFamily() == other.getFamily() &&
      53   [ +  +  +  +  :       1056 :             getAddress() == other.getAddress());
           +  + ][ +  + ]
      54                 :            : }
      55                 :            : 
      56                 :            : bool
      57                 :        256 : IOEndpoint::operator!=(const IOEndpoint& other) const {
      58                 :        256 :     return (!operator==(other));
      59                 :            : }
      60                 :            : 
      61                 :            : } // namespace asiolink
      62 [ +  - ][ +  - ]:         30 : } // namespace isc

Generated by: LCOV version 1.9