1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright (C) 2014-2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef VSOMEIP_INTERNAL_UDP_SERVICE_IMPL_HPP
#define VSOMEIP_INTERNAL_UDP_SERVICE_IMPL_HPP
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/udp.hpp>
#include <vsomeip/defines.hpp>
#include "server_endpoint_impl.hpp"
namespace vsomeip {
typedef server_endpoint_impl<boost::asio::ip::udp,
VSOMEIP_MAX_UDP_MESSAGE_SIZE> udp_server_endpoint_base_impl;
class udp_server_endpoint_impl: public udp_server_endpoint_base_impl {
public:
udp_server_endpoint_impl(std::shared_ptr<endpoint_host> _host,
endpoint_type _local,
boost::asio::io_service &_io);
virtual ~udp_server_endpoint_impl();
void start();
void stop();
void restart();
void receive();
bool send_to(const std::shared_ptr<endpoint_definition> _target,
const byte_t *_data, uint32_t _size, bool _flush);
void send_queued(queue_iterator_type _queue_iterator);
endpoint_type get_remote() const;
bool get_remote_address(boost::asio::ip::address &_address) const;
bool get_multicast(service_t _service, event_t _event,
endpoint_type &_target) const;
void join(const std::string &_address);
void leave(const std::string &_address);
void add_multicast(service_t _service, instance_t _instance,
const std::string &_address, uint16_t _port);
void remove_multicast(service_t _service, instance_t _instance);
unsigned short get_local_port() const;
bool is_local() const;
client_t get_client(std::shared_ptr<endpoint_definition> _endpoint);
public:
void receive_cbk(boost::system::error_code const &_error,
std::size_t _size);
private:
void set_broadcast();
private:
socket_type socket_;
endpoint_type remote_;
std::map<service_t, std::map<instance_t, endpoint_type> > multicasts_;
receive_buffer_t recv_buffer_;
size_t recv_buffer_size_;
std::mutex stop_mutex_;
};
} // namespace vsomeip
#endif // VSOMEIP_INTERNAL_UDP_SERVICE_IMPL_HPP
|