| 921 | } |
| 922 | |
| 923 | EipStatus OpenCommunicationChannels(CipConnectionObject *connection_object) { |
| 924 | |
| 925 | EipStatus eip_status = kEipStatusOk; |
| 926 | /*get pointer to the CPF data, currently we have just one global instance of the struct. This may change in the future*/ |
| 927 | CipCommonPacketFormatData *common_packet_format_data = |
| 928 | &g_common_packet_format_data_item; |
| 929 | |
| 930 | ConnectionObjectConnectionType originator_to_target_connection_type = |
| 931 | ConnectionObjectGetOToTConnectionType(connection_object); |
| 932 | |
| 933 | ConnectionObjectConnectionType target_to_originator_connection_type = |
| 934 | ConnectionObjectGetTToOConnectionType(connection_object); |
| 935 | |
| 936 | /* open a connection "point to point" or "multicast" based on the ConnectionParameter */ |
| 937 | if (originator_to_target_connection_type == |
| 938 | kConnectionObjectConnectionTypeMulticast) /* Multicast consuming */ |
| 939 | { |
| 940 | if (OpenMulticastConnection(kUdpCommuncationDirectionConsuming, |
| 941 | connection_object, common_packet_format_data) |
| 942 | == kEipStatusError) { |
| 943 | OPENER_TRACE_ERR("error in OpenMulticast Connection\n"); |
| 944 | return kCipErrorConnectionFailure; |
| 945 | } |
| 946 | } else if (originator_to_target_connection_type == |
| 947 | kConnectionObjectConnectionTypePointToPoint) /* Point to Point consuming */ |
| 948 | { |
| 949 | if (OpenConsumingPointToPointConnection(connection_object, |
| 950 | common_packet_format_data) |
| 951 | == kEipStatusError) { |
| 952 | OPENER_TRACE_ERR("error in PointToPoint consuming connection\n"); |
| 953 | return kCipErrorConnectionFailure; |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | if (target_to_originator_connection_type == |
| 958 | kConnectionObjectConnectionTypeMulticast) /* Multicast producing */ |
| 959 | { |
| 960 | if (OpenProducingMulticastConnection(connection_object, |
| 961 | common_packet_format_data) |
| 962 | == kEipStatusError) { |
| 963 | OPENER_TRACE_ERR("error in OpenMulticast Connection\n"); |
| 964 | return kCipErrorConnectionFailure; |
| 965 | } |
| 966 | } else if (target_to_originator_connection_type == |
| 967 | kConnectionObjectConnectionTypePointToPoint) /* Point to Point producing */ |
| 968 | { |
| 969 | |
| 970 | if (OpenProducingPointToPointConnection(connection_object, |
| 971 | common_packet_format_data) |
| 972 | != kEipStatusOk) { |
| 973 | OPENER_TRACE_ERR("error in PointToPoint producing connection\n"); |
| 974 | return kCipErrorConnectionFailure; |
| 975 | } |
| 976 | } |
| 977 | return eip_status; |
| 978 | } |
| 979 | |
| 980 | void CloseCommunicationChannelsAndRemoveFromActiveConnectionsList( |
no test coverage detected