LCOV - code coverage report
Current view: top level - src/net/raw - RawIPSocket.hpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 2 2 100.0 %
Date: 2025-04-27 01:14:20 Functions: 2 4 50.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            : ** Copyright (C) 2023 Sylvain Fargier
       3                 :            : **
       4                 :            : ** This software is provided 'as-is', without any express or implied
       5                 :            : ** warranty.  In no event will the authors be held liable for any damages
       6                 :            : ** arising from the use of this software.
       7                 :            : **
       8                 :            : ** Permission is granted to anyone to use this software for any purpose,
       9                 :            : ** including commercial applications, and to alter it and redistribute it
      10                 :            : ** freely, subject to the following restrictions:
      11                 :            : **
      12                 :            : ** 1. The origin of this software must not be misrepresented; you must not
      13                 :            : **    claim that you wrote the original software. If you use this software
      14                 :            : **    in a product, an acknowledgment in the product documentation would be
      15                 :            : **    appreciated but is not required.
      16                 :            : ** 2. Altered source versions must be plainly marked as such, and must not be
      17                 :            : **    misrepresented as being the original software.
      18                 :            : ** 3. This notice may not be removed or altered from any source distribution.
      19                 :            : **
      20                 :            : ** Created on: 2023-12-21T17:55:46
      21                 :            : ** Author: Sylvain Fargier <fargier.sylvain@gmail.com>
      22                 :            : */
      23                 :            : 
      24                 :            : #ifndef RAWIPSOCKET_HPP__
      25                 :            : #define RAWIPSOCKET_HPP__
      26                 :            : 
      27                 :            : #include "../Socket.hpp"
      28                 :            : #include "RawIPMessage.hpp"
      29                 :            : 
      30                 :            : namespace ccut {
      31                 :            : namespace net {
      32                 :            : 
      33                 :            : /**
      34                 :            :  * @brief raw socket for IPv4 communication
      35                 :            :  * @details providing a protocol is required to receive messages, Protocol::RAW
      36                 :            :  * makes the socket write only (see man-page raw(7)).
      37                 :            :  *
      38                 :            :  */
      39                 :            : class RawIPv4Socket : public Socket<RawIPv4Message>
      40                 :            : {
      41                 :            : public:
      42                 :            :     explicit RawIPv4Socket(Protocol proto,
      43                 :            :                            const std::string &name = "IPv4Socket");
      44                 :          1 :     virtual ~RawIPv4Socket() = default;
      45                 :            : 
      46                 :            : protected:
      47                 :            :     /**
      48                 :            :      * @param v6 must be false
      49                 :            :      */
      50                 :            :     int makeSocket(bool v6 = false) override;
      51                 :            : 
      52                 :            :     Message processMessage(const address_t &from,
      53                 :            :                            const address_t &to,
      54                 :            :                            const cow_ptr<buffer_t> &buffer) override;
      55                 :            : 
      56                 :            :     const Protocol m_proto;
      57                 :            : };
      58                 :            : 
      59                 :            : /**
      60                 :            :  * @brief raw socket for IPv6 communication
      61                 :            :  *
      62                 :            :  */
      63                 :            : class RawIPv6Socket : public Socket<RawIPv6Message>
      64                 :            : {
      65                 :            : public:
      66                 :            :     explicit RawIPv6Socket(Protocol proto,
      67                 :            :                            const std::string &name = "IPv6Socket");
      68                 :          1 :     virtual ~RawIPv6Socket() = default;
      69                 :            : 
      70                 :            : protected:
      71                 :            :     /**
      72                 :            :      * @param v6 must be false
      73                 :            :      */
      74                 :            :     int makeSocket(bool v6 = false) override;
      75                 :            : 
      76                 :            :     Message processMessage(const address_t &from,
      77                 :            :                            const address_t &to,
      78                 :            :                            const cow_ptr<buffer_t> &buffer) override;
      79                 :            : 
      80                 :            :     const Protocol m_proto;
      81                 :            : };
      82                 :            : 
      83                 :            : } // namespace net
      84                 :            : } // namespace ccut
      85                 :            : 
      86                 :            : #endif

Generated by: LCOV version 1.14