privacy.c

Go to the documentation of this file.
00001 
00055 #include "../tm/tm_load.h"
00056 #include "mod.h"
00057 #include "sip.h"
00058 #include "privacy.h"
00059 
00060 extern struct tm_binds tmb;
00061 
00062 static str asserted_identity={"P-Asserted-Identity",19};
00063 static str privacy={"Privacy",7};
00064 
00070 int apply_privacy_id(struct sip_msg* msg){
00071     struct hdr_field *hdr;
00072 
00073     LOG(L_DBG, "DBG:"M_NAME": apply_privacy_id\n");
00074     hdr = cscf_get_next_header(msg,asserted_identity,NULL);
00075     if (!hdr) return CSCF_RETURN_FALSE;
00076     do {
00077         cscf_del_header(msg,hdr);
00078         hdr=cscf_get_next_header(msg,asserted_identity,hdr);
00079     } while (hdr);
00080 
00081     return CSCF_RETURN_TRUE;
00082 }
00083 
00089 void privacy_reply_cb(struct cell *t, int type, struct tmcb_params *ps) {
00090     S_apply_privacy(ps->rpl, 0, 0);
00091 }
00092 
00100 int S_apply_privacy(struct sip_msg* msg, char* str1, char* str2) {
00101     char *c;
00102     int ret = CSCF_RETURN_FALSE;
00103     
00104     str privacy_content = cscf_get_headers_content(msg,privacy);
00105 
00106     if (!privacy_content.len){ 
00107         ret = CSCF_RETURN_FALSE;
00108         goto done;
00109     }
00110     
00111     LOG(L_DBG, "DBG:"M_NAME":S_apply_privacy\n");
00112     c = strtok(privacy_content.s," \t\r\n;,");
00113     while (c){
00114         if (strlen(c)==2 && strncasecmp(c,"id",2)==0){
00115             ret = apply_privacy_id(msg);
00116             break;
00117         }
00118         c = strtok(0," \t\r\n;,");
00119     }
00120     
00121 done:   
00122     if (privacy_content.s) pkg_free(privacy_content.s);
00123     return ret;
00124 }
00125 
00133 int S_privacy_hook(struct sip_msg* msg, char* str1, char* str2) {
00134     unsigned int a,b;
00135     
00136     cscf_get_transaction(msg,&a,&b);
00137     tmb.register_tmcb(msg,0,TMCB_RESPONSE_IN,privacy_reply_cb,0);
00138     
00139     return CSCF_RETURN_TRUE;
00140 }
00141 

Generated on Thu Oct 23 04:14:39 2008 for Open IMS Core CSCFs by  doxygen 1.5.2