# Presence B2B UA

Vaclav
Kubart
Iptel/Tekelec
vaclav.kubart@iptel.org

This module acts as back to back user agent for presence events. In the future it will do subscriptions to reg events and presence with resource lists too.

It is accessible only using internal Querry Status API (QSA). Everywhere (in C code) you need subscriptions to presentity status, you only create an internal subscription to it and the rest is done by this module. It processes internal subscription and creates a SIP subscription (SUBSCRIBE-NOTIFY dialog) to requested presentity. Every NOTIFY request produces new QSA message with status information into destination message queue.

Instead of this module can be used PA module with parameter `accept_internal_subscriptions` set to 1. In that case the subscription will be only to internal status hold by PA.

For every requested (record, subscriber) is created new SIP subscription! This is due to authorization of such subscriptions - B2B UA can't decide about authorization rules, thus it has to leave it on the presence server to which it creates the subscription and this means, that it has to create the subscription as the subscriber. There is a possibility to do subscriptions with the same To + From only once, but this is left for future optimalizations (it will probably not help a lot).

## Dependencies

### Modules

- tm

- dialog

### Libraries

- libcds (internal)

- libpresence (internal)

## Usage

This module can be used by RLS module (e.g. RLS module does internal subscriptions to "presence" which can be handled by this module or PA module).

In near future it will be used by PA module for subscribing to users; this could be useful with UACs capable to process SUBSCRIBE/NOTIFY but not using PUBLISH for presence state publication (like Windows Messenger).

## Configuration example

    ...
    loadmodule "/home/kubartv/SER/lib/ser/modules/tm.so"
    loadmodule "/home/kubartv/SER/lib/ser/modules/dialog.so"
    loadmodule "/home/kubartv/SER/lib/ser/modules/presence_b2b.so"

    ...
    modparam("presence_b2b", "presence_route", "<sip:my-sip-server.domain.com;lr>")
    modparam("presence_b2b", "on_error_retry_time", 600)
    modparam("presence_b2b", "wait_for_term_notify", 33)
    modparam("presence_b2b", "resubscribe_delta", 15)
    modparam("presence_b2b", "min_resubscribe_time", 55)
    modparam("presence_b2b", "default_expiration", 667)
    ...

    route {

    	...

    	if (uri==myself) {

    		...

     		if (method=="NOTIFY") {
     			if (!t_newtran()) {
     			   log(1, "newtran error\n");
     			   sl_reply_error();
     			};
     			if (!handle_notify()) {
     				t_reply("481", "Unable to handle notification");
     			}
     			break;
     		};

    		...
    	}

    	...

    }