void average_pkt_jitter(int src, int dst, int application){ if (otg_info->rx_jitter_sample[src][dst][application] > 0 ) { otg_info->rx_jitter_avg[src][dst][application]/= otg_info->rx_jitter_sample[src][dst][application]; otg_info->rx_jitter_avg_e2e[src][dst][application]/= otg_info->rx_jitter_sample[src][dst][application]; } else { LOG_T(OTG,"[src %d][dst %d][app %d]number of samples for jitter calculation is %d\n",src, dst, application, otg_info->rx_jitter_sample[src][dst][application]); } if (otg_info->rx_jitter_avg[src][dst][application] > 0) { if (src<NB_eNB_INST) otg_info->average_jitter_dl+=otg_info->rx_jitter_avg[src][dst][application]; else otg_info->average_jitter_ul+=otg_info->rx_jitter_avg[src][dst][application]; LOG_T(OTG,"average_jitter_dl %lf average_jitter_ul %lf \n",otg_info->average_jitter_dl,otg_info->average_jitter_ul ); } if (otg_info->rx_jitter_avg_e2e[src][dst][application] > 0) { if (src<NB_eNB_INST) otg_info->average_jitter_dl_e2e+=otg_info->rx_jitter_avg_e2e[src][dst][application]; else otg_info->average_jitter_ul_e2e+=otg_info->rx_jitter_avg_e2e[src][dst][application]; LOG_T(OTG,"average_jitter_dl %lf average_jitter_ul %lf \n",otg_info->average_jitter_dl_e2e,otg_info->average_jitter_ul_e2e); } }
void tsender<STREAM>::set_send_handler(const tsend_handler& send_handler__) { LOG_T(__PRETTY_FUNCTION__, ".\n"); send_handler_ = send_handler__; }
void tsender<STREAM>::send_queue_message() { LOG_T(__PRETTY_FUNCTION__ , ": id »", messages_.front().id() , "« data »", messages_.front().contents() , "«.\n"); std::ostream os(&send_buffer_); os << messages_.front().encode(connection_.get_protocol()); typedef std::function<void( const boost::system::error_code& , const size_t bytes_transferred )> thandler; auto functor = [&](thandler&& handler) { boost::asio::async_write( stream_ , send_buffer_ , handler); }; connection_.strand_execute( functor , std::bind( &tsender::send_queue_message_handler , this , std::placeholders::_1 , std::placeholders::_2)); }
int main(int argc, char **argv) { char * g_log_level="trace"; // by default global log level is set to trace //initialize the log generator logInit(map_str_to_int(level_names, g_log_level)); LOG_T(LOG,"global log level is set to %s \n",g_log_level ); at_parse_init(at_null_callback_handler, mt_null_attach_state_request_handler, mt_null_attach_request_handler, mt_null_detach_request_handler); printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); at_parse_string("AT+CGATT=?\r"); printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); at_parse_string("AT+CGATT?\r"); printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); at_parse_string("AT+CGATT?\r"); printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); at_parse_string("AT+CGATT?\r"); printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); at_parse_string("AT+CGATT?\r"); printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); at_parse_string("AT+CGATT=1\r"); printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); at_parse_string("AT+CGATT=0\r"); printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); return(0); }
// 不同的线程,会调用这个接口 void HTTPConnectionManager::newRequest(void* req, std::string uri, std::string content) { HTTPReply m_reply; // 取出对端的IP ev_uint16_t port; char *addr = NULL; evhttp_connection_get_peer(((evhttp_request*)req)->evcon, &addr , &port); char address[20]; strcpy(address, addr); m_requestHandler->handleRequest(address, uri, content, m_reply); //if(m_reply.status == > 0) // 如果是request处理好了,就回复 { struct evbuffer *buf = evbuffer_new(); evbuffer_add_printf(buf, "%s", m_reply.m_content.c_str()); evhttp_add_header(evhttp_request_get_output_headers((evhttp_request*)req), "Connection", "close"); evhttp_add_header(evhttp_request_get_output_headers((evhttp_request*)req), \ m_reply.m_headers[0].m_name.c_str(), m_reply.m_headers[0].m_value.c_str()); evhttp_send_reply((evhttp_request*)req, HTTP_OK, "OK", buf); evbuffer_free(buf); LOG_T("<== [" << m_reply.m_content << "]"); } }
int main(int argc, char *argv[]) { LOG("this is first log|%d|%#x|",10,123); LOG_T("this is log_t"); LOG_TT("this is log_tt"); return 0; }
//----------------------------------------------------------------------------- tbs_size_t mac_rlc_serialize_tb (char* buffer_pP, list_t transport_blocksP) { //----------------------------------------------------------------------------- mem_block_t *tb_p; tbs_size_t tbs_size; tbs_size_t tb_size; tbs_size = 0; while (transport_blocksP.nb_elements > 0) { tb_p = list_remove_head (&transport_blocksP); if (tb_p != NULL) { tb_size = ((struct mac_tb_req *) (tb_p->data))->tb_size; #ifdef DEBUG_MAC_INTERFACE #if defined(TRACE_RLC_PAYLOAD) LOG_T(RLC, "[MAC-RLC] DUMP TX PDU(%d bytes):\n", tb_size); rlc_util_print_hex_octets(RLC, ((struct mac_tb_req *) (tb_p->data))->data_ptr, tb_size); #endif #endif memcpy(&buffer_pP[tbs_size], &((struct mac_tb_req *) (tb_p->data))->data_ptr[0], tb_size); tbs_size = tbs_size + tb_size; free_mem_block(tb_p); } } return tbs_size; }
int Directory::createIfNotExists() { if( c_check_cache >= 0 ) { LOG_T() << "step over check; using cache result..."; return c_check_cache; // we already checked this directory, return cached result } LOG_I() << "check directory " << c_directory.string(); if( fs::exists( c_directory ) == false ) { LOG_I() << "does not exists, try to create it..."; if( fs::create_directories( c_directory ) ) { LOG_I() << "directory successful created"; c_check_cache = 0; c_is_valid = true; } else { LOG_E() << "could not create directory :-( Abort!"; c_check_cache = 1; } } else if( fs::is_directory( c_directory ) == false ) { LOG_E() << "The given directory ( " << c_directory.string() << " ) is not a directory! Abort!"; c_check_cache = 4; } else { c_check_cache = 0; c_is_valid = true; } return c_check_cache; }
//----------------------------------------------------------------------------- void rlc_um_reassembly (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP, uint8_t * src_pP, int32_t lengthP) { //----------------------------------------------------------------------------- sdu_size_t sdu_max_size; LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY] reassembly() %d bytes %d bytes already reassemblied\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), lengthP, rlc_pP->output_sdu_size_to_write); if (lengthP <= 0) { return; } if ((rlc_pP->is_data_plane)) { sdu_max_size = RLC_SDU_MAX_SIZE_DATA_PLANE; } else { sdu_max_size = RLC_SDU_MAX_SIZE_CONTROL_PLANE; } if (rlc_pP->output_sdu_in_construction == NULL) { // msg("[RLC_UM_LITE] Getting mem_block ...\n"); rlc_pP->output_sdu_in_construction = get_free_mem_block (sdu_max_size); rlc_pP->output_sdu_size_to_write = 0; } if ((rlc_pP->output_sdu_in_construction)) { // check if no overflow in size if ((rlc_pP->output_sdu_size_to_write + lengthP) <= sdu_max_size) { memcpy (&rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write], src_pP, lengthP); rlc_pP->output_sdu_size_to_write += lengthP; #ifdef TRACE_RLC_UM_DISPLAY_ASCII_DATA rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write] = 0; LOG_T(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY] DATA :", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_util_print_hex_octets(RLC, (unsigned char*)rlc_pP->output_sdu_in_construction->data, rlc_pP->output_sdu_size_to_write); #endif } else { #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) AssertFatal(0, PROTOCOL_RLC_UM_CTXT_FMT" RLC_UM_DATA_IND, SDU TOO BIG, DROPPED\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY] [max_sdu size %d] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), sdu_max_size); // erase SDU rlc_pP->output_sdu_size_to_write = 0; } } else { LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[REASSEMBLY]ERROR OUTPUT SDU IS NULL\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); #if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) AssertFatal(0, PROTOCOL_RLC_UM_CTXT_FMT" RLC_UM_DATA_IND, SDU DROPPED, OUT OF MEMORY\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); #endif } }
int main( int argc , char* argv[]) { LOG_T("ECHO" , "start"); tcode::io::engine e; tcode::io::ip::raw::socket lfd(e); fd = &lfd; if (fd->open( AF_PACKET , SOCK_RAW , htons(0x0003))){ LOG_T( "arp" , "socket open success" ); fd->read( tcode::io::buffer( buffer , 1024 ) , &read_raw ); e.run(); } return 0; }
void tstrand::strand_disable() { LOG_T(__PRETTY_FUNCTION__, ".\n"); delete_strand(); own_strand_ = nullptr; }
void tstrand::strand_enable(boost::asio::io_service::strand& strand__) { LOG_T(__PRETTY_FUNCTION__, ".\n"); delete_strand(); strand_ = &strand__; }
void tstrand::strand_enable(boost::asio::io_service& io_service) { LOG_T(__PRETTY_FUNCTION__, ".\n"); delete_strand(); strand_ = new boost::asio::io_service::strand(io_service); own_strand_ = true; }
/* * Prints binary representation of given octet prepending * passed log message * * @param Octet as an unsigned character * @return None */ void util_print_binary_representation(unsigned char* message, u8_t octet) { unsigned char index = 0; unsigned char mask = 0x80; LOG_T(PDCP, "%s", message); for (index = 0; index < 8; ++index) { if (octet & mask) { LOG_T(PDCP, "1"); } else { LOG_T(PDCP, "0"); } mask /= 2; } LOG_T(PDCP, "\n"); }
tmessage::tmessage(const tprotocol protocol, const std::string& encoded_message) : type_(ttype::reply) /* Notification. */ , id_(0) , contents_() { LOG_T(__PRETTY_FUNCTION__, ": encoded_message »", encoded_message, "«.\n"); switch(protocol) { case tprotocol::direct : contents_ = encoded_message; break; case tprotocol::line : contents_ = encoded_message.substr(0, encoded_message.size() - 1); break; case tprotocol::telnet : contents_ = encoded_message.substr(0, encoded_message.size() - 2); break; case tprotocol::basic : if(encoded_message.size() < 5) { throw lib::texception( lib::texception::ttype::protocol_error , lib::concatenate( "A basic message is too small for its header." , " The size is »" , encoded_message.size() , "«")); } switch(encoded_message[0]) { case 'A' : type_ = ttype::action; break; case 'R' : type_ = ttype::reply; break; default: throw lib::texception( lib::texception::ttype::invalid_value , lib::concatenate( "Found unexpected message type »" , encoded_message[0] , "«")); } id_ = network_buffer_to_host(&encoded_message[1]); contents_ = encoded_message.substr(5); break; case tprotocol::compressed : NOT_IMPLEMENTED_YET; break; } }
void tstrand::delete_strand() { LOG_T(__PRETTY_FUNCTION__, ".\n"); if(own_strand_) { delete strand_; own_strand_ = false; } }
//----------------------------------------------------------------------------- void rlc_am_reassembly (u8_t * srcP, s32_t lengthP, rlc_am_entity_t *rlcP, u32_t frame) //----------------------------------------------------------------------------- { #ifdef TRACE_RLC_AM_DISPLAY_HEX_DATA int index; #endif #ifdef TRACE_RLC_AM_REASSEMBLY LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PAYLOAD] reassembly() %d bytes\n", frame, rlcP->module_id, rlcP->rb_id, lengthP); #endif if (rlcP->output_sdu_in_construction == NULL) { rlcP->output_sdu_in_construction = get_free_mem_block (RLC_SDU_MAX_SIZE); rlcP->output_sdu_size_to_write = 0; assert(rlcP->output_sdu_in_construction != NULL); } if (rlcP->output_sdu_in_construction != NULL) { #ifdef TRACE_RLC_AM_DISPLAY_HEX_DATA LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PAYLOAD] DATA :", frame, rlcP->module_id, rlcP->rb_id); for (index = 0; index < lengthP; index++) { LOG_T(RLC, "%02X.", srcP[index]); } msg ("\n"); #endif // check if no overflow in size if ((rlcP->output_sdu_size_to_write + lengthP) <= RLC_SDU_MAX_SIZE) { memcpy (&rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write], srcP, lengthP); #ifdef TRACE_RLC_AM_DISPLAY_ASCII_DATA rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write + lengthP] = 0; LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PAYLOAD] DATA :", frame, rlcP->module_id, rlcP->rb_id); LOG_T(RLC, "%s\n", &rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write]); #endif rlcP->output_sdu_size_to_write += lengthP; } else { LOG_E(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PAYLOAD] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", frame, rlcP->module_id, rlcP->rb_id); // erase SDU rlcP->output_sdu_size_to_write = 0; } } else { LOG_E(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PAYLOAD] ERROR OUTPUT SDU IS NULL\n", frame, rlcP->module_id, rlcP->rb_id); } }
/* this function must be called each time before size and itd are generated for the respective packet. it updates the input samples stored in the structure stream, ps: calling it more often than for each packet is also fine input: - the stream to be updated output: */ void tarmaUpdateInputSample (tarmaStream_t *stream){ int cnt; LOG_T(OTG,"TARMA_DEBUG: tarmaUpdateInputSample(%p)\n", stream); if(stream){ for(cnt=0; cnt<TARMA_NUM_PROCESSES; cnt++){ stream->tarma_input_samples[cnt]=gaussian_dist(10000,1)-10000; LOG_D(OTG,"TARMA_DEBUG: %f\n",stream->tarma_input_samples[cnt]); } } }
void tsession_reaper::wait_handler(const boost::system::error_code& error) { LOG_T(__PRETTY_FUNCTION__, ": error »", error.message(), "«.\n"); if(error != boost::asio::error::operation_aborted) { LOG_I("Session reaper: run.\n"); reap(); run(); } }
//----------------------------------------------------------------------------- void rlc_um_send_sdu (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP) { //----------------------------------------------------------------------------- if ((rlc_pP->output_sdu_in_construction)) { LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" SEND_SDU to upper layers %d bytes sdu %p\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP), rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); if (rlc_pP->output_sdu_size_to_write > 0) { rlc_pP->stat_rx_pdcp_sdu += 1; rlc_pP->stat_rx_pdcp_bytes += rlc_pP->output_sdu_size_to_write; MSC_LOG_TX_MESSAGE( (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE, (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, (const char*)(rlc_pP->output_sdu_in_construction->data), rlc_pP->output_sdu_size_to_write, MSC_AS_TIME_FMT" "PROTOCOL_RLC_UM_MSC_FMT" DATA-IND size %u", MSC_AS_TIME_ARGS(ctxt_pP), PROTOCOL_RLC_UM_MSC_ARGS(ctxt_pP,rlc_pP), rlc_pP->output_sdu_size_to_write ); #ifdef TEST_RLC_UM #ifdef TRACE_RLC_UM_DISPLAY_ASCII_DATA rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write] = 0; LOG_T(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[SEND_SDU] DATA :", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); rlc_util_print_hex_octets(RLC, rlc_pP->output_sdu_in_construction->data, rlc_pP->output_sdu_size_to_write); #endif rlc_um_v9_3_0_test_data_ind (rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); #else // msg("[RLC] DATA IND ON MOD_ID %d RB ID %d, size %d\n",rlc_pP->module_id, rlc_pP->rb_id, ctxt_pP->frame,rlc_pP->output_sdu_size_to_write); rlc_data_ind ( ctxt_pP, BOOL_NOT(rlc_pP->is_data_plane), rlc_pP->is_mxch, rlc_pP->rb_id, rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); #endif rlc_pP->output_sdu_in_construction = NULL; } else { LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT"[SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP)); } rlc_pP->output_sdu_size_to_write = 0; } }
int olg_config(char * g_log_level) { //initialize the log generator logInit(map_str_to_int(log_level_names, g_log_level)); set_glog(LOG_DEBUG, LOG_MED); //g_glog set_comp_log(OCG, LOG_INFO, LOG_LOW, 10); set_comp_log(OMG, LOG_INFO, LOG_LOW, 10); set_comp_log(EMU, LOG_INFO, LOG_LOW, 10); LOG_T(LOG,"global log level is set to %s \n",g_log_level ); return 1; }
/* * Prints incoming byte stream in hexadecimal and readable form * * @param component Utilised as with macros defined in UTIL/LOG/log.h * @param data unsigned char* pointer for data buffer * @param size Number of octets in data buffer * @return none */ void util_print_hex_octets(comp_name_t component, unsigned char* data, unsigned long size) { if (data == NULL) { LOG_W(component, "Incoming buffer is NULL! Ignoring...\n"); return; } unsigned long octet_index = 0; LOG_D(component, " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); LOG_D(component, "-----+-------------------------------------------------|\n"); LOG_T(component, " 000 |"); for (octet_index = 0; octet_index < size; ++octet_index) { /* * Print every single octet in hexadecimal form */ LOG_T(component, " %02x", data[octet_index]); /* * Align newline and pipes according to the octets in groups of 2 */ if (octet_index != 0 && (octet_index + 1) % 16 == 0) { LOG_T(component, " |\n"); LOG_T(component, " %03d |", octet_index); } } /* * Append enough spaces and put final pipe */ unsigned char index; for (index = octet_index; index < 16; ++index) LOG_T(component, " "); LOG_T(component, " |\n"); }
void tsession_reaper::run() { LOG_T(__PRETTY_FUNCTION__, ".\n"); timer_.expires_from_now(boost::posix_time::seconds( tconfiguration::configuration().reap_interval)); timer_.async_wait(std::bind( &tsession_reaper::wait_handler , this , std::placeholders::_1)); }
void tsender<STREAM>::send_reply(const uint32_t id, const std::string& message) { LOG_T(__PRETTY_FUNCTION__ , ": id »", id , "« message »", message , "«.\n"); connection_.strand_execute(std::bind( &tsender::send_message , this , tmessage(tmessage::ttype::reply, id, message))); }
//----------------------------------------------------------------------------- struct mac_data_ind mac_rlc_deserialize_tb ( char *buffer_pP, const tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcs_pP) { //----------------------------------------------------------------------------- struct mac_data_ind data_ind; mem_block_t* tb_p; num_tb_t nb_tb_read; tbs_size_t tbs_size; nb_tb_read = 0; tbs_size = 0; list_init(&data_ind.data, NULL); while (num_tbP > 0) { tb_p = get_free_mem_block(sizeof (mac_rlc_max_rx_header_size_t) + tb_sizeP); if (tb_p != NULL) { ((struct mac_tb_ind *) (tb_p->data))->first_bit = 0; ((struct mac_tb_ind *) (tb_p->data))->data_ptr = (uint8_t*)&tb_p->data[sizeof (mac_rlc_max_rx_header_size_t)]; ((struct mac_tb_ind *) (tb_p->data))->size = tb_sizeP; if (crcs_pP) { ((struct mac_tb_ind *) (tb_p->data))->error_indication = crcs_pP[nb_tb_read]; } else { ((struct mac_tb_ind *) (tb_p->data))->error_indication = 0; } memcpy(((struct mac_tb_ind *) (tb_p->data))->data_ptr, &buffer_pP[tbs_size], tb_sizeP); #ifdef DEBUG_MAC_INTERFACE #if defined(TRACE_RLC_PAYLOAD) LOG_T(RLC, "[MAC-RLC] DUMP RX PDU(%d bytes):\n", tb_sizeP); rlc_util_print_hex_octets(RLC, ((struct mac_tb_ind *) (tb_p->data))->data_ptr, tb_sizeP); #endif #endif nb_tb_read = nb_tb_read + 1; tbs_size = tbs_size + tb_sizeP; list_add_tail_eurecom(tb_p, &data_ind.data); } num_tbP = num_tbP - 1; } data_ind.no_tb = nb_tb_read; data_ind.tb_size = tb_sizeP << 3; return data_ind; }
void tsender<STREAM>::send_message(tmessage message) { LOG_T(__PRETTY_FUNCTION__ , ": id »", message.id() , "« message »", message.contents() , "«.\n"); const bool sending = !messages_.empty(); messages_.push_back(std::move(message)); if(!sending) { send_queue_message(); } }
void tsession_reaper::reap() { LOG_T(__PRETTY_FUNCTION__, ".\n"); auto itor = sessions_.begin(); while(itor != sessions_.end()) { if(itor->get_status() == tsession::tstatus::reapable) { LOG_D("Session reaper: reaping.\n"); itor = sessions_.erase(itor); } else { ++itor; } } }
uint32_t tsender<STREAM>::send_action(const std::string& message) { LOG_T(__PRETTY_FUNCTION__, ": message »", message, "«.\n"); uint32_t id__; while((id__ = ++id_) == 0) { /* NOTHING */ } connection_.strand_execute(std::bind( &tsender::send_message , this , tmessage(tmessage::ttype::action, id__, message))); return id__; }
std::string tmessage::encode(const tprotocol protocol) const { LOG_T(__PRETTY_FUNCTION__, ": protocol »", protocol, "«.\n"); std::string result; switch(protocol) { case tprotocol::direct : break; case tprotocol::line : result = contents_ + '\n'; break; case tprotocol::telnet : result = contents_ + "\r\n"; break; case tprotocol::basic : switch(type_) { case tmessage::ttype::action : result = "A" + host_to_network_string(id_) + contents_; break; case tmessage::ttype::reply : result = "R" + host_to_network_string(id_) + contents_; break; } // if(data.size() > max - 4) .. result = host_to_network_string( static_cast<uint32_t>(result.size())) + result; break; case tprotocol::compressed : NOT_IMPLEMENTED_YET; break; } return result; }
void tsender<STREAM>::send_queue_message_handler( const boost::system::error_code& error , const size_t bytes_transferred) { LOG_T(__PRETTY_FUNCTION__ , ": error »", error.message() , "« bytes_transferred »", bytes_transferred , "«.\n"); total_bytes_transferred_ += bytes_transferred; if(send_handler_) { send_handler_(error, bytes_transferred, messages_.front()); } messages_.pop_front(); if(!messages_.empty()) { send_queue_message(); } }