Hello All,
        I wrote a simple sofia-sip application that REGISTER itself to a proxy, 
send a SUBSCRIBE, an (un)SUBSCRIBE and (un)REGISTER (see flow and code below).
In response to the last NOTIFY (after the (un)SUBSCRIBE) sofia-sip sends 481 
Call Does Not Exist.
In my opinion it is not correct. The correct answer should be 200 OK since 
dialog must be destroyed on incoming NOTIFY with Subscription-State: terminated 
(RFC3265)
Do you agree ?
If so, am I doing something wrong with the code ?
Thank you very much in advance for your help
Regards,
Filippo Della Betta

P.S. I can provide to you with level 9 sofia-sip log and much more detailed SIP 
flow if you need it.

REGISTER                --->
200 OK                  <---
SUBSCRIBE               --->
200 OK                  <---
NOTIFY                  <---
200 OK                  --->
SUBSCRIBE (Expires=0)   --->
200 OK                  <---
NOTIFY                  <---
481 Call Does Not Exist --->
REGISTER (Expires=0)    --->
200 OK                  <---




#include <stdio.h>
#include <sofia-sip/su.h>
#include <sofia-sip/sdp.h>
#include <nua_stack.h>
#include <sofia-sip/nua.h>
#include <sofia-sip/nta.h>
#include <sofia-sip/soa.h>
#include <sofia-sip/sdp.h>
#include <sofia-sip/tport.h>
#include <sofia-sip/sip_protos.h>
#include <sofia-sip/su_log.h>

su_home_t * g_h3 = NULL;

void nua_callback3(nua_event_t event,
                               int status, char const *phrase,
                               nua_t *nua, nua_magic_t *magic,
                               nua_handle_t *nh, nua_hmagic_t *hmagic,
                               sip_t const *sip,
                               tagi_t tags[])
{
        printf ("nua_callback> %s status %d %s\n",
          nua_event_name (event), status, phrase);
}


int main(int argc, char* argv[])
{
        const char *UserAgent = "sofiaapp";
        const char *UserName = "+393351234567";
        const char *Proxy = "10.0.0.10";
        const int ProxyPort = 5060;
        const char *Domain = "domain.com";
        const int LocalPort = 7191;
        const int Expires = 900;

        su_init();
        int level = 9;
        su_log_set_level(NULL,level);

        g_h3 = su_home_create( );
        su_root_t *r = su_root_create(NULL);
        char *url = su_sprintf( g_h3, "sip:0.0.0.0:%d",LocalPort );
        char *proxy = NULL;
        if (ProxyPort == 5060) {
                proxy = su_sprintf( g_h3, "sip:%s", Proxy);
        } else {
                proxy = su_sprintf( g_h3, "sip:%s:%d" ,Proxy, ProxyPort  );
        }
        char *route = su_sprintf( g_h3, "<%s;lr>",proxy);

        nua_t *n = nua_create(r, nua_callback3 ,NULL,  
/*NTATAG_SIPFLAGS(MSG_FLG_COMPACT),*/ NTATAG_DEFAULT_PROXY(proxy), 
TPTAG_TOS(160), SIPTAG_USER_AGENT_STR(UserAgent), NUTAG_URL(url), TAG_END());

        nua_handle_t *nrh = nua_handle( n, NULL, TAG_END());
        nua_handle_t *nsh = nua_handle( n, NULL, TAG_END());

        char *reg = su_sprintf( g_h3, "sip:[EMAIL PROTECTED]",UserName,Domain);
        char *expires = su_sprintf( g_h3, "expires=%d",Expires);
        nua_register( nrh, SIPTAG_FROM_STR(reg),
                SIPTAG_ROUTE_STR(route),
                SIPTAG_TO_STR(reg),
                NUTAG_M_FEATURES(expires),
                NUTAG_PATH_ENABLE(0),
                TAG_END() );
        su_root_sleep(r, 2000);

        nua_subscribe(nsh,
                NUTAG_URL(reg),
                SIPTAG_ROUTE_STR(route),
                SIPTAG_FROM_STR(reg),
                SIPTAG_TO_STR(reg),
                SIPTAG_EXPIRES_STR("3600"),
                SIPTAG_EVENT_STR("presence.winfo"),
                SIPTAG_ACCEPT_STR("application/watcherinfo+xml"),
                TAG_END());
        su_root_sleep(r, 4000);

        nua_unsubscribe(nsh,
                SIPTAG_EVENT_STR("presence.winfo"),
                TAG_END());
        su_root_sleep(r, 2000);

        nua_unregister( nrh, TAG_END() );
        su_root_sleep(r, 2000);

        nua_handle_destroy( nrh );
        nua_handle_destroy( nsh );

        nua_shutdown(n);

        su_root_sleep(r, 2000);

        nua_destroy(n);

        su_root_destroy(r);
        su_home_unref( g_h3 );
        su_deinit();
        getchar();
        return 0;
}




--------------------------------------------------------------------

CONFIDENTIALITY NOTICE

This message and its attachments are addressed solely to the persons above and 
may contain confidential information. If you have received the message in 
error, be informed that any use of the content hereof is prohibited. Please 
return it immediately to the sender and delete the message. Should you have any 
questions, please contact us by replying to [EMAIL PROTECTED]

        Thank you

                                        www.telecomitalia.it

--------------------------------------------------------------------
                        

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to