* Set calling number if translated * param msg SIP message * param inbound Inbound info * param dest Destination structure * return 0 success, 1 calling number same or not support calling number translation, -1 failure */
| 875 | * return 0 success, 1 calling number same or not support calling number translation, -1 failure |
| 876 | */ |
| 877 | static int ospSetCalling( |
| 878 | struct sip_msg* msg, |
| 879 | osp_inbound* inbound, |
| 880 | osp_dest* dest) |
| 881 | { |
| 882 | str rpid; |
| 883 | int_str val; |
| 884 | char buffer[2 * sizeof dest->calling + sizeof inbound->source + 11]; |
| 885 | int result; |
| 886 | |
| 887 | if (strcmp(inbound->calling, dest->calling) == 0) { |
| 888 | LM_DBG("calling number does not been translated\n"); |
| 889 | result = 1; |
| 890 | } else if (osp_auth.rpid_avp < 0) { |
| 891 | LM_WARN("rpid_avp is not found, cannot set rpid avp\n"); |
| 892 | result = -1; |
| 893 | } else { |
| 894 | snprintf(buffer, |
| 895 | sizeof(buffer), |
| 896 | "\"%s\" <sip:%s@%s>", |
| 897 | dest->calling, |
| 898 | dest->calling, |
| 899 | inbound->source); |
| 900 | |
| 901 | rpid.s = buffer; |
| 902 | rpid.len = strlen(buffer); |
| 903 | add_avp(osp_auth.rpid_avp_type | AVP_VAL_STR, osp_auth.rpid_avp, (int_str)rpid); |
| 904 | |
| 905 | result = 0; |
| 906 | } |
| 907 | |
| 908 | if (result == 0) { |
| 909 | val.n = 1; |
| 910 | } else { |
| 911 | val.n = 0; |
| 912 | } |
| 913 | add_avp(0, _osp_calling_avpid, val); |
| 914 | |
| 915 | return result; |
| 916 | } |
| 917 | |
| 918 | /* |
| 919 | * Check if the calling number is translated. |
no test coverage detected