Changeset 427:3d9f300f3b49 in freeDiameter for extensions/app_sip/locationinfo.c
- Timestamp:
- Jul 26, 2010, 9:39:27 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/app_sip/locationinfo.c
r420 r427 45 45 struct avp_hdr *avphdr; 46 46 union avp_value value; 47 int ret=0; 47 48 48 49 //Result_Code to return in the answer … … 58 59 ans = *msg; 59 60 61 //Add the Auth-Application-Id 62 { 63 CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Application_Id, 0, &avp ) ); 64 value.i32 = 6; 65 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); 66 CHECK_FCT( fd_msg_avp_add ( ans, MSG_BRW_LAST_CHILD, avp) ); 67 } 60 68 // Add the Auth-Session-State AVP 61 69 { … … 69 77 } 70 78 71 //TODO: wait for answer from authors to clear how to find SIP server!79 72 80 //Add a SIP_Server_URI 73 81 { … … 75 83 CHECK_FCT( fd_msg_avp_hdr( avp, &avphdr ) ); 76 84 77 //We extract Realm from SIP_AOR 78 char *realm=NULL; 79 80 81 realm = strtok( (char *)(avphdr->avp_value->os.data), "@" ); 82 realm = strtok( NULL, "@" ); 83 84 if(realm!=NULL) 85 86 87 88 89 ret=exist_username(avphdr->avp_value->os.data, avphdr->avp_value->os.len); 90 91 92 if(ret==2) 93 {//error 94 /* 95 If the Diameter server cannot process the Diameter LIR command, e.g., 96 due to a database error, the Diameter server MUST set the Result-Code 97 AVP value to DIAMETER_UNABLE_TO_COMPLY and return it in a Diameter 98 LIA message. 99 */ 100 strcpy(result,"DIAMETER_UNABLE_TO_COMPLY"); 101 goto out; 102 } 103 else if(ret==1) 104 {//not found 105 /* 106 One of the errors that the Diameter server may find is that the 107 SIP-AOR AVP value is not a valid user in the realm. In such cases, 108 the Diameter server MUST set the Result-Code AVP value to 109 DIAMETER_ERROR_USER_UNKNOWN and return it in a Diameter LIA message. 110 111 */ 112 strcpy(result,"DIAMETER_ERROR_USER_UNKNOWN"); 113 goto out; 114 } 115 116 //If we arrive here, the user is known 117 int sipserverurilen; 118 char * sipserver_uri=NULL; 119 120 ret=get_sipserver_uri(avphdr->avp_value->os.data, avphdr->avp_value->os.len, &sipserver_uri, &sipserverurilen); 121 122 123 if(ret==0) 124 {//found 125 if(sipserver_uri==NULL) 126 { 127 //There is a problem because we must get a Diameter_URI here 128 strcpy(result,"DIAMETER_UNABLE_TO_COMPLY"); 129 goto out; 130 } 131 else 132 { 133 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Server_URI, 0, &avp ) ); 134 value.os.data=(unsigned char *)sipserver_uri; 135 value.os.len=sipserverurilen; 136 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); 137 CHECK_FCT( fd_msg_avp_add ( ans, MSG_BRW_LAST_CHILD, avp) ); 138 139 strcpy(result,"DIAMETER_SUCCESS"); 140 } 141 } 142 else if(ret==1) 143 {//not found 144 //We don't know this SIP_AOR in SL, that means 145 strcpy(result,"DIAMETER_ERROR_USER_UNKNOWN"); 146 goto out; 147 } 148 else 149 {// returned 2, impossible to make request 150 //We couldn't make the request, we must stop process! 151 strcpy(result,"DIAMETER_UNABLE_TO_COMPLY"); 152 goto out; 153 } 154 155 //Adding SIP-Server-Capabilities 156 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Server_Capabilities, 0, &groupedavp ) ); 157 //We add mandatory and optional capabilities 158 ret=get_sipserver_cap(avphdr->avp_value->os.data, avphdr->avp_value->os.len, &groupedavp); 159 160 161 if(ret==0) 162 {//found 163 if(sipserver_uri==NULL) 85 164 { 86 CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Server_URI, 0, &avp ) ); 87 value.os.data=(unsigned char *)realm; 88 value.os.len=strlen(realm); 89 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); 90 CHECK_FCT( fd_msg_avp_add ( ans, MSG_BRW_LAST_CHILD, avp) ); 165 //There is a problem because we must get a Diameter_URI here 166 strcpy(result,"DIAMETER_UNABLE_TO_COMPLY"); 167 CHECK_FCT( fd_msg_free( groupedavp ) ); 168 goto out; 91 169 } 92 170 else 93 171 { 94 strcpy(result,"DIAMETER_UNABLE_TO_COMPLY"); 95 goto out; 96 } 172 173 CHECK_FCT( fd_msg_avp_add ( ans, MSG_BRW_LAST_CHILD, groupedavp) ); 174 175 strcpy(result,"DIAMETER_SUCCESS"); 176 } 177 } 178 else if(ret==1) 179 {//not found 180 //We don't know this SIP_AOR in SL, that means 181 strcpy(result,"DIAMETER_ERROR_IDENTITY_NOT_REGISTERED"); 182 CHECK_FCT( fd_msg_free( groupedavp ) ); 183 goto out; 184 } 185 else 186 {// returned 2, impossible to make request 187 //We couldn't make the request, we must stop process! 188 strcpy(result,"DIAMETER_UNABLE_TO_COMPLY"); 189 CHECK_FCT( fd_msg_free( groupedavp ) ); 190 goto out; 191 } 192 193 194 97 195 } 98 196
Note: See TracChangeset
for help on using the changeset viewer.