Re: [Sofia-sip-devel] How to free a sdp_session_t struct

2008-09-01 Thread Stefano Sabatini
On Fri, Aug 29, 2008 at 5:27 PM,  [EMAIL PROTECTED] wrote:
 Hi,

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of ext Stefano Sabatini
Sent: Friday, August 29, 2008 6:24 PM
To: sofia-sip-devel@lists.sourceforge.net
Subject: [Sofia-sip-devel] How to free a sdp_session_t struct

Hi all sofia-sippers,

I'm looking for the best method to free an sdp_session_t struct.

I see there is an sdp_session_dup() function, and there are
sdp_printer_free() and sdp_parser_free(), so I was expecting some
method such as sdp_session_free().

Missing that, then I wonder if its absence means something, for
example that there is some convenient method to free an sdp_session_t.

Can you give some hint?

 Free the home used for allocating the session.

Hi, and thanks for the reply.
Yes that's a solution, nonetheless it looks still weird to me, to have
to use an home just for that seems
overkill.

Also, I wonder which is the supposed way to fill an SDP from scratch.
I can't see any specific function for doing that (e.g. add a
connection, add a media etc.)
and doing it manually is tedious.

So I suppose that the supposed way to create an SDP from scratch is to
write it down in its textual form *then*
convert it using an sdp_parser_t, otherwise maybe I have to use some
higher level function not provided in
the sdp module (soa?).

Am I right?

Regards.

-
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=100url=/
___
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel


Re: [Sofia-sip-devel] How to free a sdp_session_t struct

2008-09-01 Thread Stefano Sabatini
On Mon, Sep 1, 2008 at 9:24 AM, Stefano Sabatini [EMAIL PROTECTED] wrote:
 On Fri, Aug 29, 2008 at 5:27 PM,  [EMAIL PROTECTED] wrote:
 Hi,

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of ext Stefano Sabatini
Sent: Friday, August 29, 2008 6:24 PM
To: sofia-sip-devel@lists.sourceforge.net
Subject: [Sofia-sip-devel] How to free a sdp_session_t struct

Hi all sofia-sippers,

I'm looking for the best method to free an sdp_session_t struct.

I see there is an sdp_session_dup() function, and there are
sdp_printer_free() and sdp_parser_free(), so I was expecting some
method such as sdp_session_free().

Missing that, then I wonder if its absence means something, for
example that there is some convenient method to free an sdp_session_t.

Can you give some hint?

 Free the home used for allocating the session.

 Hi, and thanks for the reply.
 Yes that's a solution, nonetheless it looks still weird to me, to have
 to use an home just for that seems
 overkill.

There is also this problem. Assuming that I have to pass around the
allocated home, I can't use a stack allocated home, so I
have to use su_home_new() (here choosing an arbitrary size value...).

Then I think there is no way to know the home used by an sdp_session_t
object, so I would have to pass around the home
object to which the sdp_session_t is bound, which is pretty awkward,
*either* to have a memleak.

[...]

Regards.

-
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=100url=/
___
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel


[Sofia-sip-devel] Stop the nua stack

2008-09-01 Thread RĂ©mi BUISSON
Hi everyone,

I didn't success in stopping the nua stack.

Here is my client code :
#include stdio.h
#include stdlib.h
#include string.h

#include libxml/parser.h

#include sofia-sip/nua.h

#include constants.h
#include macros.h
#include xml_parser.h

/***/
/* Variables declaration   */
/***/

/* application context information structure */
typedef struct application
{
  su_home_t home[1];  /* memory home */
  su_root_t *root; /* root object */
  nua_t *nua;  /* NUA stack object */
  nua_handle_t *handle;
} application;

/* Application context structure */
application appl[1];

/***/
/* Functions declaration   */
/***/
static void eventCallBack(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[]);
static void sendMessage(const char *dest,
const char *content);

/***/
/* Main function   */
/***/
int main(int argc, char **argv){
  char *ccpp = NULL;
  printDebug(ccpp : %s\n, (ccpp=createXMLCCPP()));

  sendMessage(sip:[EMAIL PROTECTED]:1234,
  ccpp);

  xmlFree((xmlChar *)ccpp);

  return EXIT_SUCCESS;
}

/***/
/* Implementation of functions */
/***/

/* This callback will be called by SIP stack to
 * process incoming events
 */
