+static int get_auth_data_from_request(osip_message_t *msg, const char **realm, const char **username){
+ osip_authorization_t *auth=NULL;
+ osip_proxy_authorization_t *prx_auth=NULL;
+
+ *username=osip_uri_get_username(msg->from->url);
+ osip_message_get_authorization(msg, 0, &auth);
+ if (auth){
+ *realm=osip_authorization_get_realm(auth);
+ return 0;
+ }
+ osip_message_get_proxy_authorization(msg,0,&prx_auth);
+ if (prx_auth){
+ *realm=osip_proxy_authorization_get_realm(prx_auth);
+ return 0;
+ }
+ return -1;
+}
+
+static int get_auth_data(eXosip_event_t *ev, const char **realm, const char **username){
+ if (ev->response && get_auth_data_from_response(ev->response,realm,username)==0) return 0;
+ if (ev->request && get_auth_data_from_request(ev->request,realm,username)==0) return 0;
+ return -1;
+}
+