That is custom code that someone has added to your system.
There are two problems with this. Firstly the one already mentioned, that it only supports chan_sip (which no longer exists in Asterisk 21 onwards, and can be addressed as in;
Secondly, it expects the custom code to be called as a macro, but macros no longer exist in Asterisk 21 onwards and FreePBX 17 will not call it as a macro, for any Asterisk version. You need to replace MacroExit, by Return.
Obviously first check that you really need this custom code.