@brief Open a Multicast connection dependent on @p direction. * * @param direction Flag to indicate if consuming or producing. * @param connection_object Pointer to registered Object in ConnectionManager. * @param common_packet_format_data Received CPF Data Item. * @return kEipStatusOk on success, otherwise kEipStatusError */
| 521 | * @return kEipStatusOk on success, otherwise kEipStatusError |
| 522 | */ |
| 523 | EipStatus OpenMulticastConnection( |
| 524 | UdpCommuncationDirection direction, |
| 525 | CipConnectionObject *connection_object, |
| 526 | CipCommonPacketFormatData *common_packet_format_data |
| 527 | ) { |
| 528 | int j = -1; |
| 529 | |
| 530 | int address_info_item_which_contains_o_to_t = -1; |
| 531 | int address_info_item_which_contains_t_to_o = -1; |
| 532 | |
| 533 | if(kCipItemIdSocketAddressInfoOriginatorToTarget |
| 534 | == common_packet_format_data->address_info_item[0].type_id) { |
| 535 | address_info_item_which_contains_o_to_t = 0; |
| 536 | } else if(kCipItemIdSocketAddressInfoOriginatorToTarget |
| 537 | == common_packet_format_data->address_info_item[1].type_id) { |
| 538 | address_info_item_which_contains_o_to_t = 1; |
| 539 | } else { |
| 540 | OPENER_TRACE_INFO("No O->T Sockaddr info available\n"); |
| 541 | } |
| 542 | |
| 543 | if(kCipItemIdSocketAddressInfoTargetToOriginator |
| 544 | == common_packet_format_data->address_info_item[0].type_id) { |
| 545 | address_info_item_which_contains_t_to_o = 0; |
| 546 | } else if(kCipItemIdSocketAddressInfoTargetToOriginator |
| 547 | == common_packet_format_data->address_info_item[1].type_id) { |
| 548 | address_info_item_which_contains_t_to_o = 1; |
| 549 | } else { |
| 550 | OPENER_TRACE_INFO("No T->O Sockaddr info available\n"); |
| 551 | } |
| 552 | |
| 553 | if(kUdpCommuncationDirectionConsuming == direction) { |
| 554 | j = address_info_item_which_contains_o_to_t; |
| 555 | } |
| 556 | |
| 557 | if(kUdpCommuncationDirectionProducing == direction) { |
| 558 | j = address_info_item_which_contains_t_to_o; |
| 559 | } |
| 560 | |
| 561 | /*****************/ |
| 562 | |
| 563 | if (-1 == j) { |
| 564 | OPENER_TRACE_ERR( |
| 565 | "no suitable addr info item available / O->T: %d, T->O: %d, Selector: %d, direction: %d\n", |
| 566 | address_info_item_which_contains_o_to_t, |
| 567 | address_info_item_which_contains_t_to_o, |
| 568 | j, |
| 569 | direction); |
| 570 | return kEipStatusError; |
| 571 | } |
| 572 | |
| 573 | if (kCipItemIdSocketAddressInfoTargetToOriginator == |
| 574 | common_packet_format_data->address_info_item[j].type_id) { /* we are using an unused item initialize it with the default multicast address */ |
| 575 | common_packet_format_data->address_info_item[j].sin_family = htons( |
| 576 | AF_INET); |
| 577 | common_packet_format_data->address_info_item[j].sin_port = htons( |
| 578 | kOpenerEipIoUdpPort); |
| 579 | common_packet_format_data->address_info_item[j].sin_addr = |
| 580 | g_multicast_configuration.starting_multicast_address; |
no test coverage detected