< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] can not output user param in URI


On Tuesday 22 August 2006 05:14, julien wrote:
> Ok sorry for the confusion between user-parameter and extension
> parameter, I am sorry I am still a bit confused with SIP
> If there is no way to iterate through the parameters,
> how can I get the name of the unknown extension parameters?
> (I am sorry it's probably a dumb question)
> for ex:
> "sip:user:password@host:4242;ttl=15;user="me";paf=pouf;pif =plof"
> So if I need to get the values of paf and pif...
> I guess I would need to do something like:
> cout << uri.param(UnknownParameterType("paf"));
> cout << uri.param(UnknownParameterType("pif"));
> but how do I get "paf" and "pif" in the first place? :-(

I have made a patch to allow iterating through the user parameters because 
we need that for our B2BUA.

Attached the patch. It is not against the latest SVN trunk, but it is not 
that old (SVN revision 5788).
It also contains factory methods for creating the parameters in a generic 
way. (We parse out all the parameters to CORBA structures then they are 
manipulated and then we put all of them back to a new sip message).

I have never tried to submit this patch for application to resiprocate 
because one of my earlier patches I sent to this list never got any 
response/commets :)
But if it is needed by others, then somebody could apply it to svn.

Regards,
Zsolt
#! /bin/sh -e
## 05_paramlist_access.dpatch by  <rizsanyi@xxxxxxxxxxx>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: change storage and interface of SDP session and media attributes so
## DP: that it retains the sequence as they were in the original SDP and as 
they were added

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch ${2:+-d $2}}"

if [ $# -lt 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch) patch $patch_opts -p1 < $0;;
    -unpatch) patch $patch_opts -p1 -R < $0;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1;;
esac

exit 0
@DPATCH@

diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/BranchParameter.hxx 
resiprocate-0.9.0-5788/resip/stack/BranchParameter.hxx
--- resiprocate-0.9.0-5788.orig/resip/stack/BranchParameter.hxx 2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/BranchParameter.hxx      2006-04-25 
15:42:43.000000000 +0200
@@ -46,7 +46,11 @@
       {
          return new BranchParameter(type, pb, terminators);
       }
-      
+      static Parameter* create(ParameterTypes::Type type)
+      {
+         return new BranchParameter(type);
+      }
+
       virtual Parameter* clone() const;
       virtual std::ostream& encode(std::ostream& stream) const;
 
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/DataParameter.hxx 
resiprocate-0.9.0-5788/resip/stack/DataParameter.hxx
--- resiprocate-0.9.0-5788.orig/resip/stack/DataParameter.hxx   2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/DataParameter.hxx        2006-04-25 
15:42:43.000000000 +0200
@@ -27,10 +27,15 @@
       {
          return new DataParameter(type, pb, terminators);
       }
+      static Parameter* create(ParameterTypes::Type type)
+      {
+         return new DataParameter(type);
+      }
       
       virtual Parameter* clone() const;
       virtual std::ostream& encode(std::ostream& stream) const;
       
+      Type& value() {return mValue;}            // does not return a quoted 
string
    protected:
       DataParameter(const DataParameter& other) 
          : Parameter(other), 
@@ -46,7 +51,6 @@
       friend class ParserCategory;
       friend class Auth;
       friend class Uri;
-      Type& value() {return mValue;}            // does not return a quoted 
string
 };
  
 }
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/ExistsParameter.hxx 
resiprocate-0.9.0-5788/resip/stack/ExistsParameter.hxx
--- resiprocate-0.9.0-5788.orig/resip/stack/ExistsParameter.hxx 2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/ExistsParameter.hxx      2006-04-25 
15:42:43.000000000 +0200
@@ -13,7 +13,7 @@
 {
    public:
       typedef bool Type;
-      
+
       ExistsParameter(ParameterTypes::Type, ParseBuffer& pb, const char* 
terminators);
       explicit ExistsParameter(ParameterTypes::Type type);
 
@@ -21,13 +21,17 @@
       {
          return new ExistsParameter(type, pb, terminators);
       }
+      static Parameter* create(ParameterTypes::Type type)
+      {
+         return new ExistsParameter(type);
+      }
 
       virtual Parameter* clone() const;
       virtual std::ostream& encode(std::ostream& stream) const;
 
+      Type& value() {return mValue;}
    private:
       friend class ParserCategory;
-      Type& value() {return mValue;}
 
       Type mValue;
 };
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/FloatParameter.hxx 
resiprocate-0.9.0-5788/resip/stack/FloatParameter.hxx
--- resiprocate-0.9.0-5788.orig/resip/stack/FloatParameter.hxx  2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/FloatParameter.hxx       2006-04-25 
15:42:43.000000000 +0200
@@ -22,13 +22,17 @@
       {
          return new FloatParameter(type, pb, terminators);
       }
