< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[SIPfoundry] Help with osip_message_to_str and osip_message_set_body functions


Hello ALL!

Those are my allmost first steps in SIP programming and practical programming too. So i am sorry to bothe you with my questions. I have next function for building an INVITE message:

osip_message_t* Build_Invite_Mesg ( char *to, /* sip URI */

char *from, /* sip URI */

char *subject, /* text */

char *transport, /* TCP / UDP / TLS */

char *local_host,

short local_port)

{

 

/* Section 8.1:

* A valid request contains at a minimum "Request, To, From, Call-iD, Cseq,

* Max-Forwards and Via */

static osip_message_t *invite = 0;

osip_call_id_t *callid = 0;

osip_cseq_t *cseq = 0;

osip_header_t *header2;

char tmp[200];

int i;

char *buffer;

 

i = osip_message_init (&invite);

/* INVITE request */

osip_message_set_method (invite, osip_strdup ("INVITE"));

osip_message_set_version (invite, osip_strdup ("SIP/2.0"));

osip_message_set_status_code (invite, 0);

osip_message_set_reason_phrase (invite, NULL);

/* To */

i = osip_message_set_to (invite, to);

/* No route set (outbound proxy) is used */

/* The UAC must put the remote target URI (to field) in the req_uri */

i = osip_uri_clone (invite->to->url, &(invite->req_uri));

/* From */

i = osip_message_set_from (invite, from);

/* add a tag to the from field */

i = osip_from_set_tag (invite->from, (char *) strdup ("1234567"));

/* call id */

i = osip_call_id_init (&callid);

osip_call_id_set_number (callid, (char *) strdup ("abcdefghijk"));

osip_call_id_set_host (callid, osip_strdup (local_host));

invite->call_id = callid;

/* cseq */

i = osip_cseq_init (&cseq);

osip_cseq_set_number (cseq, osip_strdup ("20")); /* always start with 20... */

osip_cseq_set_method (cseq, osip_strdup ("INVITE"));

invite->cseq = cseq;

/* max forwards */

osip_message_set_max_forwards (invite, SIP_MAX_FORWARDS); /* a UA should start a request with 70 */

/* Via */

sprintf (tmp, "SIP/2.0/%s %s:%i;branch=z9hG4bK%u", transport, local_host,

local_port, strdup ("2asssadv"));

osip_message_set_via (invite, tmp);

/* subject */

osip_message_set_subject (invite, subject);

osip_message_set_allow (invite, "INVITE");

osip_message_set_allow (invite, "ACK");

osip_message_set_allow (invite, "CANCEL");

osip_message_set_allow (invite, "BYE");

 

osip_message_set_allow (invite, "OPTIONS");

osip_message_set_allow (invite, "REFER");

osip_message_set_allow (invite, "SUBSCRIBE");

osip_message_set_allow (invite, "NOTIFY");

osip_message_set_allow (invite, "MESSAGE");

 

osip_message_set_contact (invite, "amith@xxxxxxxxxxxxx");

 

osip_header_init (&header2);

osip_header_set_name (header2, "Content-Type");

osip_header_set_value (header2, "application/sdp");

osip_list_add (invite->headers, header2, -1);

 

osip_message_set_body (invite, sdp);

 

if( osip_message_to_str(invite, &buffer) == 0)

printf(" Message Invite = %s", buffer);

else

SIPXtrace(SIPX_ERROR, INFO, "Message parsing failed");

return (osip_message_t *) invite;

}

My problem is: "osip_message_to_str(invite, &buffer)" and osip_message_set_body (invite, sdp). According to LiboSip library both function should get three parameters. Where do i get from or how do i know the third parameter.

Thanks anyway and sorry again for bothering