| 1152 | |
| 1153 | #define MAX_RR_HDRS 64 |
| 1154 | str* get_route_set(struct sip_msg *msg,int *nr_routes) |
| 1155 | { |
| 1156 | static str uris[MAX_RR_HDRS]; |
| 1157 | struct hdr_field *it; |
| 1158 | rr_t *p; |
| 1159 | int n = 0; |
| 1160 | int routing_type; |
| 1161 | |
| 1162 | if (msg == NULL || msg->route == NULL) |
| 1163 | { |
| 1164 | LM_ERR("null sip msg or no route headers\n"); |
| 1165 | return 0; |
| 1166 | } |
| 1167 | |
| 1168 | routing_type = ctx_routing_get(); |
| 1169 | if (routing_type == ROUTING_SS || routing_type == ROUTING_LS) |
| 1170 | { |
| 1171 | /* must manually insert RURI, as it was part |
| 1172 | * of the route deleted to make up for strict routing */ |
| 1173 | uris[n++] = msg->new_uri; |
| 1174 | } |
| 1175 | |
| 1176 | it = msg->route; |
| 1177 | while (it != NULL) |
| 1178 | { |
| 1179 | if (parse_rr(it) < 0) |
| 1180 | { |
| 1181 | LM_ERR("failed to parse RR\n"); |
| 1182 | return 0; |
| 1183 | } |
| 1184 | |
| 1185 | p = (rr_t*)it->parsed; |
| 1186 | while (p) |
| 1187 | { |
| 1188 | if (p->deleted == 0) |
| 1189 | { |
| 1190 | uris[n++] = p->nameaddr.uri; |
| 1191 | if(n==MAX_RR_HDRS) |
| 1192 | { |
| 1193 | LM_ERR("too many RR\n"); |
| 1194 | return 0; |
| 1195 | } |
| 1196 | } |
| 1197 | else |
| 1198 | LM_DBG("Route [%.*s] has been deleted\n",p->nameaddr.uri.len, |
| 1199 | p->nameaddr.uri.s); |
| 1200 | p = p->next; |
| 1201 | } |
| 1202 | it = it->sibling; |
| 1203 | } |
| 1204 | |
| 1205 | |
| 1206 | /* if SS - remove last route */ |
| 1207 | if (routing_type == ROUTING_SS) |
| 1208 | n--; |
| 1209 | |
| 1210 | if (nr_routes) |
| 1211 | *nr_routes = n; |
nothing calls this directly
no test coverage detected