| 2952 | } |
| 2953 | |
| 2954 | static int pv_get_hdr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) |
| 2955 | { |
| 2956 | int idx; |
| 2957 | int idxf; |
| 2958 | pv_value_t tv; |
| 2959 | struct hdr_field *hf; |
| 2960 | struct hdr_field *hf0; |
| 2961 | char *p; |
| 2962 | int n; |
| 2963 | int ret; |
| 2964 | |
| 2965 | if ( (ret=pv_get_hdr_prolog(msg, param, res, &tv)) <= 0 ) |
| 2966 | return ret; |
| 2967 | |
| 2968 | if (tv.flags==0) { |
| 2969 | /* it is a known header -> use type to find it */ |
| 2970 | for (hf=msg->headers; hf; hf=hf->next) { |
| 2971 | if (tv.ri==hf->type) |
| 2972 | break; |
| 2973 | } |
| 2974 | } else { |
| 2975 | /* it is an un-known header -> use name to find it */ |
| 2976 | for (hf=msg->headers; hf; hf=hf->next) { |
| 2977 | if (hf->type==HDR_OTHER_T && hf->name.len==tv.rs.len |
| 2978 | && strncasecmp(hf->name.s, tv.rs.s, hf->name.len)==0) |
| 2979 | break; |
| 2980 | } |
| 2981 | } |
| 2982 | |
| 2983 | if(hf==NULL) |
| 2984 | return pv_get_null(msg, param, res); |
| 2985 | /* get the index */ |
| 2986 | if(pv_get_spec_index(msg, param, &idx, &idxf)!=0) |
| 2987 | { |
| 2988 | LM_ERR("invalid index\n"); |
| 2989 | return -1; |
| 2990 | } |
| 2991 | |
| 2992 | /* get the value */ |
| 2993 | res->flags = PV_VAL_STR; |
| 2994 | if(idxf!=PV_IDX_ALL && idx==0) |
| 2995 | { |
| 2996 | res->rs = hf->body; |
| 2997 | return 0; |
| 2998 | } |
| 2999 | if(idxf==PV_IDX_ALL) |
| 3000 | { |
| 3001 | p = pv_local_buf; |
| 3002 | do { |
| 3003 | if(p!=pv_local_buf) |
| 3004 | { |
| 3005 | if(p-pv_local_buf+PV_FIELD_DELIM_LEN+1>PV_LOCAL_BUF_SIZE) |
| 3006 | { |
| 3007 | LM_ERR("local buffer length exceeded\n"); |
| 3008 | return pv_get_null(msg, param, res); |
| 3009 | } |
| 3010 | memcpy(p, PV_FIELD_DELIM, PV_FIELD_DELIM_LEN); |
| 3011 | p += PV_FIELD_DELIM_LEN; |
nothing calls this directly
no test coverage detected