[Sofia-sip-devel] Probleme with machine state on INVITE request

2007-03-01 Thread moreauf
I have a problem with this following code :

#include stdio.h
#include stdlib.h
#include sofia-sip/nua.h
#include sofia-sip/soa.h

// GLOBAL VARIABLES
//SIP
su_root_t * root;
nua_t * nua;
soa_session_t * soa;

void event_callback(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(I have received an event %s status %d: %s\n,  
nua_event_name (event), status , phrase );

switch(event) {
case nua_i_invite:
if (nh ==NULL) nh = nua_handle(nua,magic, TAG_END());
 nua_respond(nh,200,OK, TAG_END());
break;;

case nua_i_bye:
if (nh ==NULL) nh = nua_handle(nua, magic, TAG_END());
nua_respond(nh, 200, OK, TAG_END() );
nua_handle_destroy(nh);
break;;

default:;
};
};

void main( ) {
  su_init();
  root = su_root_create(NULL);
  nua = nua_create(root,event_callback , NULL,
  NUTAG_URL(sip:0.0.0.0:5060), TAG_END());

  nua_set_params(nua, NUTAG_ENABLEINVITE(1),
NUTAG_AUTOALERT(1), TAG_END());
  su_root_run(root);
};

With this code , I hope that every incomming INVITE message become a  
SIP connection.
My console has this result.

I have received an event nua_i_invite status 180: Ringing
I have received an event nua_i_state status 180: Ringing
I have received an event nua_r_set_params status 200: OK
I have received an event nua_i_error status 500: No session set by user
I have received an event nua_i_state status 500: No session set by user
I have received an event nua_i_terminated status 500: No session set  
by user.

In despite of errors and terminated status, the good packets are send  
on the network at the right place. But unfortunately  the connection  
isn't etablished.

So It 's normal that when the code receive a BYE request, it respond  
by 481 : Call Does Not Exist status.

What error(s) I have done ?

Thank you in advance,

Fabien




-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel


Re: [Sofia-sip-devel] Probleme with machine state on INVITE request

2007-03-01 Thread Kai Vehmanen
Hi,

On Thu, 1 Mar 2007, moreauf wrote:

   case nua_i_invite:
   if (nh ==NULL) nh = nua_handle(nua,magic, TAG_END());
nua_respond(nh,200,OK, TAG_END());
   break;;

I think the only thing you are missing is providing the SDP to use in the 
response. See for example:

- http://sofia-sip.org/repos/sofsip-cli/src/ssc_sip.c

... and search for nua_respond

   case nua_i_bye:
   if (nh ==NULL) nh = nua_handle(nua, magic, TAG_END());
   nua_respond(nh, 200, OK, TAG_END() );
   nua_handle_destroy(nh);

You don't need to respond separately to nua_i_bye with nua_respond() -- 
the stack will do this for you.

See the examples of terminating calls at:

- http://sofia-sip.sourceforge.net/refdocs/nua/

-- 
  under work: Sofia-SIP at http://sofia-sip.sf.net

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel