There is a better way to apply a block of custom code to calls over a specific trunk. See this post:
The post talks about pjsip trunks, but the same technique will work on chan_sip. You define a subroutine with a new context name, then add the sub as a dial option to the trunk in question using the b
option:
b(context^exten^priority)