| 444 | } |
| 445 | |
| 446 | EipStatus OpenProducingMulticastConnection( |
| 447 | CipConnectionObject *connection_object, |
| 448 | CipCommonPacketFormatData *common_packet_format_data |
| 449 | ) { |
| 450 | CipConnectionObject *existing_connection_object = |
| 451 | GetExistingProducerMulticastConnection( |
| 452 | connection_object->produced_path.instance_id); |
| 453 | |
| 454 | int j = 0; /* allocate an unused sockaddr struct to use */ |
| 455 | if (g_common_packet_format_data_item.address_info_item[0].type_id == 0) { /* it is not used yet */ |
| 456 | j = 0; |
| 457 | } else if (g_common_packet_format_data_item.address_info_item[1].type_id |
| 458 | == 0) { |
| 459 | j = 1; |
| 460 | } |
| 461 | |
| 462 | int port = htons(kOpenerEipIoUdpPort); |
| 463 | if(kCipItemIdSocketAddressInfoTargetToOriginator != |
| 464 | common_packet_format_data->address_info_item[j].type_id) { |
| 465 | port = common_packet_format_data->address_info_item[j].sin_port; |
| 466 | } |
| 467 | |
| 468 | common_packet_format_data->address_info_item[j].type_id = |
| 469 | kCipItemIdSocketAddressInfoTargetToOriginator; |
| 470 | |
| 471 | if (NULL == existing_connection_object) { /* we are the first connection producing for the given Input Assembly */ |
| 472 | return OpenMulticastConnection(kUdpCommuncationDirectionProducing, |
| 473 | connection_object, |
| 474 | common_packet_format_data); |
| 475 | } else { |
| 476 | /* we need to inform our originator on the correct connection id */ |
| 477 | connection_object->cip_produced_connection_id = existing_connection_object |
| 478 | -> |
| 479 | cip_produced_connection_id; |
| 480 | } |
| 481 | |
| 482 | /* we have a connection reuse the data and the socket */ |
| 483 | |
| 484 | if (kConnectionObjectInstanceTypeIOExclusiveOwner == |
| 485 | connection_object->instance_type) { |
| 486 | /* exclusive owners take the socket and further manage the connection |
| 487 | * especially in the case of time outs. |
| 488 | */ |
| 489 | connection_object->socket[kUdpCommuncationDirectionProducing] = |
| 490 | existing_connection_object->socket[kUdpCommuncationDirectionProducing]; |
| 491 | existing_connection_object->socket[kUdpCommuncationDirectionProducing] = |
| 492 | kEipInvalidSocket; |
| 493 | } else { /* this connection will not produce the data */ |
| 494 | connection_object->socket[kUdpCommuncationDirectionProducing] = |
| 495 | kEipInvalidSocket; |
| 496 | } |
| 497 | |
| 498 | common_packet_format_data->address_info_item[j].length = 16; |
| 499 | |
| 500 | connection_object->remote_address.sin_family = AF_INET; |
| 501 | connection_object->remote_address.sin_port = common_packet_format_data |
| 502 | ->address_info_item[j].sin_port |
| 503 | = port; |
no test coverage detected