MCPcopy Create free account
hub / github.com/EIPStackGroup/OpENer / AssembleLinearMessage

Function AssembleLinearMessage

source/src/enet_encap/cpf.c:651–758  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

649}
650
651int AssembleLinearMessage(
652 const CipMessageRouterResponse *const message_router_response,
653 const CipCommonPacketFormatData *const common_packet_format_data_item,
654 ENIPMessage *const outgoing_message) {
655
656 if (message_router_response) {
657 /* add Interface Handle and Timeout = 0 -> only for SendRRData and SendUnitData necessary */
658 outgoing_message->used_message_length += AddDintToMessage(0,
659 &outgoing_message->current_message_position);
660 outgoing_message->used_message_length += AddIntToMessage(0,
661 &outgoing_message->current_message_position);
662 }
663
664 EncodeItemCount(common_packet_format_data_item, outgoing_message);
665
666 /* process Address Item */
667 switch (common_packet_format_data_item->address_item.type_id) {
668 case kCipItemIdNullAddress: {
669 EncodeNullAddressItem(outgoing_message);
670 break;
671 }
672 case kCipItemIdConnectionAddress: {
673 EncodeConnectedAddressItem(common_packet_format_data_item,
674 outgoing_message);
675 break;
676 }
677 case kCipItemIdSequencedAddressItem: {
678 EncodeSequencedAddressItem(common_packet_format_data_item,
679 outgoing_message);
680 break;
681 }
682 default:
683 OPENER_TRACE_INFO("Unknown CIP Item in AssembleLinearMessage");
684 return kEipStatusError;
685 }
686
687 /* process Data Item */
688 if ( (common_packet_format_data_item->data_item.type_id
689 == kCipItemIdUnconnectedDataItem)
690 || (common_packet_format_data_item->data_item.type_id
691 == kCipItemIdConnectedDataItem) ) {
692
693 if (message_router_response) {
694 EncodeDataItemType(common_packet_format_data_item,
695 outgoing_message);
696
697 if (common_packet_format_data_item->data_item.type_id
698 == kCipItemIdConnectedDataItem) { /* Connected Item */
699 EncodeConnectedDataItemLength(message_router_response,
700 outgoing_message);
701 EncodeSequenceNumber(&g_common_packet_format_data_item,
702 outgoing_message);
703
704 } else { /* Unconnected Item */
705 EncodeUnconnectedDataItemLength(message_router_response,
706 outgoing_message);
707 }
708

Callers 3

NotifyCommonPacketFormatFunction · 0.85
AssembleIOMessageFunction · 0.85

Calls 15

AddDintToMessageFunction · 0.85
AddIntToMessageFunction · 0.85
EncodeItemCountFunction · 0.85
EncodeNullAddressItemFunction · 0.85
EncodeDataItemTypeFunction · 0.85
EncodeSequenceNumberFunction · 0.85
EncodeReplyServiceFunction · 0.85

Tested by

no test coverage detected