~ubuntu-branches/debian/sid/kamailio/sid

« back to all changes in this revision

Viewing changes to modules/ims_registrar_scscf/save.c

  • Committer: Package Import Robot
  • Author(s): Victor Seva
  • Date: 2014-01-06 11:47:13 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140106114713-t8xidp4arzrnyeya
Tags: 4.1.1-1
* New upstream release
* debian/patches:
  - add upstream fixes
* Added tls outbound websocket autheph dnssec modules
  - openssl exception added to their license
* removing sparc and ia64 from supported archs
  for mono module (Closes: #728915)

Show diffs side-by-side

added added

removed removed

Lines of Context:
259
259
 
260
260
        /* additional info from message */
261
261
        if (parse_headers(_m, HDR_USERAGENT_F, 0) != -1 && _m->user_agent
262
 
                && _m->user_agent->body.len > 0 && _m->user_agent->body.len < UA_MAX_SIZE) {
 
262
                && _m->user_agent->body.len > 0 && _m->user_agent->body.len < MAX_UA_SIZE) {
263
263
            ci.user_agent = &_m->user_agent->body;
264
264
        } else {
265
265
            ci.user_agent = &no_ua;
926
926
 
927
927
}
928
928
 
929
 
int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction) {
 
929
int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction, char* route) {
930
930
    str private_identity = {0, 0}, public_identity = {0, 0};
931
931
    int assignment_type = AVP_IMS_SAR_NO_ASSIGNMENT;
932
932
    int data_available = AVP_IMS_SAR_USER_DATA_NOT_AVAILABLE;
933
933
    int require_user_data = 1;
934
934
    rerrno = R_FINE;
935
935
    tm_cell_t *t = 0;
 
936
    str route_name;
936
937
 
937
938
    saved_transaction_t* saved_t;
938
939
    cfg_action_t* cfg_action;
939
940
 
940
 
    sar_param_t* ap = (sar_param_t*) str1;
941
 
    cfg_action = ap->paction->next;
942
 
 
 
941
    udomain_t* _d = (udomain_t*) str1;
 
942
    
 
943
    if (fixup_get_svalue(_m, (gparam_t*) route, &route_name) != 0) {
 
944
        LM_ERR("no async route block for assign_server_unreg\n");
 
945
        return -1;
 
946
    }
 
947
    
 
948
    LM_DBG("Looking for route block [%.*s]\n", route_name.len, route_name.s);
 
949
    int ri = route_get(&main_rt, route_name.s);
 
950
    if (ri < 0) {
 
951
        LM_ERR("unable to find route block [%.*s]\n", route_name.len, route_name.s);
 
952
        return -1;
 
953
    }
 
954
    cfg_action = main_rt.rlist[ri];
 
955
    if (cfg_action == NULL) {
 
956
        LM_ERR("empty action lists in route block [%.*s]\n", route_name.len, route_name.s);
 
957
        return -1;
 
958
    }
 
959
    
943
960
    LM_DBG("Assigning unregistered user for direction [%.*s]\n", direction->len, direction->s);
944
961
 
945
962
    enum cscf_dialog_direction dir = cscf_get_dialog_direction(direction->s);
995
1012
    saved_t->expires = 1; //not a dereg as this is server_assign_unreg
996
1013
    saved_t->require_user_data = require_user_data;
997
1014
    saved_t->sar_assignment_type = assignment_type;
998
 
    saved_t->domain = (udomain_t*) ap->param;
 
1015
    saved_t->domain = (udomain_t*) _d;
999
1016
 
1000
1017
    saved_t->contact_header = 0;
1001
1018
 
1043
1060
 */
1044
1061
//int save(struct sip_msg* msg, udomain_t* _d) {
1045
1062
 
1046
 
int save(struct sip_msg* msg, char* str1) {
 
1063
int save(struct sip_msg* msg, char* str1, char *route) {
1047
1064
    int expires;
1048
1065
    int require_user_data = 0;
1049
1066
    int data_available;
1051
1068
    int st;
1052
1069
    str public_identity, private_identity, realm;
1053
1070
    int sar_assignment_type = AVP_IMS_SAR_NO_ASSIGNMENT;
 
1071
    str route_name;
 
1072
    
 
1073
    udomain_t* _d = (udomain_t*) str1;
1054
1074
 
1055
1075
    rerrno = R_FINE;
1056
1076
    get_act_time();
1062
1082
 
1063
1083
    contact_for_header_t* contact_header = 0;
1064
1084
 
1065
 
    sar_param_t* ap = (sar_param_t*) str1;
1066
 
    cfg_action = ap->paction->next;
 
1085
    if (fixup_get_svalue(msg, (gparam_t*) route, &route_name) != 0) {
 
1086
        LM_ERR("no async route block for assign_server_unreg\n");
 
1087
        return -1;
 
1088
    }
 
1089
    
 
1090
    LM_DBG("Looking for route block [%.*s]\n", route_name.len, route_name.s);
 
1091
    int ri = route_get(&main_rt, route_name.s);
 
1092
    if (ri < 0) {
 
1093
        LM_ERR("unable to find route block [%.*s]\n", route_name.len, route_name.s);
 
1094
        return -1;
 
1095
    }
 
1096
    cfg_action = main_rt.rlist[ri];
 
1097
    if (cfg_action == NULL) {
 
1098
        LM_ERR("empty action lists in route block [%.*s]\n", route_name.len, route_name.s);
 
1099
        return -1;
 
1100
    }
1067
1101
 
1068
1102
    //check which route block we are in - if not request then we fail out.
1069
1103
    if (!is_route_type(REQUEST_ROUTE)) {
1106
1140
 
1107
1141
    expires = cscf_get_max_expires(msg, 0); //check all contacts for max expires
1108
1142
    if (expires != 0) { //if <0 then no expires was found in which case we treat as reg/re-reg with default expires.
1109
 
        if (is_impu_registered((udomain_t*) ap->param, &public_identity)) {
 
1143
        if (is_impu_registered(_d, &public_identity)) {
1110
1144
            LM_DBG("preparing for SAR assignment for RE-REGISTRATION <%.*s>\n", public_identity.len, public_identity.s);
1111
1145
            sar_assignment_type = AVP_IMS_SAR_RE_REGISTRATION;
1112
1146
        } else {
1135
1169
            //unregister the requested contacts, if none left at the end then send a SAR, otherwise return successfully
1136
1170
            LM_DBG("need to unregister contacts\n");
1137
1171
            //lets update the contacts - we need to know if all were deleted or not for the public identity
1138
 
            int res = update_contacts_new(msg, (udomain_t*) ap->param, &public_identity, sar_assignment_type, 0, 0, 0, 0, 0, &contact_header);
 
1172
            int res = update_contacts_new(msg, _d, &public_identity, sar_assignment_type, 0, 0, 0, 0, 0, &contact_header);
1139
1173
            if (res <= 0) {
1140
1174
                LM_ERR("Error processing REGISTER for de-registration\n");
1141
1175
                free_contact_buf(contact_header);
1190
1224
    saved_t->expires = expires;
1191
1225
    saved_t->require_user_data = require_user_data;
1192
1226
    saved_t->sar_assignment_type = sar_assignment_type;
1193
 
    saved_t->domain = (udomain_t*) ap->param;
 
1227
    
 
1228
    saved_t->domain = _d;
1194
1229
 
1195
1230
    saved_t->public_identity.s = (char*) shm_malloc(public_identity.len + 1);
1196
1231
    if (!saved_t->public_identity.s) {