+      static Parameter* create(ParameterTypes::Type type)
+      {
+         return new FloatParameter(type);
+      }
 
       virtual Parameter* clone() const;
       virtual std::ostream& encode(std::ostream& stream) const;
 
+      Type& value() {return mValue;}
    private:
       friend class ParserCategory;
-      Type& value() {return mValue;}
 
       Type mValue;
 };
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/IntegerParameter.hxx 
resiprocate-0.9.0-5788/resip/stack/IntegerParameter.hxx
--- resiprocate-0.9.0-5788.orig/resip/stack/IntegerParameter.hxx        
2006-01-12 16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/IntegerParameter.hxx     2006-04-25 
15:42:43.000000000 +0200
@@ -22,14 +22,18 @@
       {
          return new IntegerParameter(type, pb, terminators);
       }
+      static Parameter* create(ParameterTypes::Type type)
+      {
+         return new IntegerParameter(type);
+      }
 
       virtual std::ostream& encode(std::ostream& stream) const;
 
       virtual Parameter* clone() const;
+      Type& value() {return mValue;}
    private:
       friend class ParserCategory;
       friend class Uri;
-      Type& value() {return mValue;}
 
       int mValue;
 };
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/ParameterTypeEnums.hxx 
resiprocate-0.9.0-5788/resip/stack/ParameterTypeEnums.hxx
--- resiprocate-0.9.0-5788.orig/resip/stack/ParameterTypeEnums.hxx      
2006-01-12 16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/ParameterTypeEnums.hxx   2006-04-25 
15:42:43.000000000 +0200
@@ -124,8 +124,10 @@
       static Type getType(const char* start, unsigned int length);
 
       typedef Parameter* (*Factory)(ParameterTypes::Type, ParseBuffer&, const 
char*);
+      typedef Parameter* (*CreateFactory)(ParameterTypes::Type);
 
       static Factory ParameterFactories[MAX_PARAMETER];
+      static CreateFactory ParameterCreateFactories[MAX_PARAMETER];
       static Data ParameterNames[MAX_PARAMETER];
 };
  
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/ParameterTypes.cxx 
resiprocate-0.9.0-5788/resip/stack/ParameterTypes.cxx
--- resiprocate-0.9.0-5788.orig/resip/stack/ParameterTypes.cxx  2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/ParameterTypes.cxx       2006-04-25 
16:30:02.000000000 +0200
@@ -12,6 +12,7 @@
 _enum##_Param::_enum##_Param()                                                 
 \
 {                                                                              
 \
    ParameterTypes::ParameterFactories[ParameterTypes::_enum] = Type::decode;   
 \
+   ParameterTypes::ParameterCreateFactories[ParameterTypes::_enum] = 
Type::create;    \
    ParameterTypes::ParameterNames[ParameterTypes::_enum] = _name;              
 \
 }                                                                              
 \
 _enum##_Param resip::p_##_enum
@@ -23,6 +24,8 @@
 using namespace resip;
 
 ParameterTypes::Factory 
ParameterTypes::ParameterFactories[ParameterTypes::MAX_PARAMETER] = {0};
+ParameterTypes::CreateFactory
+ParameterTypes::ParameterCreateFactories[ParameterTypes::MAX_PARAMETER] = {0};
 Data ParameterTypes::ParameterNames[ParameterTypes::MAX_PARAMETER] = 
{"PARAMETER?"};
 
 defineParam(data, "data", ExistsParameter, "callee-caps");
