registrar_cb.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include<stdio.h>
00030 #include<stdlib.h>
00031 #include "../../dprint.h"
00032 #include "../pua/pua.h"
00033 #include "registrar_cb.h"
00034 #include "pua_bla.h"
00035
00036
00037 void bla_cb(ucontact_t* c, int type, void* param)
00038 {
00039 subs_info_t subs;
00040 str uri={0, 0};
00041 char* at;
00042 LM_DBG("start\n");
00043 if(is_bla_aor== 0)
00044 {
00045 LM_DBG("Not a recognized BLA AOR\n");
00046 return ;
00047 }
00048
00049 if(type & UL_CONTACT_INSERT)
00050 LM_DBG("type= UL_CONTACT_INSERT\n");
00051 else
00052 if(type & UL_CONTACT_UPDATE)
00053 LM_DBG("type= UL_CONTACT_UPDATE\n");
00054 else
00055 if(type & UL_CONTACT_EXPIRE)
00056 LM_DBG("type= UL_CONTACT_EXPIRE\n");
00057 else
00058 if(type & UL_CONTACT_DELETE)
00059 LM_DBG("type= UL_CONTACT_DELETE\n");
00060
00061 memset(&subs, 0, sizeof(subs_info_t));
00062 subs.remote_target= &c->c;
00063
00064 subs.pres_uri= ®_from_uri;
00065
00066 uri.s = (char*)pkg_malloc(sizeof(char)*(c->aor->len+default_domain.len+6));
00067 if(uri.s == NULL)
00068 goto error;
00069
00070 memcpy(uri.s, "sip:", 4);
00071 uri.len = 4;
00072
00073 memcpy(uri.s+ uri.len, c->aor->s, c->aor->len);
00074 uri.len+= c->aor->len;
00075 at = memchr(c->aor->s, '@', c->aor->len);
00076 if(!at)
00077 {
00078 uri.s[uri.len++]= '@';
00079 memcpy(uri.s+ uri.len, default_domain.s, default_domain.len);
00080 uri.len+= default_domain.len;
00081 }
00082
00083 subs.watcher_uri= &uri;
00084 if(type & UL_CONTACT_DELETE || type & UL_CONTACT_EXPIRE )
00085 subs.expires= 0;
00086 else
00087 subs.expires= c->expires - (int)time(NULL);
00088
00089
00090 subs.source_flag= BLA_SUBSCRIBE;
00091 subs.event= BLA_EVENT;
00092 subs.contact= &server_address;
00093
00094 if(bla_outbound_proxy.s && bla_outbound_proxy.len)
00095 subs.outbound_proxy= &bla_outbound_proxy;
00096 else
00097 if(c->received.s && c->received.len)
00098 subs.outbound_proxy= &c->received;
00099
00100 if(type & UL_CONTACT_INSERT)
00101 subs.flag|= INSERT_TYPE;
00102 else
00103 subs.flag|= UPDATE_TYPE;
00104
00105 if(pua_send_subscribe(&subs)< 0)
00106 {
00107 LM_ERR("while sending subscribe\n");
00108 }
00109 pkg_free(uri.s);
00110 error:
00111 is_bla_aor= 0;
00112 return ;
00113 }