299 cursor_ascii = m_tmp_ascii_buffer; |
299 cursor_ascii = m_tmp_ascii_buffer; |
300 must_print = false; |
300 must_print = false; |
301 data_start = ind; |
301 data_start = ind; |
302 } |
302 } |
303 |
303 |
304 *cursor_ascii++ = static_cast<u8_t>((*data >= 0x20 && *data < 0x7f) ? *data : '.'); |
304 *cursor_ascii++ = (*data >= 0x20 && *data < 0x7f) ? *data : '.'; |
305 |
305 |
306 *cursor++ = octet_to_ascii(((*data) & 0xf0) >> 4); |
306 *cursor++ = octet_to_ascii(((*data) & 0xf0) >> 4); |
307 *cursor++ = octet_to_ascii(((*data) & 0x0f)); |
307 *cursor++ = octet_to_ascii(((*data) & 0x0f)); |
308 data++; |
308 data++; |
309 |
309 |
310 if ((ind > 0u |
310 if (ind > 0u |
311 && ((ind+1) % byte_group_size) == 0) |
311 && ((ind+1) % byte_group_size) == 0 |
312 || byte_group_size == 1ul) |
312 || byte_group_size == 1ul) |
313 { |
313 { |
314 *cursor++ = ' '; |
314 *cursor++ = ' '; |
315 } |
315 } |
316 |
316 |
443 #define EAP_TRACE_TIMER(object, flags, parameters) |
443 #define EAP_TRACE_TIMER(object, flags, parameters) |
444 #endif //#if defined(USE_EAP_TIMER_QUEUE_TRACE) |
444 #endif //#if defined(USE_EAP_TIMER_QUEUE_TRACE) |
445 |
445 |
446 EAP_FUNC_EXPORT eap_status_e eap_am_tools_c::timer_thread_function() |
446 EAP_FUNC_EXPORT eap_status_e eap_am_tools_c::timer_thread_function() |
447 { |
447 { |
448 EAP_TRACE_TIMER(this, TRACE_FLAGS_TIMER, (EAPL("TIMER: Timer thread starts.\n"))); |
448 EAP_TRACE_TIMER(this, TRACE_FLAGS_DEFAULT, (EAPL("TIMER: Timer thread starts.\n"))); |
449 |
449 |
450 u32_t static_sleep_time = get_timer_resolution_ms(); |
450 u32_t static_sleep_time = get_timer_resolution_ms(); |
451 u64_t start_time = get_clock_ticks(); |
451 u64_t start_time = get_clock_ticks(); |
452 u64_t current_time = start_time; |
452 u64_t current_time = start_time; |
453 u64_t virtual_time = 0u; |
453 u64_t virtual_time = 0u; |
460 u64_t end_time = 0u; |
460 u64_t end_time = 0u; |
461 |
461 |
462 // Note 64-bit casted to 32-bit. |
462 // Note 64-bit casted to 32-bit. |
463 EAP_TRACE_TIMER( |
463 EAP_TRACE_TIMER( |
464 this, |
464 this, |
465 TRACE_FLAGS_TIMER, (EAPL("TIMER: get_clock_ticks_of_second() = %lu\n"), |
465 TRACE_FLAGS_DEFAULT, (EAPL("TIMER: get_clock_ticks_of_second() = %lu\n"), |
466 static_cast<u32_t>(get_clock_ticks_of_second()))); |
466 static_cast<u32_t>(get_clock_ticks_of_second()))); |
467 |
467 |
468 hw_ticks_of_millisecond = get_clock_ticks_of_second(); |
468 hw_ticks_of_millisecond = get_clock_ticks_of_second(); |
469 hw_ticks_of_millisecond /= 1000u; |
469 hw_ticks_of_millisecond /= 1000u; |
470 |
470 |
486 u64_t delay_time = 0ul; |
486 u64_t delay_time = 0ul; |
487 |
487 |
488 |
488 |
489 EAP_TRACE_TIMER( |
489 EAP_TRACE_TIMER( |
490 this, |
490 this, |
491 TRACE_FLAGS_TIMER, |
491 TRACE_FLAGS_DEFAULT, |
492 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_enter(): begin\n"))); |
492 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_enter(): begin\n"))); |
493 |
493 |
494 mutex->mutex_enter(); |
494 mutex->mutex_enter(); |
495 |
495 |
496 EAP_TRACE_TIMER( |
496 EAP_TRACE_TIMER( |
497 this, |
497 this, |
498 TRACE_FLAGS_TIMER, |
498 TRACE_FLAGS_DEFAULT, |
499 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_enter(): end\n"))); |
499 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_enter(): end\n"))); |
500 |
500 |
501 while(get_is_timer_thread_active()) |
501 while(get_is_timer_thread_active()) |
502 { |
502 { |
503 bool timer_queue_is_empty = get_timer_queue_is_empty(); |
503 bool timer_queue_is_empty = get_timer_queue_is_empty(); |
504 |
504 |
505 current_sleep_time = next_sleep_time; |
505 current_sleep_time = next_sleep_time; |
506 |
506 |
507 EAP_TRACE_TIMER( |
507 EAP_TRACE_TIMER( |
508 this, |
508 this, |
509 TRACE_FLAGS_TIMER, |
509 TRACE_FLAGS_DEFAULT, |
510 (EAPL("TIMER: timer_sleep(): current_sleep_time=%d\n"), |
510 (EAPL("TIMER: timer_sleep(): current_sleep_time=%d\n"), |
511 static_cast<u32_t>(current_sleep_time))); |
511 static_cast<u32_t>(current_sleep_time))); |
512 |
512 |
513 // - - - - - - - - - - - - - - - - - - - - - - - - |
513 // - - - - - - - - - - - - - - - - - - - - - - - - |
514 begin_time = get_clock_ticks(); |
514 begin_time = get_clock_ticks(); |
515 |
515 |
516 EAP_TRACE_TIMER( |
516 EAP_TRACE_TIMER( |
517 this, |
517 this, |
518 TRACE_FLAGS_TIMER, |
518 TRACE_FLAGS_DEFAULT, |
519 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_leave(): begin\n"))); |
519 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_leave(): begin\n"))); |
520 |
520 |
521 mutex->mutex_leave(this); |
521 mutex->mutex_leave(this); |
522 |
522 |
523 EAP_TRACE_TIMER( |
523 EAP_TRACE_TIMER( |
524 this, |
524 this, |
525 TRACE_FLAGS_TIMER, |
525 TRACE_FLAGS_DEFAULT, |
526 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_leave(): end\n"))); |
526 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_leave(): end\n"))); |
527 |
527 |
528 // Sleep happens outside of the mutex. |
528 // Sleep happens outside of the mutex. |
529 timer_sleep(current_sleep_time); |
529 timer_sleep(current_sleep_time); |
530 |
530 |
531 EAP_TRACE_TIMER( |
531 EAP_TRACE_TIMER( |
532 this, |
532 this, |
533 TRACE_FLAGS_TIMER, |
533 TRACE_FLAGS_DEFAULT, |
534 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_enter(): begin\n"))); |
534 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_enter(): begin\n"))); |
535 |
535 |
536 mutex->mutex_enter(); |
536 mutex->mutex_enter(); |
537 |
537 |
538 EAP_TRACE_TIMER( |
538 EAP_TRACE_TIMER( |
539 this, |
539 this, |
540 TRACE_FLAGS_TIMER, |
540 TRACE_FLAGS_DEFAULT, |
541 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_enter(): end\n"))); |
541 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_enter(): end\n"))); |
542 |
542 |
543 end_time = get_clock_ticks(); |
543 end_time = get_clock_ticks(); |
544 // - - - - - - - - - - - - - - - - - - - - - - - - |
544 // - - - - - - - - - - - - - - - - - - - - - - - - |
545 |
545 |
566 if (get_is_timer_thread_active() == true |
566 if (get_is_timer_thread_active() == true |
567 && get_use_eap_milli_second_timer() == true) |
567 && get_use_eap_milli_second_timer() == true) |
568 { |
568 { |
569 EAP_TRACE_TIMER( |
569 EAP_TRACE_TIMER( |
570 this, |
570 this, |
571 TRACE_FLAGS_TIMER, |
571 TRACE_FLAGS_DEFAULT, |
572 (EAPL("TIMER: real_sleep_time=%d, delay_time=%d\n"), |
572 (EAPL("TIMER: real_sleep_time=%d, delay_time=%d\n"), |
573 static_cast<u32_t>(real_sleep_time), |
573 static_cast<u32_t>(real_sleep_time), |
574 static_cast<u32_t>(delay_time))); |
574 static_cast<u32_t>(delay_time))); |
575 |
575 |
576 next_sleep_time = pulse_timer(static_cast<u32_t>(real_sleep_time+delay_time)); |
576 next_sleep_time = pulse_timer(static_cast<u32_t>(real_sleep_time+delay_time)); |
607 virtual_time += real_sleep_time; |
607 virtual_time += real_sleep_time; |
608 |
608 |
609 |
609 |
610 EAP_TRACE_TIMER( |
610 EAP_TRACE_TIMER( |
611 this, |
611 this, |
612 TRACE_FLAGS_TIMER, |
612 TRACE_FLAGS_DEFAULT, |
613 (EAPL("TIMER: Timer thread pulse_timer, sleep time = %4d ms, real_sleep_time %4d ms, ") |
613 (EAPL("TIMER: Timer thread pulse_timer, sleep time = %4d ms, real_sleep_time %4d ms, ") |
614 EAPL("virtual_time %6d, real_time %6d, next_sleep_time %4d, delay_time %4d.\n"), |
614 EAPL("virtual_time %6d, real_time %6d, next_sleep_time %4d, delay_time %4d.\n"), |
615 current_sleep_time, |
615 current_sleep_time, |
616 static_cast<u32_t>(real_sleep_time), |
616 static_cast<u32_t>(real_sleep_time), |
617 static_cast<u32_t>(virtual_time), |
617 static_cast<u32_t>(virtual_time), |
621 |
621 |
622 } // while() |
622 } // while() |
623 |
623 |
624 EAP_TRACE_TIMER( |
624 EAP_TRACE_TIMER( |
625 this, |
625 this, |
626 TRACE_FLAGS_TIMER, |
626 TRACE_FLAGS_DEFAULT, |
627 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_leave(): begin\n"))); |
627 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_leave(): begin\n"))); |
628 |
628 |
629 mutex->mutex_leave(this); |
629 mutex->mutex_leave(this); |
630 |
630 |
631 EAP_TRACE_TIMER( |
631 EAP_TRACE_TIMER( |
632 this, |
632 this, |
633 TRACE_FLAGS_TIMER, |
633 TRACE_FLAGS_DEFAULT, |
634 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_leave(): end\n"))); |
634 (EAPL("MUTEX: eap_am_tools_c::timer_thread_function(): mutex_leave(): end\n"))); |
635 |
635 |
636 delete mutex; |
636 delete mutex; |
637 |
637 |
638 EAP_TRACE_TIMER(this, TRACE_FLAGS_TIMER, (EAPL("TIMER: Timer thread stops.\n"))); |
638 EAP_TRACE_TIMER(this, TRACE_FLAGS_DEFAULT, (EAPL("TIMER: Timer thread stops.\n"))); |
639 |
639 |
640 m_thread_stopped =true; |
640 m_thread_stopped =true; |
641 |
641 |
642 return eap_status_ok; |
642 return eap_status_ok; |
643 } |
643 } |
1062 // +-+-+-+-+-+-+-+-+-+-+ |
1062 // +-+-+-+-+-+-+-+-+-+-+ |
1063 // : : | : : : : : : : | |
1063 // : : | : : : : : : : | |
1064 // +-+-+-+-+-+-+-+-+-+-+ |
1064 // +-+-+-+-+-+-+-+-+-+-+ |
1065 */ |
1065 */ |
1066 value = octet_from_ascii_armor(source_byte); |
1066 value = octet_from_ascii_armor(source_byte); |
1067 target[*output_ind] = static_cast<u8_t>(target[*output_ind] | (value & 0x30) >> 4u); |
1067 target[*output_ind] |= (value & 0x30) >> 4u; |
1068 ++(*output_ind); |
1068 ++(*output_ind); |
1069 if (last_input_byte == false) |
1069 if (last_input_byte == false) |
1070 { |
1070 { |
1071 target[*output_ind] = static_cast<u8_t>((value & 0x0f) << 4u); |
1071 target[*output_ind] = static_cast<u8_t>((value & 0x0f) << 4u); |
1072 *missing_bit_count = 4u; |
1072 *missing_bit_count = 4u; |
1096 // +-+-+-+-+-+-+-+-+-+-+-+-+ |
1096 // +-+-+-+-+-+-+-+-+-+-+-+-+ |
1097 // : : : : | : : : : : : : | |
1097 // : : : : | : : : : : : : | |
1098 // +-+-+-+-+-+-+-+-+-+-+-+-+ |
1098 // +-+-+-+-+-+-+-+-+-+-+-+-+ |
1099 */ |
1099 */ |
1100 value = octet_from_ascii_armor(source_byte); |
1100 value = octet_from_ascii_armor(source_byte); |
1101 target[*output_ind] = static_cast<u8_t>(target[*output_ind] | ((value >> 2u) & 0x0f)); |
1101 target[*output_ind] |= (value >> 2u) & 0x0f; |
1102 ++(*output_ind); |
1102 ++(*output_ind); |
1103 if (last_input_byte == false) |
1103 if (last_input_byte == false) |
1104 { |
1104 { |
1105 target[*output_ind] = static_cast<u8_t>((value & 0x03) << 6u); |
1105 target[*output_ind] = static_cast<u8_t>((value & 0x03) << 6u); |
1106 *missing_bit_count = 6u; |
1106 *missing_bit_count = 6u; |
1132 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
1132 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
1133 // : : : : : : | : : : : : : : | |
1133 // : : : : : : | : : : : : : : | |
1134 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
1134 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
1135 */ |
1135 */ |
1136 value = octet_from_ascii_armor(source_byte); |
1136 value = octet_from_ascii_armor(source_byte); |
1137 target[*output_ind] = static_cast<u8_t>(target[*output_ind] | value); |
1137 target[*output_ind] |= value; |
1138 ++(*output_ind); |
1138 ++(*output_ind); |
1139 *missing_bit_count = 0u; |
1139 *missing_bit_count = 0u; |
1140 } |
1140 } |
1141 else |
1141 else |
1142 { |
1142 { |
1654 this)); |
1654 this)); |
1655 |
1655 |
1656 if (m_shutdown_was_called == false) |
1656 if (m_shutdown_was_called == false) |
1657 { |
1657 { |
1658 m_shutdown_was_called = true; |
1658 m_shutdown_was_called = true; |
1659 |
|
1660 // stop tracing as tools get deleted |
|
1661 set_trace_mask(eap_trace_mask_none); |
|
1662 |
1659 |
1663 #if !defined(NO_EAP_AM_MEMORY_STORE) |
1660 #if !defined(NO_EAP_AM_MEMORY_STORE) |
1664 (void) am_cancel_all_timers(); |
|
1665 if (m_memory_store != 0) |
1661 if (m_memory_store != 0) |
1666 { |
1662 { |
1667 status = m_memory_store->shutdown(); |
1663 status = m_memory_store->shutdown(); |
1668 } |
1664 } |
1669 delete m_memory_store; |
1665 delete m_memory_store; |
1892 { |
1888 { |
1893 return EAP_STATUS_RETURN(this, status); |
1889 return EAP_STATUS_RETURN(this, status); |
1894 } |
1890 } |
1895 |
1891 |
1896 previous_data = data[ind]; |
1892 previous_data = data[ind]; |
1897 data[ind] = static_cast<u8_t>(data[ind] ^ rnd); |
1893 data[ind] ^= rnd; |
1898 |
1894 |
1899 if (previous_data != data[ind]) |
1895 if (previous_data != data[ind]) |
1900 { |
1896 { |
1901 error_generated = true; |
1897 error_generated = true; |
1902 sent_packet->set_random_error_type(eap_random_error_type_manipulate_byte); |
1898 sent_packet->set_random_error_type(eap_random_error_type_manipulate_byte); |
2034 if (status != eap_status_ok) |
2030 if (status != eap_status_ok) |
2035 { |
2031 { |
2036 return EAP_STATUS_RETURN(this, status); |
2032 return EAP_STATUS_RETURN(this, status); |
2037 } |
2033 } |
2038 |
2034 |
2039 delta_length = static_cast<u8_t>(delta_length % (static_cast<i32_t>(sent_packet->get_data_length()) |
2035 delta_length %= (static_cast<i32_t>(sent_packet->get_data_length()) |
2040 - static_cast<i32_t>(minimum_packet_length))); |
2036 - static_cast<i32_t>(minimum_packet_length) /*eapol_ethernet_header_wr_c::get_header_length()*/ ); |
2041 |
2037 |
2042 if (delta_length == 0) |
2038 if (delta_length == 0) |
2043 { |
2039 { |
2044 continue; |
2040 continue; |
2045 } |
2041 } |
2433 // | node (2-5) | |
2429 // | node (2-5) | |
2434 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
2430 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
2435 |
2431 |
2436 // set the four most significant bits (bits 12 through 15) of the |
2432 // set the four most significant bits (bits 12 through 15) of the |
2437 // time_hi_and_version field to the appropriate 4-bit version number |
2433 // time_hi_and_version field to the appropriate 4-bit version number |
2438 hash[6] = static_cast<u8_t>(hash[6] & 0x0F); |
2434 hash[6] &= 0x0F; |
2439 hash[6] = static_cast<u8_t>(hash[6] | 0x50); |
2435 hash[6] |= 0x50; |
2440 |
2436 |
2441 // set the two most significant bits (bits 6 and 7) of the |
2437 // set the two most significant bits (bits 6 and 7) of the |
2442 // clock_seq_hi_and_reserved to zero and one, respectively |
2438 // clock_seq_hi_and_reserved to zero and one, respectively |
2443 hash[8] = static_cast<u8_t>(hash[8] & 0x3F); |
2439 hash[8] &= 0x3F; |
2444 hash[8] = static_cast<u8_t>(hash[8] | 0x80); |
2440 hash[8] |= 0x80; |
2445 |
2441 |
2446 return EAP_STATUS_RETURN(this, eap_status_ok); |
2442 return EAP_STATUS_RETURN(this, eap_status_ok); |
2447 } |
2443 } |
2448 |
2444 |
2449 //----------------------------------------------------------------------------------------------- |
2445 //----------------------------------------------------------------------------------------------- |