Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
845b9831
Commit
845b9831
authored
Jan 14, 2021
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use datagram handle to lookup remote UDP addresses
parent
e0c8ff16
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
9 deletions
+25
-9
libcaf_io/caf/io/datagram_servant.hpp
libcaf_io/caf/io/datagram_servant.hpp
+8
-6
libcaf_io/caf/io/network/datagram_servant_impl.hpp
libcaf_io/caf/io/network/datagram_servant_impl.hpp
+4
-2
libcaf_io/src/io/abstract_broker.cpp
libcaf_io/src/io/abstract_broker.cpp
+2
-1
libcaf_io/src/io/network/datagram_servant_impl.cpp
libcaf_io/src/io/network/datagram_servant_impl.cpp
+8
-0
libcaf_io/src/io/network/test_multiplexer.cpp
libcaf_io/src/io/network/test_multiplexer.cpp
+3
-0
No files found.
libcaf_io/caf/io/datagram_servant.hpp
View file @
845b9831
...
@@ -22,12 +22,12 @@
...
@@ -22,12 +22,12 @@
#include "caf/message.hpp"
#include "caf/message.hpp"
#include "caf/io/datagram_handle.hpp"
#include "caf/io/broker_servant.hpp"
#include "caf/io/broker_servant.hpp"
#include "caf/io/system_messages.hpp"
#include "caf/io/datagram_handle.hpp"
#include "caf/io/network/ip_endpoint.hpp"
#include "caf/io/network/datagram_manager.hpp"
#include "caf/io/network/datagram_manager.hpp"
#include "caf/io/network/ip_endpoint.hpp"
#include "caf/io/network/receive_buffer.hpp"
#include "caf/io/network/receive_buffer.hpp"
#include "caf/io/system_messages.hpp"
namespace
caf
{
namespace
caf
{
namespace
io
{
namespace
io
{
...
@@ -62,13 +62,16 @@ public:
...
@@ -62,13 +62,16 @@ public:
/// Returns the local port of associated socket.
/// Returns the local port of associated socket.
virtual
uint16_t
local_port
()
const
=
0
;
virtual
uint16_t
local_port
()
const
=
0
;
/// Returns the address of the remote endpoint for the handle.
virtual
std
::
string
remote_addr
(
datagram_handle
)
const
=
0
;
/// Returns all the handles associated with this servant
/// Returns all the handles associated with this servant
virtual
std
::
vector
<
datagram_handle
>
hdls
()
const
=
0
;
virtual
std
::
vector
<
datagram_handle
>
hdls
()
const
=
0
;
/// Adds a new remote endpoint identified by the `ip_endpoint` to
/// Adds a new remote endpoint identified by the `ip_endpoint` to
/// the related manager.
/// the related manager.
virtual
void
add_endpoint
(
const
network
::
ip_endpoint
&
ep
,
virtual
void
add_endpoint
(
const
network
::
ip_endpoint
&
ep
,
datagram_handle
hdl
)
datagram_handle
hdl
)
=
0
;
=
0
;
virtual
void
remove_endpoint
(
datagram_handle
hdl
)
=
0
;
virtual
void
remove_endpoint
(
datagram_handle
hdl
)
=
0
;
...
@@ -96,4 +99,3 @@ using datagram_servant_ptr = intrusive_ptr<datagram_servant>;
...
@@ -96,4 +99,3 @@ using datagram_servant_ptr = intrusive_ptr<datagram_servant>;
// Allows the `middleman_actor` to create an `datagram_servant` and then send it
// Allows the `middleman_actor` to create an `datagram_servant` and then send it
// to the BASP broker.
// to the BASP broker.
CAF_ALLOW_UNSAFE_MESSAGE_TYPE
(
caf
::
io
::
datagram_servant_ptr
)
CAF_ALLOW_UNSAFE_MESSAGE_TYPE
(
caf
::
io
::
datagram_servant_ptr
)
libcaf_io/caf/io/network/datagram_servant_impl.hpp
View file @
845b9831
...
@@ -18,11 +18,11 @@
...
@@ -18,11 +18,11 @@
#pragma once
#pragma once
#include "caf/io/fwd.hpp"
#include "caf/io/datagram_servant.hpp"
#include "caf/io/datagram_servant.hpp"
#include "caf/io/fwd.hpp"
#include "caf/io/network/native_socket.hpp"
#include "caf/io/network/datagram_handler_impl.hpp"
#include "caf/io/network/datagram_handler_impl.hpp"
#include "caf/io/network/native_socket.hpp"
#include "caf/policy/udp.hpp"
#include "caf/policy/udp.hpp"
...
@@ -52,6 +52,8 @@ public:
...
@@ -52,6 +52,8 @@ public:
void
flush
()
override
;
void
flush
()
override
;
std
::
string
remote_addr
(
datagram_handle
hdl
)
const
override
;
std
::
string
addr
()
const
override
;
std
::
string
addr
()
const
override
;
uint16_t
port
(
datagram_handle
hdl
)
const
override
;
uint16_t
port
(
datagram_handle
hdl
)
const
override
;
...
...
libcaf_io/src/io/abstract_broker.cpp
View file @
845b9831
...
@@ -320,7 +320,8 @@ datagram_handle abstract_broker::datagram_hdl_by_port(uint16_t port) {
...
@@ -320,7 +320,8 @@ datagram_handle abstract_broker::datagram_hdl_by_port(uint16_t port) {
std
::
string
abstract_broker
::
remote_addr
(
datagram_handle
hdl
)
{
std
::
string
abstract_broker
::
remote_addr
(
datagram_handle
hdl
)
{
auto
i
=
datagram_servants_
.
find
(
hdl
);
auto
i
=
datagram_servants_
.
find
(
hdl
);
return
i
!=
datagram_servants_
.
end
()
?
i
->
second
->
addr
()
:
std
::
string
{};
return
i
!=
datagram_servants_
.
end
()
?
i
->
second
->
remote_addr
(
hdl
)
:
std
::
string
{};
}
}
uint16_t
abstract_broker
::
remote_port
(
datagram_handle
hdl
)
{
uint16_t
abstract_broker
::
remote_port
(
datagram_handle
hdl
)
{
...
...
libcaf_io/src/io/network/datagram_servant_impl.cpp
View file @
845b9831
...
@@ -94,6 +94,14 @@ std::string datagram_servant_impl::addr() const {
...
@@ -94,6 +94,14 @@ std::string datagram_servant_impl::addr() const {
return
*
x
;
return
*
x
;
}
}
std
::
string
datagram_servant_impl
::
remote_addr
(
datagram_handle
hdl
)
const
{
auto
&
eps
=
handler_
.
endpoints
();
auto
itr
=
eps
.
find
(
hdl
);
if
(
itr
==
eps
.
end
())
return
0
;
return
network
::
host
(
itr
->
second
);
}
uint16_t
datagram_servant_impl
::
port
(
datagram_handle
hdl
)
const
{
uint16_t
datagram_servant_impl
::
port
(
datagram_handle
hdl
)
const
{
auto
&
eps
=
handler_
.
endpoints
();
auto
&
eps
=
handler_
.
endpoints
();
auto
itr
=
eps
.
find
(
hdl
);
auto
itr
=
eps
.
find
(
hdl
);
...
...
libcaf_io/src/io/network/test_multiplexer.cpp
View file @
845b9831
...
@@ -373,6 +373,9 @@ datagram_servant_ptr test_multiplexer::new_datagram_servant(datagram_handle hdl,
...
@@ -373,6 +373,9 @@ datagram_servant_ptr test_multiplexer::new_datagram_servant(datagram_handle hdl,
void
flush
()
override
{
void
flush
()
override
{
// nop
// nop
}
}
std
::
string
remote_addr
(
datagram_handle
)
const
override
{
return
"test"
;
}
std
::
string
addr
()
const
override
{
std
::
string
addr
()
const
override
{
return
"test"
;
return
"test"
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment