compare_with_info_contact_too.patch
  on Register reply AmSIPRegistration::onSipReply(...) compares Contact
field from server with local contact which generated by
AmBasicSipDialog::getContactHdr()
  when we set contact with user part for registration manually,
comparing always returns false, because
AmBasicSipDialog::getContactHdr() ignore possible user part
  patch above is try to fix this behavior via comparing with contact
from SIPRegistrationInfo

memorize_sendRequest_flags_in_SIPRequestInfo.patch
  when we get 401 in response to registration, we send new
(authenticated) request.
  AmSIPRegistration::doRegistration() uses SIP_FLAGS_NOCONTACT flag for
AmBasicSipDialog::sendRequest(...) to avoid automatic generation of
Contact when it is set manually.
  but, in cases where authorization is required, UACAuth loses this flag
and we have two Contact headers in authenticated REGISTER request.
  possible fix: memorize flags in SIPRequestInfo on
UACAuth::onSendRequest(AmSipRequest& req, int& flags)

please someone examine this issues

-- 
best regards
Michael Furmur

diff --git a/core/AmSipRegistration.cpp b/core/AmSipRegistration.cpp
index 6429927..34b8a29 100644
--- a/core/AmSipRegistration.cpp
+++ b/core/AmSipRegistration.cpp
@@ -123,6 +123,13 @@ bool AmSIPRegistration::doRegistration()
 
   int flags=0;
   if(!info.contact.empty()) {
+        size_t end = 0;
+        if(!info_contact.parse_contact(info.contact,(size_t)0,end)){
+            ERROR("failed to parse contact field.\n");
+            waiting_result = false;
+            reg_send_begin  = time(NULL);
+            return false;
+        }
     hdrs += SIP_HDR_COLSP(SIP_HDR_CONTACT) "<"
       + info.contact + ">" + CRLF;
     flags = SIP_FLAGS_NOCONTACT;
@@ -310,7 +317,8 @@ void AmSIPRegistration::onSipReply(const AmSipRequest& req,
          }
          server_contact.dump();
 
-         if (server_contact.isEqual(local_contact)) {
+         if (server_contact.isEqual(local_contact) ||
+                 (!info.contact.empty()&&server_contact.isEqual(info_contact))) {
            DBG("contact found\n");
            found = active = true;
 
diff --git a/core/AmSipRegistration.h b/core/AmSipRegistration.h
index 7d3dc1c..c1eb098 100644
--- a/core/AmSipRegistration.h
+++ b/core/AmSipRegistration.h
@@ -80,6 +80,7 @@ class AmSIPRegistration
 
   AmUriParser server_contact;
   AmUriParser local_contact;
+  AmUriParser info_contact;
 
   time_t reg_begin;    
   unsigned int reg_expires;
diff --git a/core/plug-in/uac_auth/UACAuth.cpp b/core/plug-in/uac_auth/UACAuth.cpp
index 188e33a..54820e3 100644
--- a/core/plug-in/uac_auth/UACAuth.cpp
+++ b/core/plug-in/uac_auth/UACAuth.cpp
@@ -229,7 +229,7 @@ bool UACAuth::onSipReply(const AmSipRequest& req, const AmSipReply& reply,
            // resend request 
            if (dlg->sendRequest(ri->second.method,
                                 &(ri->second.body),
-                                hdrs, SIP_FLAGS_VERBATIM | SIP_FLAGS_NOAUTH) == 0) {
+                                hdrs, ri->second.flags | SIP_FLAGS_VERBATIM | SIP_FLAGS_NOAUTH) == 0) {
              processed = true;
               DBG("authenticated request successfully sent.\n");
              // undo SIP dialog status change
@@ -271,7 +271,8 @@ bool UACAuth::onSendRequest(AmSipRequest& req, int& flags)
   DBG("adding %d to list of sent requests.\n", req.cseq);
   sent_requests[req.cseq] = SIPRequestInfo(req.method, 
                                           &req.body,
-                                          req.hdrs//,
+                                          req.hdrs,
+                                          flags//,
                                           // TODO: fix this!!!
                                           /*dlg->getOAState()*/);
   return false;
diff --git a/core/plug-in/uac_auth/UACAuth.h b/core/plug-in/uac_auth/UACAuth.h
index 0b91c6b..41d74bb 100644
--- a/core/plug-in/uac_auth/UACAuth.h
+++ b/core/plug-in/uac_auth/UACAuth.h
@@ -80,13 +80,15 @@ struct SIPRequestInfo {
   string method;
   AmMimeBody body;
   string hdrs;
+  int flags;
   //AmOfferAnswer::OAState oa_state;
 
   SIPRequestInfo(const string& method, 
                 const AmMimeBody* body,
-                const string& hdrs
+                const string& hdrs,
+                int flags
                 )
-    : method(method), hdrs(hdrs)
+         : method(method), hdrs(hdrs), flags(flags)
   {
     if(body) this->body = *body;
   }

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to