Commit bf227239 authored by Joseph Noir's avatar Joseph Noir

Udp handshake received, not answered

parent f6fbd101
......@@ -102,7 +102,9 @@ inline bool operator!=(const header& lhs, const header& rhs) {
/// Checks whether given header contains a handshake.
inline bool is_handshake(const header& hdr) {
return hdr.operation == message_type::server_handshake
|| hdr.operation == message_type::client_handshake;
|| hdr.operation == message_type::client_handshake
|| hdr.operation == message_type::udp_client_handshake
|| hdr.operation == message_type::udp_server_handshake;
}
/// Checks wheter given header contains a heartbeat.
......
......@@ -69,6 +69,10 @@ enum class message_type : uint8_t {
///
/// ![](heartbeat.png)
heartbeat = 0x05,
// TODO: udp handshakes
udp_client_handshake = 0x06,
udp_server_handshake = 0x07
};
/// @relates message_type
......
......@@ -597,7 +597,11 @@ behavior basp_broker::make_behavior() {
<< CAF_ARG(msg.handle));
ctx.callback->deliver(make_error(sec::disconnect_during_handshake));
}
// TODO: some error?
} else {
if (ctx.callback) {
// TODO: if callback available, handle that
}
// TODO: Is there configuration necessary?
// configure_datagram_size(...);
}
......@@ -693,9 +697,11 @@ behavior basp_broker::make_behavior() {
// flush(msg.handle);
// TODO: is this right?
},
/*
[=](const dgram_delegate_msg&) {
std::cerr << "[BB] Received new delegate message" << std::endl;
CAF_LOG_TRACE(CAF_ARG(msg.handle));
},
*/
// received from underlying broker implementation
[=](const dgram_scribe_closed_msg& msg) {
CAF_LOG_TRACE(CAF_ARG(msg.handle));
......@@ -709,12 +715,6 @@ behavior basp_broker::make_behavior() {
CAF_ASSERT(nid == none
|| !state.instance.tbl().reachable(nid));
},
// received from underlying broker implementation
[=](const dgram_acceptor_closed_msg& msg) {
CAF_LOG_TRACE(CAF_ARG(msg.handle));
auto port = local_port(msg.handle);
state.instance.remove_published_actor(port);
},
[=](const dgram_doorman_closed_msg& msg) {
CAF_LOG_TRACE(CAF_ARG(msg.handle));
std::cerr << "[BB] Received dgram_doorman_closed_msg" << std::endl;
......@@ -777,7 +777,8 @@ behavior basp_broker::make_behavior() {
[=](connect_atom, dgram_scribe_handle hdl,
const std::string& host, uint16_t port) {
CAF_LOG_TRACE(CAF_ARG(hdl.id()));
std::cerr << "[BB] connect for dgram to " << host << ":" << port << std::endl;
std::cerr << "[BB] \"connect\" for dgram to "
<< host << ":" << port << std::endl;
auto rp = make_response_promise();
auto res = assign_dgram_scribe(hdl, host, port);
if (res) {
......@@ -786,8 +787,8 @@ behavior basp_broker::make_behavior() {
ctx.remote_port = port;
ctx.callback = rp;
auto& bi = state.instance;
//bi.write_server_handshake(context(), wr_buf(hdl), port);
//bi.write_client_handshake(context(), wr_buf(hdl), local_port(hdl));
// bi.write_server_handshake(context(), wr_buf(hdl), port);
// bi.write_client_handshake(context(), wr_buf(hdl), local_port(hdl));
bi.write_udp_client_handshake(context(), wr_buf(hdl));
flush(hdl);
configure_datagram_size(hdl, 1500);
......
......@@ -58,7 +58,7 @@ bool dgram_doorman::delegate_msg(execution_unit* ctx,
CAF_LOG_TRACE(CAF_ARG(endpoint) << CAF_ARG(num_bytes));
if (detached())
return false;
using delegate_t = dgram_delegate_msg;
using delegate_t = new_datagram_msg; // dgram_delegate_msg;
using tmp_t = mailbox_element_vals<delegate_t>;
auto guard = parent_;
auto& buf = rd_buf();
......@@ -68,7 +68,7 @@ bool dgram_doorman::delegate_msg(execution_unit* ctx,
// msg_buf.resize(num_bytes);
tmp_t tmp{strong_actor_ptr{}, message_id::make(),
mailbox_element::forwarding_stack{},
delegate_t{hdl(), endpoint, std::move(buf)}};
delegate_t{endpoint, std::move(buf)}};
invoke_mailbox_element_impl(ctx,tmp);
return true;
}
......
......@@ -87,6 +87,22 @@ bool client_handshake_valid(const header& hdr) {
&& zero(hdr.operation_data);
}
bool udp_server_handshake_valid(const header& hdr) {
return valid(hdr.source_node)
&& valid(hdr.dest_node)
&& hdr.source_node != hdr.dest_node
&& zero(hdr.source_actor)
&& zero(hdr.dest_actor)
&& zero(hdr.operation_data);
}
bool udp_client_handshake_valid(const header& hdr) {
return valid(hdr.source_node)
&& !valid(hdr.dest_node)
&& zero(hdr.dest_actor)
&& !zero(hdr.operation_data);
}
bool dispatch_message_valid(const header& hdr) {
return valid(hdr.dest_node)
&& (!zero(hdr.dest_actor) || hdr.has(header::named_receiver_flag))
......@@ -141,6 +157,10 @@ bool valid(const header& hdr) {
return kill_proxy_instance_valid(hdr);
case message_type::heartbeat:
return heartbeat_valid(hdr);
case message_type::udp_server_handshake:
return udp_server_handshake_valid(hdr);
case message_type::udp_client_handshake:
return udp_client_handshake_valid(hdr);
}
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment