| 1058 | } |
| 1059 | |
| 1060 | void routing_manager_impl::on_message(const byte_t* _data, length_t _length, boardnet_endpoint* _receiver, |
| 1061 | const boost::asio::ip::address& _remote_address, port_t _remote_port, bool _is_multicast) { |
| 1062 | |
| 1063 | uint8_t its_check_status = e2e::profile_interface::generic_check_status::E2E_OK; |
| 1064 | instance_t its_instance(0x0); |
| 1065 | bool is_forwarded(true); |
| 1066 | // message is at least 16-bytes, see also PRS_SOMEIP_00910 |
| 1067 | if (_length < VSOMEIP_FULL_HEADER_SIZE) { |
| 1068 | VSOMEIP_ERROR_P << "Dropped message with invalid length " << _length; |
| 1069 | return; |
| 1070 | } |
| 1071 | |
| 1072 | const message_type_e its_message_type = static_cast<message_type_e>(_data[VSOMEIP_MESSAGE_TYPE_POS]); |
| 1073 | const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); |
| 1074 | const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); |
| 1075 | const client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); |
| 1076 | const session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); |
| 1077 | const auto its_return_code = static_cast<return_code_e>(_data[VSOMEIP_RETURN_CODE_POS]); |
| 1078 | |
| 1079 | // refer to error workflow in PRS_SOMEIP_00195 |
| 1080 | // (although note that it is *NOT* strictly followed!) |
| 1081 | |
| 1082 | // ignore messages with invalid message type |
| 1083 | if (!utility::is_valid_message_type(its_message_type)) { |
| 1084 | VSOMEIP_ERROR_P << "Dropped message with invalid message type 0x" << hex2(static_cast<uint8_t>(its_message_type)); |
| 1085 | return; |
| 1086 | } |
| 1087 | // ignore messages with.. unknown remote address? how is this even possible?! |
| 1088 | if (_remote_address.is_unspecified()) { |
| 1089 | VSOMEIP_ERROR_P << "Dropped message with invalid remote address from: " << _remote_address.to_string() << ":" << _remote_port; |
| 1090 | return; |
| 1091 | } |
| 1092 | |
| 1093 | // Log messages which could cause routing issues. |
| 1094 | if (!is_valid_client_id(its_client, its_message_type)) { |
| 1095 | VSOMEIP_ERROR_P << "Invalid client id. message=" << hex4(its_service) << "." << hex4(its_method) << "." |
| 1096 | << hex2(static_cast<uint8_t>(its_message_type)) << "." << hex2(static_cast<uint8_t>(its_return_code)) |
| 1097 | << " client=0x" << hex4(its_client) << " source=" << _remote_address << ":" << _remote_port; |
| 1098 | } |
| 1099 | |
| 1100 | if (its_service == VSOMEIP_SD_SERVICE) { |
| 1101 | if (discovery_ && its_method == sd::method) { |
| 1102 | if (configuration_->get_sd_port() == _remote_port) { |
| 1103 | // ACL check SD message |
| 1104 | if (!is_acl_message_allowed(_receiver, its_service, ANY_INSTANCE, _remote_address)) { |
| 1105 | return; |
| 1106 | } |
| 1107 | discovery_->on_message(_data, _length, _remote_address, _is_multicast); |
| 1108 | } else { |
| 1109 | VSOMEIP_ERROR << "Ignored SD message from unknown port (" << _remote_port << ")"; |
| 1110 | } |
| 1111 | } |
| 1112 | } else { |
| 1113 | if (_is_multicast) { |
| 1114 | its_instance = ep_mgr_impl_->find_instance_multicast(its_service, _remote_address); |
| 1115 | } else { |
| 1116 | its_instance = ep_mgr_impl_->find_instance(its_service, _receiver); |
| 1117 | } |
nothing calls this directly
no test coverage detected