Syntax of "t_reply" : code reason trans_id to_tag new headers [Body] */
| 666 | [Body] |
| 667 | */ |
| 668 | mi_response_t *mi_tm_reply(const mi_params_t *params, str *new_hdrs, str *body) |
| 669 | { |
| 670 | unsigned int hash_index; |
| 671 | unsigned int hash_label; |
| 672 | int rpl_code; |
| 673 | struct cell *trans; |
| 674 | str reason; |
| 675 | str totag; |
| 676 | str tmp, trans_id; |
| 677 | char *p; |
| 678 | int n; |
| 679 | |
| 680 | /* get all info from the command */ |
| 681 | |
| 682 | if (get_mi_int_param(params, "code", &rpl_code) < 0) |
| 683 | return init_mi_param_error(); |
| 684 | if (rpl_code>=700) |
| 685 | return init_mi_error(400, MI_SSTR("Invalid reply code")); |
| 686 | |
| 687 | if (get_mi_string_param(params, "reason", &reason.s, &reason.len) < 0) |
| 688 | return init_mi_param_error(); |
| 689 | |
| 690 | if (get_mi_string_param(params, "trans_id", &trans_id.s, &trans_id.len) < 0) |
| 691 | return init_mi_param_error(); |
| 692 | |
| 693 | tmp = trans_id; |
| 694 | p = memchr( tmp.s, ':', tmp.len); |
| 695 | if ( p ) { |
| 696 | /* old fashion ID hash:label, decimal */ |
| 697 | tmp.len = p-tmp.s; |
| 698 | if( str2int( &tmp, &hash_index)!=0 ) |
| 699 | return init_mi_error(400,MI_SSTR("Invalid index in old trans_id")); |
| 700 | |
| 701 | tmp.s = p+1; |
| 702 | tmp.len = (trans_id.s+trans_id.len) - tmp.s; |
| 703 | if( str2int( &tmp, &hash_label)!=0 ) |
| 704 | return init_mi_error(400,MI_SSTR("Invalid label in old trans_id")); |
| 705 | } else { |
| 706 | p = memchr( tmp.s, '.', tmp.len); |
| 707 | if ( p==NULL) |
| 708 | return init_mi_error(400, MI_SSTR("Invalid trans_id")); |
| 709 | /* new format ID label.hash, reversed hexa */ |
| 710 | tmp.len = p-tmp.s; |
| 711 | if( reverse_hex2int( tmp.s, tmp.len, &hash_label)!=0 ) |
| 712 | return init_mi_error(400, MI_SSTR("Invalid label in trans_id")); |
| 713 | |
| 714 | tmp.s = p+1; |
| 715 | tmp.len = (trans_id.s+trans_id.len) - tmp.s; |
| 716 | if( reverse_hex2int( tmp.s, tmp.len, &hash_index)!=0 ) |
| 717 | return init_mi_error(400,MI_SSTR("Invalid label in old trans_id")); |
| 718 | } |
| 719 | |
| 720 | if (get_mi_string_param(params, "to_tag", &totag.s, &totag.len) < 0) |
| 721 | return init_mi_param_error(); |
| 722 | |
| 723 | if( t_lookup_ident( &trans, hash_index, hash_label)<0 ) |
| 724 | return init_mi_error(404, MI_SSTR("Transaction not found")); |
| 725 |
no test coverage detected