* Return parsed To or From, host part of the parsed uri is realm */
| 42 | * Return parsed To or From, host part of the parsed uri is realm |
| 43 | */ |
| 44 | int get_realm(struct sip_msg* _m, hdr_types_t _hftype, struct sip_uri** _u) |
| 45 | { |
| 46 | |
| 47 | if(_u==NULL) |
| 48 | return -1; |
| 49 | if ((REQ_LINE(_m).method.len == 8) |
| 50 | && !memcmp(REQ_LINE(_m).method.s, "REGISTER", 8) |
| 51 | && (_hftype == HDR_AUTHORIZATION_T) |
| 52 | ) { |
| 53 | if (!_m->to && ((parse_headers(_m, HDR_TO_F, 0)==-1) || (!_m->to))) { |
| 54 | LM_ERR("failed to parse TO headers\n"); |
| 55 | return -1; |
| 56 | } |
| 57 | |
| 58 | /* Body of To header field is parsed automatically */ |
| 59 | if((*_u = parse_to_uri(_m))==NULL) |
| 60 | return -1; |
| 61 | } else { |
| 62 | if (parse_from_header(_m) < 0) { |
| 63 | LM_ERR("failed to parse FROM headers\n"); |
| 64 | return -2; |
| 65 | } |
| 66 | if((*_u = parse_from_uri(_m))==NULL) |
| 67 | return -1; |
| 68 | } |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | /* |
no test coverage detected