@brief Call Connection Manager. * @param receive_data Pointer to structure with data and header information. * @param originator_address Address of the originator as received from socket * @param outgoing_message The outgoing ENIP message */
| 649 | * @param outgoing_message The outgoing ENIP message |
| 650 | */ |
| 651 | EipStatus HandleReceivedSendUnitDataCommand( |
| 652 | const EncapsulationData *const receive_data, |
| 653 | const struct sockaddr *const originator_address, |
| 654 | ENIPMessage *const outgoing_message) { |
| 655 | EipStatus return_value = kEipStatusOkSend; |
| 656 | |
| 657 | if (receive_data->data_length >= 6) { |
| 658 | /* Command specific data UDINT .. Interface Handle, UINT .. Timeout, CPF packets */ |
| 659 | /* don't use the data yet */ |
| 660 | GetDintFromMessage( |
| 661 | (const EipUint8 **const ) &receive_data->current_communication_buffer_position); /* skip over null interface handle*/ |
| 662 | GetIntFromMessage( |
| 663 | (const EipUint8 **const ) &receive_data->current_communication_buffer_position); /* skip over unused timeout value*/ |
| 664 | ( (EncapsulationData *const)receive_data )->data_length -= 6; /* the rest is in CPF format*/ |
| 665 | |
| 666 | if (kSessionStatusValid == CheckRegisteredSessions(receive_data) ) /* see if the EIP session is registered*/ |
| 667 | { |
| 668 | EipInt16 send_size = |
| 669 | NotifyConnectedCommonPacketFormat(receive_data, |
| 670 | originator_address, |
| 671 | outgoing_message); |
| 672 | |
| 673 | return_value = send_size; |
| 674 | |
| 675 | if (send_size < 0) { /* need to send reply */ |
| 676 | return_value = kEipStatusError; |
| 677 | } |
| 678 | } else { /* received a package with non registered session handle */ |
| 679 | InitializeENIPMessage(outgoing_message); |
| 680 | GenerateEncapsulationHeader(receive_data, |
| 681 | 0, |
| 682 | receive_data->session_handle, |
| 683 | kEncapsulationProtocolInvalidSessionHandle, |
| 684 | outgoing_message); |
| 685 | } |
| 686 | } |
| 687 | return return_value; |
| 688 | } |
| 689 | |
| 690 | /** @brief Call UCMM or Message Router if UCMM not implemented. |
| 691 | * @param receive_data Pointer to structure with data and header information. |
no test coverage detected