📄 radius_attribute.c
字号:
if (radius_add_attribute_to_list ((RADIUS_ATTRIBUTE_LIST_HANDLE) p_radius_attribute_list_controller, type, attribute_length - RADIUS_SIZE_OF_ATTRIBUTE_HEADER_IN_PACKET, &sptr_attribute_entry_in_packet->value[0]) == FAIL) { return (FAIL); } } sptr_attribute_entry_in_packet = (RADIUS_ATTRIBUTE_ENTRY_IN_PACKET *) ((UINT) sptr_attribute_entry_in_packet + attribute_length); packet_length -= attribute_length; } if (eap_message_found == true) { if (radius_add_attribute_to_list ((RADIUS_ATTRIBUTE_LIST_HANDLE) p_radius_attribute_list_controller, RADIUS_EAP_MESSAGE, index, &temp_attribute_data[0]) == FAIL) { return (FAIL); } } return (PASS);}#endif /* __EAP__ *//*****************************************************************************************/void print_radius_attributes (RADIUS_LIST_CONTROLLER* p_radius_attribute_list_controller){ RW_CONTAINER_ITERATOR attribute_iterator; RADIUS_ATTRIBUTE_ENTRY* p_attribute;#ifdef __EAP__ char output_buffer[MAXIMUM_RADIUS_RX_PACKET_SIZE]; char output_ascii[MAXIMUM_RADIUS_RX_PACKET_SIZE];#else char output_buffer[MAXIMUM_OUTPUT_BUFFER_LENGTH + sizeof (BYTE)]; char output_ascii[MAXIMUM_ATTRIBUTE_LENGTH + sizeof (BYTE)];#endif /* __EAP__ */ enum RADIUS_ATTRIBUTE_TYPE output_type; UINT output_length; if (radius.trace_printing_enabled != TRUE) { return; } radius_printf (RADIUS_TRACE_PRINTF, " attributes:\n"); attribute_iterator = p_radius_attribute_list_controller->iterator; rw_container_goto_front (attribute_iterator); while (rw_container_is_at_end (attribute_iterator) == false) { p_attribute = (RADIUS_ATTRIBUTE_ENTRY *) rw_container_at (attribute_iterator); output_type = p_attribute->type; output_length = p_attribute->length_of_attribute_value; convert_bytes_to_ascii ((BYTE *)&p_attribute->value[0], output_length, &output_buffer[0]); convert_bytes_to_printable_ascii ((BYTE *)&p_attribute->value[0], output_length, &output_ascii[0]); radius_printf (RADIUS_TRACE_PRINTF, " type = 0x%X, length = 0x%X, value = %s : %s\n", output_type, output_length, &output_buffer[0], &output_ascii[0]); rw_container_next (attribute_iterator); }}/*****************************************************************************************/void convert_bytes_to_ascii (BYTE *bptr_input_buffer, UINT length, char *cptr_output_buffer){ USHORT index; USHORT output_value; for (index = 0x0000; index < length; ++index) { output_value = bptr_input_buffer[index]; sprintf (&cptr_output_buffer[index * sizeof (OUTPUT_BUFFER_ENTRY)], "%02X ", output_value); } cptr_output_buffer[length * sizeof (OUTPUT_BUFFER_ENTRY)] = 0x00;}/*****************************************************************************************/static void convert_bytes_to_printable_ascii (BYTE *bptr_input_buffer, UINT length, char *cptr_output_buffer){ USHORT index; for (index = 0x0000; index < length; ++index) { if (isprint (bptr_input_buffer[index]) == NOT_PRINTABLE_ASCII) { cptr_output_buffer[index] = '.'; } else { cptr_output_buffer[index] = (char) bptr_input_buffer[index]; } } cptr_output_buffer[length] = 0x00;}/*****************************************************************************************/#ifdef __RADIUS_ATTRIBUTE_VERIFICATION_DEBUG__bool radius_service_type_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } if ((uint_value < RADIUS_LOGIN_SERVICE_TYPE) || (uint_value >= MAXIMUM_RADIUS_SERVICE_TYPE)) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_service_type_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_framed_protocol_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } if ((uint_value < RADIUS_PPP_PROTOCOL) || (uint_value >= MAXIMUM_RADIUS_FRAMED_PROTOCOL_TYPE)) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_framed_routing_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_framed_routing_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } /* Removed Check for value less than RADIUS_NONE_ROUTING as unsigned * variable need not be checked for negative values */ if (uint_value >= MAXIMUM_RADIUS_FRAMED_ROUTING_METHOD_TYPE) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_framed_routing_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_framed_MTU_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } if ((uint_value < MIN_FRAMED_MTU) || (uint_value > MAX_FRAMED_MTU)) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_framed_MTU_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_framed_compression_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } /* Removed Check for value less than RADIUS_NONE_COMPRESSION as * unsigned variable need not be checked for negative values */ if (uint_value >= MAXIMUM_RADIUS_FRAMED_COMPRESSION_METHOD_TYPE) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_framed_compression_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_login_service_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } /* Removed Check for value less than RADIUS_TELNET_LOGIN_SERVICE * as unsigned variable need not be checked for negative values */ if (uint_value >= MAXIMUM_RADIUS_LOGIN_SERVICE_TYPE) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_login_service_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_login_TCP_port_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } /* Removed Check for value less than zero as unsigned variable * need not be checked for negative values */ if (uint_value >= RADIUS_MAX_PORT_NUMBER) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_login_TCP_port_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_termination_action_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } /* Removed Check for value Less than * RADIUS_DEFAULT_TERMINATION_ACTION as unsigned variable * need not be checked for negative values */ if (uint_value >= MAXIMUM_RADIUS_TERMINATION_ACTION_TYPE) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_termination_action_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_apple_talk_link_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } /* Removed Check for value Less than zero as unsigned variable * need not be checked for negative values */ if (uint_value >= RADIUS_MAX_APPLETALK_LINK) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_apple_talk_link_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_apple_talk_network_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } /* Removed Check for value Less than zero as unsigned value * need not be checked for negative values */ if (uint_value >= RADIUS_MAX_APPLETALK_NETWORK) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_apple_talk_network_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_acct_status_type_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } if ((uint_value < RADIUS_ACCOUNTING_START) || (uint_value >= MAXIMUM_RADIUS_ACCOUNTING_STATUS_TYPE)) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_acct_status_type_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_acct_authentic_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } if ((uint_value < RADIUS_ACCOUNTING_RADIUS_AUTHENTICATION) || (uint_value >= MAXIMUM_RADIUS_ACCOUNTING_AUTHENTIC_TYPE)) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_acct_authentic_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_acct_terminate_cause_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } if ((uint_value < RADIUS_ACCOUNTING_TERMINATION_USER_REQUEST) || (uint_value >= MAXIMUM_RADIUS_ACCOUNTING_TERMINATE_CAUSE_TYPE)) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_acct_terminate_cause_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_nas_port_type_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } /* Removed Check for value Less than RADIUS_ASYNC_PORT_TYPE * as unsigned value need not checked for negative values */ if (uint_value >= MAXIMUM_RADIUS_NAS_PORT_TYPE) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_nas_port_type_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_tunnel_type_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } if ((uint_value < RADIUS_TUNNEL_PPTP) || (uint_value >= MAXIMUM_RADIUS_TUNNEL_TYPE)) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_tunnel_type_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_tunnel_medium_type_value_check (BYTE_ENUM (RADIUS_ATTRIBUTE_TYPE) type, void *value){ ULONG uint_value; if (radius_util_deserialize_ulong (value, &uint_value) == false) { return (false); } if ((uint_value < RADIUS_TUNNEL_MEDIUM_IPV4) || (uint_value >= MAXIMUM_RADIUS_TUNNEL_MEDIUM_TYPE)) { radius_printf (RADIUS_ALARM_PRINTF, "RADIUS: radius_tunnel_medium_type_value_check: Value outside valid range.\n"); return (false); } return (true);}/*****************************************************************************************/bool radius_verify_attribute_value (RADIUS_ATTRIBUTE_ENTRY* p_attribute){ UINT length; if (p_attribute == NULL) { return (false); } length = p_attribute->length_of_attribute_value; if ((length < radius_attribute_value_control[p_attribute->type].attribute_length_lower_limit) || (length > radius_attribute_value_control[p_attribute->type].attribute_length_upper_limit)) { return (false); } if (radius_attribute_value_control[p_attribute->type].fptr_validate_attribute_value != NULL) { if (radius_attribute_value_control[p_attribute->type].fptr_validate_attribute_value (p_attribute->type, &(p_attribute->value[0])) == false) { return (false); } } return (true);}/*****************************************************************************************/#endif /*__RADIUS_ATTRIBUTE_VERIFICATION_DEBUG__*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -