| 3365 | |
| 3366 | |
| 3367 | int tr_parse_via(str* in, trans_t *t) |
| 3368 | { |
| 3369 | char *p; |
| 3370 | str name; |
| 3371 | tr_param_t *tp = NULL; |
| 3372 | |
| 3373 | if(in==NULL || in->s==NULL || t==NULL) |
| 3374 | return -1; |
| 3375 | p = in->s; |
| 3376 | name.s = in->s; |
| 3377 | |
| 3378 | /* find next token */ |
| 3379 | while(*p && *p!=TR_PARAM_MARKER && *p!=TR_RBRACKET) p++; |
| 3380 | if(*p=='\0') |
| 3381 | { |
| 3382 | LM_ERR("invalid transformation: %.*s\n", in->len, in->s); |
| 3383 | goto error; |
| 3384 | } |
| 3385 | name.len = p - name.s; |
| 3386 | trim(&name); |
| 3387 | |
| 3388 | if(name.len==4 && strncasecmp(name.s, "name", 4)==0) |
| 3389 | { |
| 3390 | t->subtype = TR_VIA_NAME; |
| 3391 | return 0; |
| 3392 | } else if(name.len==7 && strncasecmp(name.s, "version", 7)==0) |
| 3393 | { |
| 3394 | t->subtype = TR_VIA_VERSION; |
| 3395 | return 0; |
| 3396 | } else if(name.len==9 && strncasecmp(name.s, "transport", 9)==0) { |
| 3397 | t->subtype = TR_VIA_TRANSPORT; |
| 3398 | return 0; |
| 3399 | } else if((name.len==4 && strncasecmp(name.s, "host", 4)==0) |
| 3400 | || (name.len==6 && strncasecmp(name.s, "domain", 6)==0)) { |
| 3401 | t->subtype = TR_VIA_HOST; |
| 3402 | return 0; |
| 3403 | } else if(name.len==4 && strncasecmp(name.s, "port", 4)==0) { |
| 3404 | t->subtype = TR_VIA_PORT; |
| 3405 | return 0; |
| 3406 | } else if(name.len==6 && strncasecmp(name.s, "params", 6)==0) { |
| 3407 | t->subtype = TR_VIA_PARAMS; |
| 3408 | return 0; |
| 3409 | } else if(name.len==5 && strncasecmp(name.s, "param", 5)==0) { |
| 3410 | t->subtype = TR_VIA_PARAM; |
| 3411 | if(*p!=TR_PARAM_MARKER) |
| 3412 | { |
| 3413 | LM_ERR("invalid param transformation: %.*s\n", in->len, in->s); |
| 3414 | goto error; |
| 3415 | } |
| 3416 | p++; |
| 3417 | if (tr_parse_sparam(p, in, &tp, 0) == NULL) |
| 3418 | goto error; |
| 3419 | t->params = tp; |
| 3420 | |
| 3421 | return 0; |
| 3422 | } else if(name.len==7 && strncasecmp(name.s, "comment", 7)==0) { |
| 3423 | t->subtype = TR_VIA_COMMENT; |
| 3424 | return 0; |
nothing calls this directly
no test coverage detected