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

[reSIProcate-users] ExtensionHeader and comma-separated addr-spec


Hi

I am facing a problem where I need to parse multiple comma-separated
addresses from an extension header. The problem is that if there are
multiple addr-spec values in one header, the parser is not able
to split the values.

Consider the following code example:


                const ExtensionHeader h_fooHeader("P-FooHeader");

                if (msg->exists(h_fooHeader)) {

                    StringCategories &sc = msg->header(h_fooHeader);

                    for (StringCategories::iterator i = sc.begin(); i != 
sc.end(); ++i) {
                        const StringCategory &s = *i;
                        const Data foo(s.value());

                        printf("got foo-header: %s\n", foo.c_str());
                    }
               }


this code works for SIP messages like:

  P-FooHeader: <sip:foo@xxxxxxxxxxx>;param=1
  P-FooHeader: <sip:bar@xxxxxxxxxxx>;param=2

which will print out the two header entries.


But this code is not working for SIP messages like this:

  P-FooHeader: <sip:foo@xxxxxxxxxxx>;param=1, <sip:baz@xxxxxxxxxxx>;param=0
  P-FooHeader: <sip:bar@xxxxxxxxxxx>;param=2


For my extension header I would like to parse and validate that the
content (Addr-Spec) is correct. For this I assume that NameAddr is the
best class to use.


How can I put the content of a StringCategory value into a new
NameAddr value, and iterate over all address fields inside the value?
I have looked at the documentation, but it does not mention this
special case. Are there any places in the code where similar stuff
is done?

Thanks in advance for any help!


/alfred