| 107 | } |
| 108 | |
| 109 | static int determine_source (struct sip_msg *msg, enum hash_source source, |
| 110 | str *source_string) { |
| 111 | source_string->s = NULL; |
| 112 | source_string->len = 0; |
| 113 | |
| 114 | if(validate_msg(msg) < 0) { |
| 115 | return -1; |
| 116 | } |
| 117 | |
| 118 | switch (source) { |
| 119 | case shs_call_id: |
| 120 | return determine_call_id (msg, source_string); |
| 121 | case shs_from_uri: |
| 122 | return determine_fromto_uri (get_from(msg), source_string); |
| 123 | case shs_from_user: |
| 124 | return determine_fromto_user (get_from(msg), source_string); |
| 125 | case shs_to_uri: |
| 126 | return determine_fromto_uri (get_to(msg), source_string); |
| 127 | case shs_to_user: |
| 128 | return determine_fromto_user (get_to(msg), source_string); |
| 129 | default: |
| 130 | LM_ERR("unknown hash source %i.\n", |
| 131 | (int) source); |
| 132 | return -1; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | static int validate_msg(struct sip_msg * msg) { |
| 137 | if(!msg->callid && ((parse_headers(msg, HDR_CALLID_F, 0) == -1) || !msg->callid)) { |
no test coverage detected