| 226 | } |
| 227 | |
| 228 | EipStatus GetAttributeSingleTcpIpInterface( |
| 229 | CipInstance *const RESTRICT instance, |
| 230 | CipMessageRouterRequest *RESTRICT const message_router_request, |
| 231 | CipMessageRouterResponse *RESTRICT const message_router_response, |
| 232 | struct sockaddr *originator_address, |
| 233 | const int encapsulation_session) { |
| 234 | |
| 235 | EipByte *message = message_router_response->data; |
| 236 | |
| 237 | message_router_response->data_length = 0; |
| 238 | message_router_response->reply_service = (0x80 |
| 239 | | message_router_request->service); |
| 240 | message_router_response->size_of_additional_status = 0; |
| 241 | |
| 242 | EipUint16 attribute_number = message_router_request->request_path |
| 243 | .attribute_number; |
| 244 | uint8_t get_bit_mask = 0; |
| 245 | |
| 246 | message_router_response->general_status = kCipErrorAttributeNotSupported; |
| 247 | |
| 248 | if (9 == message_router_request->request_path.attribute_number) { /* attribute 9 can not be easily handled with the default mechanism therefore we will do it by hand */ |
| 249 | if (kGetAttributeAll == message_router_request->service) { |
| 250 | get_bit_mask = (instance->cip_class->get_all_bit_mask[CalculateIndex( |
| 251 | attribute_number)]); |
| 252 | message_router_response->general_status = kCipErrorSuccess; |
| 253 | } else { |
| 254 | get_bit_mask = (instance->cip_class->get_single_bit_mask[CalculateIndex( |
| 255 | attribute_number) |
| 256 | ]); |
| 257 | } |
| 258 | |
| 259 | if ( 0 == ( get_bit_mask & ( 1 << (attribute_number % 8) ) ) ) { |
| 260 | return kEipStatusOkSend; |
| 261 | } |
| 262 | message_router_response->general_status = kCipErrorSuccess; |
| 263 | |
| 264 | message_router_response->data_length += EncodeData( |
| 265 | kCipUsint, &(g_multicast_configuration.alloc_control), &message); |
| 266 | message_router_response->data_length += EncodeData( |
| 267 | kCipUsint, &(g_multicast_configuration.reserved_shall_be_zero), |
| 268 | &message); |
| 269 | message_router_response->data_length += EncodeData( |
| 270 | kCipUint, |
| 271 | &(g_multicast_configuration.number_of_allocated_multicast_addresses), |
| 272 | &message); |
| 273 | |
| 274 | EipUint32 multicast_address = ntohl( |
| 275 | g_multicast_configuration.starting_multicast_address); |
| 276 | |
| 277 | message_router_response->data_length += EncodeData(kCipUdint, |
| 278 | &multicast_address, |
| 279 | &message); |
| 280 | } else { |
| 281 | CipAttributeStruct *attribute = GetCipAttribute(instance, attribute_number); |
| 282 | |
| 283 | if ( (NULL != attribute) && ( NULL != attribute->data) ) { |
| 284 | |
| 285 | OPENER_TRACE_INFO("getAttribute %d\n", |
no test coverage detected