Ok, just to chime in here, you should not be mixing dev_connect with xx_listen APIs on the same devices for routing purposes. It should be one method or the other, not both.
Also from reading the down from the beginning of the chain, you cannot have a single device being routed in hairpin mode and also perform a play/record at the same time. As that device can only listen to one timeslot at a time. You need an extra resource to accomplish that task.
Thus if you want to IP legs to be listening to each other, you can not also play and record to those same streams as they are only connected together at the IPM level.
Meaning hair-pinned would be:
ipm_getxmitslot (ipmB1C1 tsinfo1)
ipm_getxmitslot(ipmB1C2, tsinfo2)
listen (ipmB1C1, tsinfo2)
listen (ipmB1C2, tsinfo1)
If you need to play or record to those devices, then you would have to unlisten the IPM channel in order to connect to voice device.
The only way of which you can have two legs connected together and then also play file to be heard, all three devices would need to be in a conference.
For the record side you would have to use a transaction record (where you pass both tsinfo of ipmB1C1, and B1C2 timeslots) to the dx_rec call. It would not be listening to the ipm channels via a listen call, as it does it internally.
Jeff