Autoware.Auto
udp_sender.hpp
Go to the documentation of this file.
1 // Copyright 2020 Silexica GmbH, Lichtstr. 25, Cologne, Germany. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef LIDAR_INTEGRATION__UDP_SENDER_HPP_
17 #define LIDAR_INTEGRATION__UDP_SENDER_HPP_
18 
20 #include <common/types.hpp>
21 
22 #include <stdint.h>
23 #include <netinet/in.h>
24 
27 
28 class LIDAR_INTEGRATION_PUBLIC UdpSenderBase
29 {
30 public:
32  const char8_t * const ip, const uint16_t port,
33  const bool8_t ipv6 = false);
34 
35 protected:
36  void send(const void * const data, const size_t length) const;
37 
38 private:
39  int m_socket;
40  struct sockaddr_in6 m_addr;
41 };
42 
43 template<typename Packet>
44 class UdpSender : public UdpSenderBase
45 {
46 public:
48 
49 public:
50  void send(Packet const & pkt) const
51  {
52  UdpSenderBase::send(static_cast<const void * const>(&pkt), sizeof(pkt));
53  }
54 };
55 
56 #endif // LIDAR_INTEGRATION__UDP_SENDER_HPP_
void send(Packet const &pkt) const
Definition: udp_sender.hpp:50
bool bool8_t
Definition: types.hpp:33
This file includes common type definition.
char char8_t
Definition: types.hpp:34
UdpSenderBase(const char8_t *const ip, const uint16_t port, const bool8_t ipv6=false)
Definition: udp_sender.cpp:27
void send(const void *const data, const size_t length) const
Definition: udp_sender.cpp:60
Definition: udp_sender.hpp:44
Definition: udp_sender.hpp:28