reSIProcate/repro  9694
Public Member Functions
repro::GruuMonkey Class Reference

#include <GruuMonkey.hxx>

Inheritance diagram for repro::GruuMonkey:
Inheritance graph
[legend]
Collaboration diagram for repro::GruuMonkey:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GruuMonkey ()
virtual ~GruuMonkey ()
virtual processor_action_t process (RequestContext &)
virtual void dump (std::ostream &os) const

Detailed Description

Definition at line 10 of file GruuMonkey.hxx.


Constructor & Destructor Documentation

GruuMonkey::GruuMonkey ( )

Definition at line 20 of file GruuMonkey.cxx.

{}
GruuMonkey::~GruuMonkey ( ) [virtual]

Definition at line 23 of file GruuMonkey.cxx.

{}

Member Function Documentation

void GruuMonkey::dump ( std::ostream &  os) const [virtual]

Definition at line 131 of file GruuMonkey.cxx.

{
  os << "Gruu Monkey" << std::endl;
}
Processor::processor_action_t GruuMonkey::process ( RequestContext context) [virtual]

Implements repro::Processor.

Definition at line 27 of file GruuMonkey.cxx.

{
   DebugLog(<< "Monkey handling request: " << *this 
            << "; reqcontext = " << context);

   resip::SipMessage& request = context.getOriginalRequest();

   //    sip:alice;uuid:urn:00000-000-8....@example.com;user=gruu
   //
   // Looking for a Request URI which contains ";user=gruu"
   
   
   // This monkey looks for a Request URIs such as:
   //    sip:alice@example.com;opaque=uuid:urn:0000-000-89akkskhnasd
   //
   // Looking for a Request URI which contains an opaque parameter
   
   
   Uri reqUri = request.header(h_RequestLine).uri();
   
   if (reqUri.exists(p_opaque))
   {
      Uri aor = reqUri.getAor();
      Data instance = reqUri.param(p_opaque);
      
      // find the GRUU from the AOR and instance
      
      if (!mStore.mUserStore.aorExists(aor))
      {
         // send 404 Not Found
         resip::SipMessage response;
         InfoLog (<< *this << ": no AOR matching this GRUU found.  Gruu: <" << uri << ">, sending 404");
         Helper::makeResponse(response, request, 404); 
         context.sendResponse(response);
         return Processor::SkipThisChain;            
      }
      
      if (mStore.isContactRegistered(reqUri.getAor(), reqUri.param(p_opaque)))
      {
         // grab the grid from the Request URI
         Data grid;
         if (reqUri.exists(p_grid))
         {
            grid = reqUri.params(p_grid);
         }
      
         // walk through the entries that match the instance and aor
         RegistrationPersistenceManager::ContactList records = mStore.getRegistrationBinding(aor)->mContacts;
         RegistrationPersistenceManager::ContactList::const_iterator i;
         
         for (i = records.begin(); i != records.end(); ++i)
         {
            if (i->mInstance == reqUri.param(p_opaque))
            {
               NameAddr newTarget = i->mContact.uri();
               // strip caller prefs
               // strip instance and flowId
               // preserve q-values
               if (i->mContact.exists(p_q))
               {
                  newTarget.param(p_q) = i->mContact.param(p_q);
               }
               
               // copy the grid over from the request URI
               if (!grid.empty())
               {
                  newTarget.uri().param(p_grid) = grid;
               }
               
               // populate the targetSet with appropriate tuple (or sessionId) and URI combo
               // !rwm! TODO add a version of addTarget that take the server session id or the Path
               // and only uses sendOverExistingConnection 
               if (i->mSipPath.empty())
               {
                  assert(i->mServerSessionId)  // make sure there is either a Path or a sessionId
                  context.addTarget(newTarget, i->mServerSessionId);
               }
               else
               {
                  context.addTarget(newTarget, i->mSipPath);
               }
            }

            
            InfoLog (<< "Sending to requri: " << request.header(h_RequestLine).uri());
            // skip the rest of the monkeys
            return Processor::SkipThisChain;                
         }
         else  // nobody home with that GRUU
         {
            // send 480 Temporarily Unavailable
            resip::SipMessage response;
            InfoLog (<< *this << ": no contacts matching this GRUU found.  Gruu: <" << uri << ">, sending 480");
            Helper::makeResponse(response, request, 480); 
            context.sendResponse(response);
            return Processor::SkipThisChain;
         }
      }
   }
   return Processor::Continue;
}

The documentation for this class was generated from the following files: