本文整理汇总了C++中meta_message_ptr::port方法的典型用法代码示例。如果您正苦于以下问题:C++ meta_message_ptr::port方法的具体用法?C++ meta_message_ptr::port怎么用?C++ meta_message_ptr::port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta_message_ptr
的用法示例。
在下文中一共展示了meta_message_ptr::port方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sac_process_message
/**
* Check if there's a handler for this message and call it, else
* discard message.
*
* @param in The input message.
* @param out The output message.
*/
bool sac_process_message(meta_message_ptr& in, meta_message_ptr& out)
{
// discard messages that this MIHF broadcasted to itself
// discard messages that are not destined to this MIHF or if
// multicast messages are not supported
if(in->source() == mihfid) {
ODTONE_LOG(1, "(sac) Discarding message! Reason: ",
"message was broadcasted to itself");
return false;
}
if(!utils::this_mihf_is_destination(in) && !utils::is_multicast(in)) {
ODTONE_LOG(1, "(sac) Discarding message! Reason: ",
"this is not the message destination");
return false;
}
/** __no__ authentication at this point */
uint mid = in->mid();
//
// no thread safety because insertion should __only__ be made
// on MIHF initialization
//
std::map<uint, handler_t>::iterator it;
it = _callbacks.find(mid);
if(it != _callbacks.end()) {
handler_t process_message = it->second;
bool rsp;
try {
rsp = process_message(in, out);
} catch(mih::bad_tlv) {
ODTONE_LOG(1, "Discarding malformed message.");
return false;
}
// set ip and port of response message
out->ip(in->ip());
out->scope(in->scope());
out->port(in->port());
// response message must have the same tid
out->tid(in->tid());
return rsp;
} else {
ODTONE_LOG(1, "(sac) (warning) message with mid: ", mid,
" unknown, discarding.");
}
return false;
}
示例2: sac_process_message
bool sac_process_message(meta_message_ptr& in, meta_message_ptr& out)
{
// discard messages that this MIHF broadcasted to itself
if (in->source() == mihfid)
return false;
/** __no__ authentication at this point */
uint mid = in->mid();
//
// no thread safety because insertion should __only__ be made
// on MIHF initialization
//
std::map<uint, handler_t>::iterator it;
it = _callbacks.find(mid);
if(it != _callbacks.end()) {
handler_t process_message = it->second;
bool rsp = process_message(in, out);
// set ip and port of response message
out->ip(in->ip());
out->port(in->port());
// response message must have the same tid
out->tid(in->tid());
return rsp;
} else {
log(1, "(sac) (warning) message with mid: ", mid,
" unknown, discarding.");
}
return false;
}
示例3: get_capabilities
/**
* Parse all capabilities from MIH Capability Discover message and stores
* them.
*
* @param in input message.
* @param out output message.
*/
void service_management::get_capabilities(meta_message_ptr& in,
meta_message_ptr& out)
{
address_entry mihf_info;
mihf_info.ip = in->ip();
mihf_info.port = in->port();
if(in->opcode() == mih::operation::request) {
*in >> mih::request(mih::request::capability_discover)
& mih::tlv_net_type_addr_list(mihf_info.capabilities_list_net_type_addr)
& mih::tlv_event_list(mihf_info.capabilities_event_list)
& mih::tlv_command_list(mihf_info.capabilities_cmd_list)
& mih::tlv_query_type_list(mihf_info.capabilities_query_type)
& mih::tlv_transport_option_list(mihf_info.capabilities_trans_list)
& mih::tlv_mbb_ho_supp_list(mihf_info.capabilities_mbb_ho_supp);
} else if(in->opcode() == mih::operation::response) {
示例4: ack_responder
/**
* Run Acknowledge Responder State Machine transaction.
*/
void ack_responder()
{
switch(ack_rsp_state)
{
case ACK_RSP_INIT:
goto _rsp_init_lbl_;
case ACK_RSP_RETURN_ACK:
goto _rsp_return_ack_lbl_;
case ACK_RSP_PIGGYBACKING:
goto _rsp_piggybacking_lbl_;
case ACK_RSP_RETURN_DUPLICATE:
goto _rsp_return_duplicate_lbl_;
}
_rsp_init_lbl_:
{
ack->ackreq(false);
ack->ackrsp(true);
ack->opcode((mih::operation::type)opcode);
ack->tid(tid);
ack->mid(in->mid());
ack->source(my_mihf_id);
ack->destination(peer_mihf_id);
ack->ip(in->ip());
ack->port(in->port());
if (msg_out_avail)
goto _rsp_piggybacking_lbl_;
else
{
_netsap.send(ack);
msg_in_avail = false;
goto _rsp_return_ack_lbl_;
}
return;
}
_rsp_return_ack_lbl_:
{
ack_rsp_state = ACK_RSP_RETURN_ACK;
if(msg_in_avail)
{
_netsap.send(ack);
msg_in_avail = false;
}
else if (msg_out_avail)
goto _rsp_piggybacking_lbl_;
return;
}
_rsp_piggybacking_lbl_:
{
ack_rsp_state = ACK_RSP_PIGGYBACKING;
out->ackrsp(true);
dup = out;
if (msg_in_avail)
goto _rsp_return_duplicate_lbl_;
return;
}
_rsp_return_duplicate_lbl_:
{
ack_rsp_state = ACK_RSP_RETURN_DUPLICATE;
if (msg_in_avail) {
_netsap.send(dup);
msg_in_avail = false;
}
}
}