Will,
You can strip and remove headers with append_hf() and remove_hf() at will, and add headers to replies with append_to_reply().
However, as a methodological matter, I have to concur with the position taken by Carsten. Ultimately, the problem is improper handling of reinvites by one endpoint. Reinvites can legitimately arise for many reasons, of which SST pings are only one, and clobbering together a hack to deal with that situation and that situation alone represents a narrowly-conceived view of the problem and certainly is not a production-worthy solution.
You must fix the endpoint; sometimes there's no way around hard problems sometimes.
-- Alex