void Retrans::check_msg_received (Msg &in) { switch (in.get_type ()) { case COAP_TYPE_ACK : del (&in) ; break ; default : break ; } }
void Retrans::check_msg_sent (Msg &in) { switch (in.get_type ()) { case COAP_TYPE_CON : add (&in) ; break ; default : break ; } }
bool Casan::is_hello (Msg &m, long int &hlid) { bool found = false ; // a hello msg is NON POST if (m.get_type () == COAP_TYPE_NON && m.get_code () == COAP_CODE_POST) { m.reset_next_option () ; for (option *o = m.next_option () ; o != NULL ; o = m.next_option ()) { if (o->optcode () == option::MO_Uri_Query) { // we benefit from the added nul byte at the end of val if (sscanf ((const char *) o->optval ((int *) 0), CASAN_HELLO, &hlid) == 1) found = true ; } } } return found ; }
bool Casan::is_assoc (Msg &m, time_t &sttl, int &mtu) { bool found_ttl = false ; bool found_mtu = false ; if (m.get_type () == COAP_TYPE_CON && m.get_code () == COAP_CODE_POST) { m.reset_next_option () ; for (option *o = m.next_option () ; o != NULL ; o = m.next_option ()) { if (o->optcode () == option::MO_Uri_Query) { long int n ; // sscanf "%ld" waits for a long int // we benefit from the added nul byte at the end of val if (sscanf ((const char *) o->optval ((int *) 0), CASAN_ASSOC_TTL, &n) == 1) { DBG1 (BLUE ("TTL recv: ")) ; DBG1 (n) ; DBGLN0 () ; sttl = ((time_t) n) * 1000 ; found_ttl = true ; // continue, just in case there are other query strings } else if (sscanf ((const char *) o->optval ((int *) 0), CASAN_ASSOC_MTU, &n) == 1) { DBG1 (BLUE ("MTU recv: ")) ; DBG1 (n) ; DBGLN0 () ; mtu = n ; found_mtu = true ; // continue, just in case there are other query strings } else break ; } } } return found_ttl && found_mtu ; }