本文整理汇总了C++中Msg::recv方法的典型用法代码示例。如果您正苦于以下问题:C++ Msg::recv方法的具体用法?C++ Msg::recv怎么用?C++ Msg::recv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Msg
的用法示例。
在下文中一共展示了Msg::recv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop
void Casan::loop ()
{
Msg in (l2_) ;
Msg out (l2_) ;
l2net::l2_recv_t ret ;
uint8_t oldstatus ;
long int hlid ;
l2addr *srcaddr ;
int mtu ; // mtu announced by master in assoc msg
oldstatus = status_ ; // keep old value for debug display
sync_time (curtime) ; // get current time
retrans_.loop (*l2_, curtime) ; // check needed retransmissions
srcaddr = NULL ;
ret = in.recv () ; // get received message
if (ret == l2net::RECV_OK)
srcaddr = l2_->get_src () ; // get a new address
switch (status_)
{
case SL_COLDSTART :
send_discover (out) ;
twait_.init (curtime) ;
status_ = SL_WAITING_UNKNOWN ;
break ;
case SL_WAITING_UNKNOWN :
if (ret == l2net::RECV_OK)
{
retrans_.check_msg_received (in) ;
if (is_ctl_msg (in))
{
if (is_hello (in, hlid))
{
DBGLN1 (F ("Received a CTL HELLO msg")) ;
change_master (hlid, -1) ; // don't change mtu
twait_.init (curtime) ;
status_ = SL_WAITING_KNOWN ;
}
else if (is_assoc (in, sttl_, mtu))
{
DBGLN1 (F ("Received a CTL ASSOC msg")) ;
change_master (-1, mtu) ; // "unknown" hlid
send_assoc_answer (in, out) ;
trenew_.init (curtime, sttl_) ;
status_ = SL_RUNNING ;
}
else DBGLN1 (F (RED ("Unkwnon CTL"))) ;
}
}
if (status_ == SL_WAITING_UNKNOWN && twait_.next (curtime))
send_discover (out) ;
break ;
case SL_WAITING_KNOWN :
if (ret == l2net::RECV_OK)
{
retrans_.check_msg_received (in) ;
if (is_ctl_msg (in))
{
if (is_hello (in, hlid))
{
DBGLN1 (F ("Received a CTL HELLO msg")) ;
change_master (hlid, -1) ; // don't change mtu
}
else if (is_assoc (in, sttl_, mtu))
{
DBGLN1 (F ("Received a CTL ASSOC msg")) ;
change_master (-1, mtu) ; // unknown hlid
send_assoc_answer (in, out) ;
trenew_.init (curtime, sttl_) ;
status_ = SL_RUNNING ;
}
else DBGLN1 (F (RED ("Unkwnon CTL"))) ;
}
}
if (status_ == SL_WAITING_KNOWN)
{
if (twait_.expired (curtime))
{
reset_master () ; // master_ is no longer known
send_discover (out) ;
twait_.init (curtime) ; // reset timer
status_ = SL_WAITING_UNKNOWN ;
}
else if (twait_.next (curtime))
{
send_discover (out) ;
}
}
break ;
//.........这里部分代码省略.........