w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RethBuf.hpp
Go to the documentation of this file.
1// $Id: RethBuf.hpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2017-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2018-12-22 1091 1.0.1 Dump() not longer virtual (-Wnon-virtual-dtor fix)
8// 2017-04-17 880 1.0 Initial version
9// 2017-02-12 850 0.1 First draft
10// ---------------------------------------------------------------------------
11
12
17#ifndef included_Retro_RethBuf
18#define included_Retro_RethBuf 1
19
20#include <memory>
21#include <string>
22
23#include "librtools/Rtime.hpp"
24
25namespace Retro {
26
27 class RethBuf {
28 public:
29 typedef std::shared_ptr<RethBuf> pbuf_t;
30
31 RethBuf();
32 ~RethBuf();
33
34 void Clear();
35 void SetSize(uint16_t size);
36 void SetTime();
37 void SetTime(const Rtime& time);
38
39 uint16_t Size() const;
40 const Rtime& Time() const;
41
42 const uint8_t* Buf8() const;
43 const uint16_t* Buf16() const;
44 const uint32_t* Buf32() const;
45
46 uint8_t* Buf8();
47 uint16_t* Buf16();
48 uint32_t* Buf32();
49
50 void SetMacDestination(uint64_t mac);
51 void SetMacSource(uint64_t mac);
52
53 uint64_t MacDestination() const;
54 uint64_t MacSource() const;
55 uint16_t Type() const;
56 bool IsMcast() const;
57 bool IsBcast() const;
58
59 ssize_t Read(int fd);
60 ssize_t Write(int fd) const;
61
62 std::string FrameInfo() const;
63
64 void Dump(std::ostream& os, int ind=0, const char* text=0,
65 int detail=0) const;
66
67 // some constants
68 static const size_t kMaxSize = 1514;
69 static const size_t kMinSize = 60;
70 static const size_t kCrcSize = 4;
71 static const size_t kWOffDstMac = 0;
72 static const size_t kWOffSrcMac = 3;
73 static const size_t kWOffTyp = 6;
74
75 protected:
77 uint16_t fSize;
79 };
80
81} // end namespace Retro
82
83#include "RethBuf.ipp"
84
85#endif
FIXME_docs.
Definition: RethBuf.hpp:27
void SetTime()
FIXME_docs.
Definition: RethBuf.ipp:42
ssize_t Read(int fd)
FIXME_docs.
Definition: RethBuf.cpp:71
bool IsMcast() const
FIXME_docs.
Definition: RethBuf.ipp:158
~RethBuf()
Destructor.
Definition: RethBuf.cpp:57
static const size_t kCrcSize
size of ethernet CRC
Definition: RethBuf.hpp:70
static const size_t kMinSize
min ethernet frame size
Definition: RethBuf.hpp:69
bool IsBcast() const
FIXME_docs.
Definition: RethBuf.ipp:166
void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Definition: RethBuf.cpp:102
static const size_t kWOffTyp
offset type in 16 bit wrds
Definition: RethBuf.hpp:73
RethBuf()
Default constructor.
Definition: RethBuf.cpp:50
void SetMacSource(uint64_t mac)
FIXME_docs.
Definition: RethBuf.ipp:133
const uint8_t * Buf8() const
FIXME_docs.
Definition: RethBuf.ipp:76
uint8_t fBuf[kMaxSize+kCrcSize]
Definition: RethBuf.hpp:78
void SetMacDestination(uint64_t mac)
FIXME_docs.
Definition: RethBuf.ipp:124
uint64_t MacDestination() const
FIXME_docs.
Definition: RethBuf.ipp:142
uint64_t MacSource() const
FIXME_docs.
Definition: RethBuf.ipp:150
static const size_t kWOffDstMac
offset dst mac in 16 bit wrds
Definition: RethBuf.hpp:71
static const size_t kWOffSrcMac
offset src mac in 16 bit wrds
Definition: RethBuf.hpp:72
static const size_t kMaxSize
max ethernet frame size
Definition: RethBuf.hpp:68
const uint16_t * Buf16() const
FIXME_docs.
Definition: RethBuf.ipp:84
std::shared_ptr< RethBuf > pbuf_t
Definition: RethBuf.hpp:29
std::string FrameInfo() const
FIXME_docs.
Definition: RethBuf.cpp:89
void SetSize(uint16_t size)
FIXME_docs.
Definition: RethBuf.ipp:33
uint16_t Size() const
FIXME_docs.
Definition: RethBuf.ipp:60
void Clear()
FIXME_docs.
Definition: RethBuf.ipp:24
const uint32_t * Buf32() const
FIXME_docs.
Definition: RethBuf.ipp:92
ssize_t Write(int fd) const
FIXME_docs.
Definition: RethBuf.cpp:81
uint16_t fSize
Definition: RethBuf.hpp:77
uint16_t Type() const
FIXME_docs.
Definition: RethBuf.cpp:63
const Rtime & Time() const
FIXME_docs.
Definition: RethBuf.ipp:68
FIXME_docs.
Definition: Rtime.hpp:25
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47