+static void fill_options_answer(osip_message_t *options){
+ osip_message_set_allow(options,"INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, SUBSCRIBE, NOTIFY, INFO");
+ osip_message_set_accept(options,"application/sdp");
+}
+
+static void process_refer(Sal *sal, SalOp *op, eXosip_event_t *ev){
+ osip_header_t *h=NULL;
+ osip_message_t *ans=NULL;
+ ms_message("Receiving REFER request !");
+ osip_message_header_get_byname(ev->request,"Refer-To",0,&h);
+
+ if (h){
+ osip_from_t *from=NULL;
+ char *tmp;
+ osip_from_init(&from);
+
+ if (osip_from_parse(from,h->hvalue)==0){
+ if (op ){
+ osip_uri_header_t *uh=NULL;
+ osip_header_t *referred_by=NULL;
+ osip_uri_header_get_byname(&from->url->url_headers,(char*)"Replaces",&uh);
+ if (uh!=NULL && uh->gvalue && uh->gvalue[0]!='\0'){
+ ms_message("Found replaces in Refer-To");
+ if (op->replaces){
+ ms_free(op->replaces);
+ }
+ op->replaces=ms_strdup(uh->gvalue);
+ }
+ osip_message_header_get_byname(ev->request,"Referred-By",0,&referred_by);
+ if (referred_by && referred_by->hvalue && referred_by->hvalue[0]!='\0'){
+ if (op->referred_by)
+ ms_free(op->referred_by);
+ op->referred_by=ms_strdup(referred_by->hvalue);
+ }
+ }
+ osip_uri_header_freelist(&from->url->url_headers);
+ osip_from_to_str(from,&tmp);
+ sal->callbacks.refer_received(sal,op,tmp);
+ osip_free(tmp);
+ osip_from_free(from);
+ }
+ eXosip_lock();
+ eXosip_call_build_answer(ev->tid,202,&ans);
+ if (ans)
+ eXosip_call_send_answer(ev->tid,202,ans);
+ eXosip_unlock();
+ }
+ else
+ {
+ ms_warning("cannot do anything with the refer without destination\n");
+ }
+}
+