Failed to authenticate device

I want to redirect flooder IP address with messages like “Failed to authenticate device” to my perl script.

I add in “chan_sip.c” after:

this code:

But if flooder connects to the asterisk server, it falls with message:

[quote]Disconnected from Asterisk server
Executing last minute cleanups[/quote]

Can you help me with code to EXEC my script?