@@ -130,6 +133,7 @@
 Qop_Factory_Param::Qop_Factory_Param()
 {
    ParameterTypes::ParameterFactories[ParameterTypes::qopFactory] = 
Type::decode;
+   ParameterTypes::ParameterCreateFactories[ParameterTypes::qopFactory] = 
Type::create;
    ParameterTypes::ParameterNames[ParameterTypes::qopFactory] = "qop";
 }
 Qop_Factory_Param resip::p_qopFactory;
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/ParserCategory.cxx 
resiprocate-0.9.0-5788/resip/stack/ParserCategory.cxx
--- resiprocate-0.9.0-5788.orig/resip/stack/ParserCategory.cxx  2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/ParserCategory.cxx       2006-04-25 
16:30:07.000000000 +0200
@@ -303,6 +303,14 @@
    return 0;
 }
 
+ParserCategory::ParameterList
+ParserCategory::parameters() const
+{
+   ParameterList params(mParameters.begin(), mParameters.end());
+   params.insert(params.end(), mUnknownParameters.begin(), 
mUnknownParameters.end());
+   return params;
+}
+
 void
 ParserCategory::setParameter(const Parameter* parameter)
 {
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/ParserCategory.hxx 
resiprocate-0.9.0-5788/resip/stack/ParserCategory.hxx
--- resiprocate-0.9.0-5788.orig/resip/stack/ParserCategory.hxx  2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/ParserCategory.hxx       2006-04-25 
15:42:43.000000000 +0200
@@ -166,6 +166,8 @@
       Parameter* getParameterByEnum(ParameterTypes::Type type) const;
       void removeParameterByEnum(ParameterTypes::Type type);
       void setParameter(const Parameter* parameter);
+      typedef std::vector<Parameter*> ParameterList;
+      ParameterList parameters() const;
 
    protected:
       ParserCategory();
@@ -175,7 +177,6 @@
 
       virtual const Data& errorContext() const;
 
-      typedef std::vector<Parameter*> ParameterList; 
       mutable ParameterList mParameters;
       mutable ParameterList mUnknownParameters;
       Headers::Type mHeaderType;
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/QopParameter.cxx 
resiprocate-0.9.0-5788/resip/stack/QopParameter.cxx
--- resiprocate-0.9.0-5788.orig/resip/stack/QopParameter.cxx    2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/QopParameter.cxx 2006-04-25 
15:43:48.000000000 +0200
@@ -36,6 +36,12 @@
    }
 }
 
+Parameter*
+QopParameter::create(ParameterTypes::Type type)
+{
+   return new DataParameter(ParameterTypes::qop);
+}
+
 /* ====================================================================
  * The Vovida Software License, Version 1.0 
  * 
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/QopParameter.hxx 
resiprocate-0.9.0-5788/resip/stack/QopParameter.hxx
--- resiprocate-0.9.0-5788.orig/resip/stack/QopParameter.hxx    2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/QopParameter.hxx 2006-04-25 
15:43:53.000000000 +0200
@@ -14,6 +14,7 @@
 {
    public:
       static Parameter* decode(ParameterTypes::Type type, ParseBuffer& pb, 
const char* terminators);
+      static Parameter* create(ParameterTypes::Type type);
    private:
       QopParameter();
 };
diff -Naur resiprocate-0.9.0-5788.orig/resip/stack/RportParameter.hxx 
resiprocate-0.9.0-5788/resip/stack/RportParameter.hxx
--- resiprocate-0.9.0-5788.orig/resip/stack/RportParameter.hxx  2006-01-12 
16:58:40.000000000 +0100
+++ resiprocate-0.9.0-5788/resip/stack/RportParameter.hxx       2006-04-25 
15:42:43.000000000 +0200
@@ -24,6 +24,10 @@
       {
          return new RportParameter(type, pb, terminators);
       }
+      static Parameter* create(ParameterTypes::Type type)
+      {
+         return new RportParameter(type);
+      }
 
       int& port() {return mValue;}
       int port() const {return mValue;}