IAX2 channels names

There are two asterisks. They are connected between by themselves IAX2 a trunk.
Calls go from one asterisk on the second.
Active IAX2 channels are called as names of trunks IAX2 / - .

There is a task to take name IAX2 of the channel on 2 asterisk on which the call hangs
And to determine corresponding name IAX2 of the channel on the first asterisk through
Which this call passes. It is necessary for the subsequent management
Calls agi, functions of the manager and foreign scripts.
Similarly for SIP trunks.