Hi, we are filtering some method names from the Allow header with kamailio 4.1: depending in the configuration: if (hf_value_exists("Allow", "INFO")) { xlog("L_INFO", "Remove INFO from Allow\n"); exclude_hf_value("Allow", "INFO"); } if (hf_value_exists("Allow", "REFER")) { xlog("L_INFO", "Remove REFER from Allow\n"); exclude_hf_value("Allow", "REFER"); }
There is a problem in case multiple rewrites are done on the same header so the resulting message is going to be broken:
Input: Allow: INVITE, BYE, REGISTER, ACK, OPTIONS, CANCEL, SUBSCRIBE, NOTIFY, PRACK, INFO, REFER
OUTPUT: Allow: INVITE, BYE, REGISTER, ACK, OPTIONS, CANCEL, SUBSCRIBE, NOTIFY, PRACK,
The trailing comma is not allowed. So we have to use msg_apply_changes(). But kamailio is quite restrictive on where you can call msg_apply_changes(): 1. it must be done before record_route()* and 2. it is not allowed in the branch route. As for me it's valid use case when you need to do some header manipulations only for some of the branches, isn't?
*(1) is further aggravated by the fact that the record_route() for loose-routed requests is usually called quite early in the processing pipeline. Imagine kamailio.cfg would look like:
request_route {
# per request initial checks route(REQINIT);
# NAT detection route(NATDETECT);
# CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) { route(RELAY); } exit; }
# ---> filter Allow route(FILTER_ALLOW_METHODS);
# handle requests within SIP dialogs route(WITHINDLG);
I don't like the idea of changing the message before loose-routing.
Taking (1) and (2) into account, would it be possible to
a) fix exclude_hf_value to allow to filter multiple values in a single pass and b) allow msg_apply_changes() in branch route without any ill effects on the record-route headers?
Please share your ideas.
Thanks, Andrew