void eventCallBack(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[])
{
  printDebug(%s received MESSAGE: %03d %s\n, __FILE__, status, phrase);
 
  if(sip)
{
  printDebug(From: %s%s URL_PRINT_FORMAT \n,
 sip-sip_from-a_display ? sip-sip_from-a_display : ,
 sip-sip_from-a_display ?   : ,
 URL_PRINT_ARGS(sip-sip_from-a_url));
}
 
  if(sip  sip-sip_subject)
{
  printDebug(Subject: %s\n, sip-sip_subject-g_value);
}
 
  if(sip  sip-sip_content_type)
{
  printDebug(Content-type: %s\n, sip-sip_content_type-c_type);
}
 
  if(sip  sip-sip_payload)
{
  printDebug(Content: %s\n, sip-sip_payload-pl_data);
  /*fwrite(sip-sip_payload-pl_data, sip-sip_payload-pl_len, 1, 
stdout);
fputs(\n, stdout);*/
 
}

  /* if(sip-sip_payload  strcmp(sip-sip_payload-pl_data, TEARDOWN) 
== 0)
{
  su_root_break(root);
  }*/

  if (status == STATUS_OK) {
printDebug(end\n);
/*su_root_break(appl-root); * I 
would like to stop here */
return;
  }
}

void sendMessage(const char *dest,
 const char *content)
{
  nua_handle_t *handle;
  char buff[BUFFER_SIZE];

  /* initialize Sofia-SIP library and create event loop */ 
  su_init();

  /* initialize memory handling */
  su_home_init(appl-home);

  /* initialize root object */
  appl-root = su_root_create(appl);
 
  if (appl-root != NULL)
{
  /* create a user agent instance. Caller and callee should bind to 
different
   * address to avoid conflicts. The stack will call the 
'eventCallBack()'
   * callback when events such as succesful registration to network,
   * an incoming call, etc, occur.
   */
  appl-nua = nua_create(appl-root, /* Event loop */
 eventCallBack, /* Callback for processing events */
 appl, /* Additional data to pass to callback */
 NUTAG_URL(sip:0.0.0.0:2345;transport=tcp), /* Address 
to bind to */
 TAG_END()); /* Last tag should always finish the 
sequence */
  if (appl-nua != NULL)
{
  /* set necessary parameters */
  nua_set_params(appl-nua,
 /* tags as necessary ... */
 TAG_NULL());

  /* send the informations */
  appl-handle = nua_handle(appl-nua, NULL, SIPTAG_TO_STR(dest), 
TAG_END());
 
  nua_message(appl-handle,
  SIPTAG_CONTENT_TYPE_STR(application/XML),
  SIPTAG_PAYLOAD_STR(content),
  TAG_END());
 
  nua_handle_destroy(appl-handle);

  /* enter main loop for processing of messages */
  su_root_run(appl-root);
 
  /* destroy NUA stack */
  nua_destroy(appl-nua);
}
 
  /* deinit root object */
  su_root_destroy(appl-root);
  appl-root = NULL;
}
 
  /* deinitialize memory handling */
  su_home_deinit(appl-home);
 
  /* deinitialize system utilities */
  su_deinit();
}


I would like it to send a message with XML content and stop the client 
but I got this message :
nua_destroy(0x80c87f0): FATAL: nua_shutdown not completed
client: nua.c:235: nua_destroy: Assertion 

Re: [Sofia-sip-devel] How to free a sdp_session_t struct

2008-09-01 Thread Stefano Sabatini
On 9/1/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of ext Stefano Sabatini
Sent: Monday, September 01, 2008 3:44 PM
To: sofia-sip-devel@lists.sourceforge.net
Subject: Re: [Sofia-sip-devel] How to free a sdp_session_t struct

 Free the home used for allocating the session.

 Hi, and thanks for the reply.
 Yes that's a solution, nonetheless it looks still weird to
me, to have
 to use an home just for that seems
 overkill.

 There is also this problem. Assuming that I have to pass around the
 allocated home, I can't use a stack allocated home, so I
 have to use su_home_new() (here choosing an arbitrary size value...).

 Then I think there is no way to know the home used by an
sdp_session_t
 object, so I would have to pass around the home
 object to which the sdp_session_t is bound, which is pretty awkward,
 *either* to have a memleak.

Another solution could be to pass around sdp_parser_t rather than
sdp_session_t, then
use sdp_session() to get the sdp_session_t from the parser and free
both parser and
session with sdp_parser_free(), do you think this is an
acceptable solution?

