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

Re: [reSIProcate] [resiprocate] New headers and parameters from RFC 3455 and UUI drafts (#6)


Hello John,
Thank you very much for your help.
Yesterday, after sending the mail, I thought a similar solution, but I used 
ParseBuffer class to parse icid-value in first position.
The result is a code that is more complex than that you wrote. I send a portion 
of my code if it can be useful to someone in the list, or if anyone has any 
comment about it.
Best regards,
Dario.

Token chargingVectorToken;
Data data(Data::from(msg.header(h_PChargingVector).c_str()));
ParseBuffer buffer(data);
chargingVectorToken.parse(buffer);
if (chargingVectorToken.exists(p_icidValue)) {
    // use chargingVectorToken.param(p_icidValue).c_str()
}
else {
    try {
        // handle icid-value in first position
        Data icidValueData(Data::from(msg.header(h_PChargingVector).c_str()));
        ParseBuffer icidValueBuffer(data);
        if (!icidValueBuffer.eof()) {
            icidValueBuffer.skipWhitespace();
            if (!icidValueBuffer.eof()) {
                // extract the key
                const char* keyStart = icidValueBuffer.skipWhitespace();
                static const std::bitset<256> terminators1 = Data::toBitset(" 
\t\r\n;=?>");
                const char* keyEnd = icidValueBuffer.skipToOneOf(terminators1);
                if ((int)(keyEnd - keyStart) > 0) {
                    ParameterTypes::Type type = 
ParameterTypes::getType(keyStart, (unsigned int)(keyEnd - keyStart));
                    if (type == ParameterTypes::icidValue) {
                        static const std::bitset<256> terminators2 = 
Data::toBitset(" \t\r\n;?>");
                        DataParameter icidValueParam(ParameterTypes::icidValue, 
icidValueBuffer, terminators2);
                        // use icidValueParam.value().c_str()
                    }
                }
            }
        }
    }
    catch (resip::BaseException& ex) {
        // handle parsing error, if any
    }
}

-----Original Message-----
From: John Gregg [mailto:jgregg@xxxxxxxxx] 
Sent: giovedì 2 ottobre 2014 21.37
To: resiprocate-devel@xxxxxxxxxxxxxxx
Cc: Dario Bozzali
Subject: Re: [reSIProcate] [resiprocate] New headers and parameters from RFC 
3455 and UUI drafts (#6)


Dario-

WRT P-Charging-Vector, here is what we do. We are a B2BUA, so we just pass the 
PCV through when we receive it. That is, on the outbound side, we just copy 
whatever we got on the inbound side:

                 if (src->exists(h_PChargingVector))
                 {
                     dest.header(h_PChargingVector) = 
src->header(h_PChargingVector);
                 }

On the inbound side, for various accounting reasons, we do parse PCV out into 
our own internal objects (pChargingVecor_):

     if (msg.exists(h_PChargingVector))
     {
         // HACK: if the header starts out with a parameter, resiprocate
         // regards it as the value. We must parse it out here by hand.
         std::string val(msg.header(h_PChargingVector).value().c_str());

         if (val.find("icid-value=") == 0)
         {
pChargingVector_.icidValue(val.substr(11).c_str());
         }

         if (msg.header(h_PChargingVector).exists(p_icidValue))
         {
pChargingVector_.icidValue(msg.header(h_PChargingVector).param(p_icidValue).c_str());
         }
         if (msg.header(h_PChargingVector).exists(p_icidGeneratedAt))
         {
pChargingVector_.icidGen(msg.header(h_PChargingVector).param(p_icidGeneratedAt).c_str());
         }
         if (msg.header(h_PChargingVector).exists(p_origIoi))
         {
pChargingVector_.origIoi(msg.header(h_PChargingVector).param(p_origIoi).c_str());
         }

...
     }

So yes, it is a pain that RFC 3455 specifies a syntax for PCV where everything 
is a parameter, and there is no "value". We manage to avoid dealing with 
generating it on the outbound side, and use the above parsing hack to derive 
the value on the inbound side.

I hope this helps,

-John Gregg



On 10/02/2014 09:43 AM, Dario Bozzali wrote:
> Hi all,
> I'm executing some additional tests on new headers. I have a couple of 
> doubts, but I don't know if there is a bug in the pull request or in my test 
> scenarios.
>
> Scenario 1 related to User-to-User header.
> How to parse the following header?
> User-to-User: "the quick silver fox jumped over the lazy brown 
> dog";encoding=hex When I try to get the value of the header I obtain the 
> string ""the" because Token::parse() method skip till first whitespace or 
> semicolon.
>
> Scenario 2 related to P-Charging-Vector header.
> P-Charging-Value has icid-value mandatory parameter and other optional 
> parameters. I understood that it should be modelled as a Token with empty 
> value, but in this way one ";" is inserted before icid-value.
> Example:
>       P-Charging-Vector: 
> ;icid-value=B6012049-0080-42D3-982E-473B24816316;icid-generated-at=192
> .168.56.1;orig-ioi=myserver
>
> What is the right way to set header value?
> Should I use a icid-value parameter to set P-Charging-Vector value?
>
> Something like this:
>
>       Token chargingVectorToken;
>       DataParameter icidValueParam(ParameterTypes::icidValue);
>       icidValueParam.value() = Data("B6012049-0080-42D3-982E-473B24816316");
>       Data icidData;
>       DataStream icidDataStream(icidData);
>       icidValueParam.encode(icidDataStream);
>       chargingVectorToken.value() = icidData;
>       chargingVectorToken.param(p_icidGeneratedAt) = Data("192.168.56.1");
>       chargingVectorToken.param(p_origIoi) = Data("myserver");
>
> Maybe John Gregg could help me on this.
>
> Thank you in advance and kind regards.
>
> Dario
>
> -----Original Message-----
> From: resiprocate-devel 
> [mailto:resiprocate-devel-bounces@xxxxxxxxxxxxxxx] On Behalf Of Dario 
> Bozzali
> Sent: martedì 23 settembre 2014 18.34
> To: 'Daniel Pocock'
> Cc: resiprocate-devel@xxxxxxxxxxxxxxx
> Subject: Re: [reSIProcate] [resiprocate] New headers and parameters 
> from RFC 3455 and UUI drafts (#6)
>
> Hi Daniel,
> Excluding DayOfWeekHash and MonthHash from build I was able to compile 
> without changing DateCategory.cxx.
> DayOfWeekHash and MonthHash are built because tool configured in project is 
> "C/C++ Compiler Tool" instead of "Custom Build Tool" as per other header 
> files.
>
> Regards,
> Dario.
>
> -----Original Message-----
> From: Daniel Pocock [mailto:daniel@xxxxxxxxxx]
> Sent: martedì 23 settembre 2014 18.24
> To: Dario Bozzali
> Cc: resiprocate-devel@xxxxxxxxxxxxxxx
> Subject: Re: [resiprocate] New headers and parameters from RFC 3455 
> and UUI drafts (#6)
>
>
> Hi Dario,
>
> I notice that MethodHash is including string.h and ctype.h so I've 
> added those same includes to DateCategory.cxx so they will be included 
> before DayOfWeekHash and MonthHash
>
> Can you just confirm, Visual Studio is not trying to compile these cxx 
> files into separate objects?  It should only be including them when it 
> compiles DateCategory.cxx so they should all become part of the object 
> file DateCategory.o
>
> Regards,
>
> Daniel
>
> On 23/09/14 18:08, Dario Bozzali wrote:
>> Hi Daniel,
>> Below I reported the output obtained using Visual Studio 2005 to build 
>> master.
>> Dario.
>>
>> 1>DayOfWeekHash.cxx
>> 1>dayofweek.gperf(5) : error C2146: syntax error : missing ';' before 
>> identifier 'type'
>> 1>dayofweek.gperf(5) : error C4430: missing type specifier - int 
>> 1>assumed. Note: C++ does not support default-int
>> 1>dayofweek.gperf(5) : error C4430: missing type specifier - int 
>> 1>assumed. Note: C++ does not support default-int
>> 1>dayofweek.gperf(13) : error C2065: 'Sat' : undeclared identifier
>> 1>dayofweek.gperf(13) : error C2078: too many initializers
>> 1>dayofweek.gperf(8) : error C2065: 'Mon' : undeclared identifier
>> 1>dayofweek.gperf(7) : error C2065: 'Sun' : undeclared identifier
>> 1>dayofweek.gperf(10) : error C2065: 'Wed' : undeclared identifier
>> 1>dayofweek.gperf(11) : error C2065: 'Thu' : undeclared identifier
>> 1>dayofweek.gperf(12) : error C2065: 'Fri' : undeclared identifier
>> 1>dayofweek.gperf(9) : error C2065: 'Tue' : undeclared identifier
>> 1>dayofweek.gperf(20) : error C3861: 'strncmp': identifier not found 
>> 1>MonthHash.cxx
>> 1>month.gperf(5) : error C2146: syntax error : missing ';' before identifier 
>> 'type'
>> 1>month.gperf(5) : error C4430: missing type specifier - int assumed.
>> 1>Note: C++ does not support default-int
>> 1>month.gperf(5) : error C4430: missing type specifier - int assumed.
>> 1>Note: C++ does not support default-int
>> 1>month.gperf(12) : error C2065: 'Jun' : undeclared identifier
>> 1>month.gperf(12) : error C2078: too many initializers
>> 1>month.gperf(13) : error C2065: 'Jul' : undeclared identifier
>> 1>month.gperf(7) : error C2065: 'Jan' : undeclared identifier
>> 1>month.gperf(11) : error C2065: 'May' : undeclared identifier
>> 1>month.gperf(8) : error C2065: 'Feb' : undeclared identifier
>> 1>month.gperf(9) : error C2065: 'Mar' : undeclared identifier
>> 1>month.gperf(10) : error C2065: 'Apr' : undeclared identifier
>> 1>month.gperf(18) : error C2065: 'Dec' : undeclared identifier
>> 1>month.gperf(14) : error C2065: 'Aug' : undeclared identifier
>> 1>month.gperf(15) : error C2065: 'Sep' : undeclared identifier
>> 1>month.gperf(16) : error C2065: 'Oct' : undeclared identifier
>> 1>month.gperf(17) : error C2065: 'Nov' : undeclared identifier
>> 1>month.gperf(28) : error C3861: 'strncmp': identifier not found
>>
>> -----Original Message-----
>> From: Daniel Pocock [mailto:daniel@xxxxxxxxxx]
>> Sent: martedì 23 settembre 2014 17.48
>> To: Dario Bozzali
>> Cc: resiprocate-devel@xxxxxxxxxxxxxxx
>> Subject: Re: [resiprocate] New headers and parameters from RFC 3455 
>> and UUI drafts (#6)
>>
>>
>>
>> On 23/09/14 17:42, Dario Bozzali wrote:
>>> Hi Daniel,
>>> I solved the compiling issue changing Visual Studio project settings to 
>>> exclude DayOfWeekHash.cxx and MonthHash.cxx from build. I commit this 
>>> change for every VS version.
>>> Now I will take a look at conflict issue.
>>
>> That sounds odd.  If you checkout the master branch, without any of your 
>> changes, does it build with those files included?
>>
>> If it doesn't build on master, can you tell me what error it gives?
>>
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxx
> https://list.resiprocate.org/mailman/listinfo/resiprocate-devel
>
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxx
> https://list.resiprocate.org/mailman/listinfo/resiprocate-devel