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

Function HandleReceivedConnectedData

source/src/cip/cipconnectionmanager.c:242–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242EipStatus HandleReceivedConnectedData(
243 const EipUint8 *const data,
244 int data_length,
245 struct sockaddr_in *from_address
246 ) {
247
248 if ( ( CreateCommonPacketFormatStructure(data, data_length,
249 &g_common_packet_format_data_item) )
250 == kEipStatusError ) {
251 return kEipStatusError;
252 } else {
253 /* check if connected address item or sequenced address item received, otherwise it is no connected message and should not be here */
254 if ( (g_common_packet_format_data_item.address_item.type_id
255 == kCipItemIdConnectionAddress)
256 || (g_common_packet_format_data_item.address_item.type_id
257 == kCipItemIdSequencedAddressItem) ) { /* found connected address item or found sequenced address item -> for now the sequence number will be ignored */
258 if (g_common_packet_format_data_item.data_item.type_id
259 == kCipItemIdConnectedDataItem) { /* connected data item received */
260
261 CipConnectionObject *connection_object = GetConnectedObject(
262 g_common_packet_format_data_item.address_item.data
263 .connection_identifier);
264 if (connection_object == NULL) {
265 return kEipStatusError;
266 }
267
268 /* only handle the data if it is coming from the originator */
269 if (connection_object->originator_address.sin_addr.s_addr
270 == from_address->sin_addr.s_addr) {
271 ConnectionObjectResetLastPackageInactivityTimerValue(connection_object);
272
273 if ( SEQ_GT32(
274 g_common_packet_format_data_item.address_item.data.
275 sequence_number,
276 connection_object->eip_level_sequence_count_consuming) ) {
277 /* reset the watchdog timer */
278 ConnectionObjectResetInactivityWatchdogTimerValue(connection_object);
279
280 /* only inform assembly object if the sequence counter is greater or equal */
281 connection_object->eip_level_sequence_count_consuming =
282 g_common_packet_format_data_item.address_item.data
283 .sequence_number;
284
285 if (NULL != connection_object->connection_receive_data_function) {
286 return connection_object->connection_receive_data_function(
287 connection_object,
288 g_common_packet_format_data_item.data_item.data,
289 g_common_packet_format_data_item.data_item.length);
290 }
291 }
292 } else {
293 OPENER_TRACE_WARN(
294 "Connected Message Data Received with wrong address information\n");
295 }
296 }
297 }
298 }
299 return kEipStatusOk;

Callers 1

Tested by

no test coverage detected