But still this looks like a strange solution and not particularly
convenient (why to pass around the whole parser if what I need is just
the session?), and is the reason for which I was looking for an
sdp_session_free() function.

 I guess you don't really want to keep the parser state.
 A home is a pool for allocated memory in the Sofia stack, so yes, you need
 to pass it around to wherever you free the sdp_session_t.

Thanks for the reply Mikhail.

So if I understood it correctly I need to keep an home just for every
sdp_session_t.

So my next obvious question is: it would be possible to change the API
and implement an
sdp_session_free() function? The sdp_session_t could inherit the home
of the sdp_parser which
creates it, or if created from scratch (sdp_session_create(home)?) it
would require an home as argument.

Not sure if this is possible to do without to break backward compatibility.

And still I have the sensation I'm doing something very strange with
my code, if no one ever had felt the necessity for a such facility
(I'm using the sdp_session_t to store an SDP in a C-language-friendly
manner)...

Kind regards.

-
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=100url=/
___
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel


[Sofia-sip-devel] tcp transportation using only one connection

2008-09-01 Thread Florian Limberger
Hi!

When using UDP for transportation the sofia-sip stack uses the same 
socket (same src port) for all outgoing logical connections. This is not 
the case with tcp. If I want to do a REGISTER with my proxy/registrar, 
the sip stack creates a new tcp connection (with some arbitrary src 
port) but does not insert this arbitrary port into the contact header. 
Instead, the contact header's port is set to the one of the tcp-server 
socket listening in general at port 5060. Hence, the registrar opens a 
new tcp-connection to my UA.

So could someone give me please a hint how to force the REGISTER-socket 
to a port of my choice or how to get the real port into the 
contact-header-line? Or is there any other possibility to have only ONE 
tcp connection to my register with the UA always being the client?

thanks for any advice,
cheers,
flo

-
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=100url=/
___
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel


[Sofia-sip-devel] Simple NTA processing...

2008-09-01 Thread Stuart Whelan
Hi Folks,

I need to implement a sip registar and presence server into an
existing application...

My first step down this road was to attempt to build as simple a
registar server as possible in order to aid understand sofia-sip and
sip in general.

I have come up with the following code, which seems to let me
register, but I bet invalid status from callback messages... I am not
sure what this means or where I should be going to find a clue to the
solution.

Can anyone assist?

Any other comments on how I am using NTA are apprecated, but please
keep in mind this is toss away code and is not meant to be complete.
:)

The output I am getting is:

Got Root
Got Agent
Got Default Leg
Incoming Request
Register: REGISTER
nta_leg(0x804c430): invalid status -1208623345 from callback

/*
 * siptest.c
 *
 *  Created on: 1/09/2008
 *  Author: whelans
 */

#include siptest.h
#include sofia-sip/nta.h
#include sofia-sip/su.h
#include sofia-sip/sip_status.h

int process_nta_request(nta_agent_magic_t *context, nta_agent_t
*agent,  nta_incoming_t *irq, sip_t *sip);

su_root_t *reg_root;
nta_agent_t *reg_agent;
nta_leg_t *default_leg;
su_root_magic_t *app;

int main(int argc, char **argv)
{
  reg_root = su_root_create(app);

  if (reg_root)
  {
printf(Got Root\n);
reg_agent = nta_agent_create(reg_root, (url_string_t*) argv[1],
NULL, NULL, TAG_END());

if (reg_agent)
{
  printf(Got Agent\n);
  default_leg = nta_leg_tcreate(reg_agent, process_nta_request,
app, NTATAG_NO_DIALOG(1),
  TAG_END());
  printf(Got Default Leg\n);
  su_root_run(reg_root);
  nta_agent_destroy(reg_agent);
}

su_root_destroy(reg_root);
  }
  return 0;
}

int process_nta_request(nta_agent_magic_t *context, nta_agent_t
*agent,  nta_incoming_t *irq, sip_t *sip)
{
  printf(Incoming Request\n);
  sip_contact_t *m;
  switch( sip-sip_request-rq_method)
  {
  casesip_method_register: printf(Register: %s\n,
sip-sip_request-rq_method_name ); break;
  default: printf(Default: %s\n,
sip-sip_request-rq_method_name );
  }
  nta_incoming_treply(irq, SIP_200_OK, TAG_END());
  return SIP_200_OK;
}

-
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=100url=/
___
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel