Hi,

I've been trying to set up Kamailio 4.0.5 as a P-CSCF, I-CSCF and S-CSCF today, and hit a few issues which I've fixed. http://sip-router.org/contribute/ suggests that patches should be submitted to this list, so here I am.

The first issue I hit was the sem_post issue that has been reported from time to time (http://lists.kamailio.org/pipermail/sr-users/2013-January/076554.html) - it looks as though sem_post is only included in -lpthread on Ubuntu 12.04, not -lrt (https://bugs.launchpad.net/ubuntu/+source/manpages/+bug/874418), so I've updated some Makefiles to reflect that.

I subsequently hit a segfault when calling pcscf_save: I've tracked this down to a while loop that was missing curly braces, and so tried to dereference a null pointer. I think there's another bug in this piece of code - because h is NULL at the end of the first while loop, we never go round the second loop, and so never call free_rr. It looks like even if we did, h->parsed has been set to 0 before we try and free it, so nothing would happen. I wasn't sure how the memory management here works, though, and so haven't tried to change this.

I also found that the ims_auth module didn't handle standard SIP Digest authentication on the MAR interface, only AKA and Digest-MD5 (which seems to be specific to OpenIMSCore HSS, and not mentioned in the IMS specs). Most of the code to allow SIP Digest authentication was already there, so I just hooked the last piece in to get it to work. I'm not sure whether this counts as a new feature or a bugfix - it's not clear whether this was meant to be supported but just missing a piece, or not meant to be supported but very easy to add in.

Finally, I was working from the 4.0 nightlies Debian repository, and the examples/scsf/kamailio.cfg file for 4.0.x seems to skip authentication. It looks like this section has been reworked heavily in 4.1.0, so this may be less important - but I put together a different kamailio.cfg based on a mailing list post (http://lists.sip-router.org/pipermail/sr-users/2013-March/077142.html), and it might make sense to use that as the default file for 4.0.x.

The attached patches are against the 4.0 branch in Git (specifically, commit 1b98961522fd8a7eb73ecc7d1772541f8b81aabc). I'm happy to apply any feedback which more knowledgeable contributors have.

Best regards,
Rob