FreeNOS
NetSend.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __BIN_NETSEND_NETSEND_H
19 #define __BIN_NETSEND_NETSEND_H
20 
21 #include <NetworkClient.h>
22 #include <NetworkQueue.h>
23 #include <POSIXApplication.h>
24 
33 class NetSend : public POSIXApplication
34 {
35  private:
36 
38  static const Size PacketSize = 1448;
39 
42 
43  public:
44 
51  NetSend(int argc,
52  char **argv);
53 
57  virtual ~NetSend();
58 
64  virtual Result initialize();
65 
71  virtual Result exec();
72 
73  private:
74 
84  Result udpSendMultiple(const struct iovec *vec,
85  const Size count,
86  const struct sockaddr & addr) const;
87 
88  private:
89 
92 
94  int m_socket;
95 };
96 
101 #endif /* __BIN_NETSEND_NETSEND_H */
NetSend::m_client
NetworkClient * m_client
Network client.
Definition: NetSend.h:91
NetSend::m_socket
int m_socket
UDP socket.
Definition: NetSend.h:94
NetworkQueue::MaxPackets
static const Size MaxPackets
Maximum number of packets available.
Definition: NetworkQueue.h:45
NetSend::NetSend
NetSend(int argc, char **argv)
Class constructor.
Definition: NetSend.cpp:27
POSIXApplication
POSIX-compatible application.
Definition: POSIXApplication.h:35
NetworkQueue.h
sockaddr
Defines a socket address and port pair.
Definition: socket.h:35
POSIXApplication.h
NetSend
Diagnostic program for sending network packets.
Definition: NetSend.h:33
NetSend::udpSendMultiple
Result udpSendMultiple(const struct iovec *vec, const Size count, const struct sockaddr &addr) const
Send multiple UDP packets.
Definition: NetSend.cpp:125
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
Application::Result
Result
Result codes.
Definition: Application.h:53
NetSend::initialize
virtual Result initialize()
Initialize the application.
Definition: NetSend.cpp:41
NetworkClient
Networking Client implementation.
Definition: NetworkClient.h:44
iovec
Input/Output vector for multi-packet operations.
Definition: socket.h:44
NetSend::PacketSize
static const Size PacketSize
Size of each packet to send in bytes.
Definition: NetSend.h:38
NetSend::QueueSize
static const Size QueueSize
Number of packets to submit for transmission each iteration.
Definition: NetSend.h:41
NetSend::exec
virtual Result exec()
Execute the application event loop.
Definition: NetSend.cpp:81
NetworkClient.h
NetSend::~NetSend
virtual ~NetSend()
Class destructor.
Definition: NetSend.cpp:37