コード例 #1
0
ファイル: groups.c プロジェクト: gozfree/src
static int groups_load_members(grp_t *grp, char *members)
{
    char *dest;
    int index = 0;

    char *tmp = members;
    char *sep;
    sep = strchr(members, '|'); /* find beginning of prefix */

    while (sep!=NULL && index<MAX_MEMBERS)
    {
        dest = grp->members[index];
        if (sep-tmp<254)
            osip_strncpy(dest, tmp, sep-tmp);
        else
        {
            OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,
                                  "groups plugin: members url must be shorter than 254\n"));
        }

        index++;
        tmp = sep+1;
        sep = strchr(tmp, '|'); /* find beginning of prefix */
    }

    dest = grp->members[index];
    if (tmp!=NULL && strlen(tmp)<254)
    {
        osip_strncpy(dest, tmp, strlen(tmp));
    }

    for (index=0; index<MAX_MEMBERS; index++)
    {
        int i;
        osip_uri_t *uri;

        dest = grp->members[index];
        if (dest[0]=='\0')
            break;
        OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,
                              "groups plugin: members of %s: %s\n",
                              grp->group,
                              dest));

        osip_uri_init(&uri);
        i = osip_uri_parse(uri, dest);
        osip_uri_free(uri);
        if (i!=0)
        {
            OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,
                                  "groups plugin: Malformed members URL in group %s!\n",
                                  grp->group));
            return -1;
        }
    }

    return 0;
}
コード例 #2
0
ファイル: uriTest.cpp プロジェクト: aimer1027/linuxField
uri_t::uri_t ( char * c_u )
{
	osip_uri_t *temp_uri ;
   	
	osip_uri_init ( &temp_uri ) ;
	osip_uri_parse ( temp_uri , c_u ) ;
	
	uri = temp_uri ;
}
コード例 #3
0
int
main (int argc, char **argv)
{
  FILE *urls_file;


  osip_uri_t *url;
  char *a_url;
  char *dest;
  char *res;

  urls_file = fopen (argv[1], "r");
  if (urls_file == NULL)
    {
      fprintf (stdout, "Failed to open %s file.\nUsage: turls urls.txt\n",
               argv[1]);
      exit (0);
    }

  a_url = (char *) osip_malloc (200);
  res = fgets (a_url, 200, urls_file);  /* lines are under 200 */
  while (res != NULL)
    {
      int errcode;

      /* remove the last '\n' before parsing */
      osip_strncpy (a_url + strlen (a_url) - 1, "\0", 1);

      if (0 != strncmp (a_url, "#", 1))
        {
          /* allocate & init url */
          osip_uri_init (&url);
          printf ("=================================================\n");
          printf ("URL TO PARSE: |%s|\n", a_url);
          errcode = osip_uri_parse (url, a_url);
          if (errcode != -1)
            {
              if (osip_uri_to_str (url, &dest) != -1)
                {
                  printf ("result:       |%s|\n", dest);
                  osip_uri_test_accessor_api (url);
                  osip_free (dest);
                }
          } else
            printf ("Bad url format: %s\n", a_url);
          osip_uri_free (url);
          printf ("=================================================\n");
        }
      res = fgets (a_url, 200, urls_file);      /* lines are under 200 */
    }
  osip_free (a_url);
  return 0;
}
コード例 #4
0
void sipomatic_init(Sipomatic *obj, char *url, bool_t ipv6)
{
	osip_uri_t *uri=NULL;
	int port=5064;
	
	obj->ipv6=ipv6;
	
	if (url==NULL){
		url=getenv("SIPOMATIC_URL");
		if (url==NULL){
			if (ipv6) url="sip:robot@[::1]:5064";
			else url="sip:[email protected]:5064";
		}
	}
	if (url!=NULL) {
		osip_uri_init(&uri);
		if (osip_uri_parse(uri,url)==0){
			if (uri->port!=NULL) port=atoi(uri->port);
		}else{
			ms_warning("Invalid identity uri:%s",url);
		}	
	}
	ms_message("Starting using url %s",url);
	ms_mutex_init(&obj->lock,NULL);
	obj->calls=NULL;
	obj->acceptance_time=5;
	obj->max_call_time=300;
	obj->file_path8000hz=ms_strdup_printf("%s/%s",PACKAGE_SOUND_DIR,ANNOUCE_FILE8000HZ);
	obj->file_path16000hz=ms_strdup_printf("%s/%s",PACKAGE_SOUND_DIR,ANNOUCE_FILE16000HZ);
	osip_trace_initialize(OSIP_INFO1,stdout);
	osip_trace_initialize(OSIP_INFO2,stdout);
	osip_trace_initialize(OSIP_WARNING,stdout);
	osip_trace_initialize(OSIP_ERROR,stdout);
	osip_trace_initialize(OSIP_BUG,stdout);
	osip_trace_initialize(OSIP_FATAL,stdout);
	osip_trace_enable_level(OSIP_INFO1);
	osip_trace_enable_level(OSIP_INFO2);
	osip_trace_enable_level(OSIP_WARNING);
	osip_trace_enable_level(OSIP_ERROR);
	osip_trace_enable_level(OSIP_BUG);
	osip_trace_enable_level(OSIP_FATAL);
	eXosip_init();
	eXosip_set_user_agent("sipomatic-" LINPHONE_VERSION "/eXosip");
	eXosip_listen_addr(IPPROTO_UDP,NULL,port,ipv6 ? AF_INET6 : AF_INET,0);
}
コード例 #5
0
ファイル: Node.cpp プロジェクト: inuyasha1027/SI2P
ChordId Node::getPredWithContact(osip_message_t *M) 
{
	osip_contact_t *osip_contact ;
	osip_generic_param_t *param ;
	osip_message_get_contact(M,0,&osip_contact) ;
	int i = osip_contact_param_get_byname (osip_contact, "predecessor", &param);
	osip_uri_t *uri;
	i=osip_uri_init(&uri);
	if (i!=0) { fprintf(stderr, "cannot allocate\n"); return -1; }
	i=osip_uri_parse(uri, param->gvalue);
	if (i!=0) { fprintf(stderr, "cannot parse uri\n"); }
	ChordId new_predessor(
		atoi(uri->username),
		constants,
		uri->host,
		uri->port
		) ;
	osip_uri_free(uri);

	return new_predessor ;
}
コード例 #6
0
ファイル: Node.cpp プロジェクト: inuyasha1027/SI2P
int Node::SndRegister(REG_TYPE type , 
					  ChordId req_uri ,  
					  ChordId to , 
					  ChordId contact , 
					  BOOL IncludeSuccList) 
{
	char *message1;
	unsigned int len = 0;



	osip_transaction_t *transaction;
	osip_event_t *sipevent;
	osip_message_t *request;

	/* temp uri */
	char * tmp_uri;
	
	int i;

	i = osip_message_init(&request);
	if (i!=0) 
		goto si2perror1;
	/* prepare the request-line */
	osip_message_set_method(request, osip_strdup("REGISTER"));
	osip_message_set_version(request, osip_strdup("SIP/2.0"));
	osip_message_set_status_code(request, 0);
	osip_message_set_reason_phrase(request, NULL);

	//requset uri
	if(type == MULTICAST)
	{
		tmp_uri = osip_strdup("sip:224.0.1.75") ;
	}
	else
		tmp_uri = ChordId2Uri(req_uri,false) ;

	osip_uri_t *uri;

	i=osip_uri_init(&uri);
	if (i!=0) 
		goto si2perror2;
	i=osip_uri_parse(uri, tmp_uri );
	if(tmp_uri)	osip_free(tmp_uri) ;
	if (i!=0)
		goto si2perror2;

	osip_message_set_uri(request , uri) ;

	if(type == JOIN)
	{
		tmp_uri = ChordId2Uri(to,false) ;

		/* when JOIN , to and from are same */
		osip_message_set_to(request, tmp_uri );
		osip_message_set_from(request, tmp_uri);
		if (tmp_uri) osip_free(tmp_uri) ;
		osip_from_param_add (request->from, osip_strdup ("user"), osip_strdup("join"));
	}

	else if(type == FINDSUCC)
	{
		tmp_uri = ChordId2Uri(to,true) ;
		osip_message_set_to(request, tmp_uri );
		if (tmp_uri) osip_free(tmp_uri) ;

		tmp_uri = ChordId2Uri(chordId,false);
		osip_message_set_from(request, tmp_uri  );
		if (tmp_uri) osip_free(tmp_uri) ;
		osip_from_param_add (request->from, osip_strdup ("user"), osip_strdup("findsucc"));
		
		//has no contact
	}

	else if(type == STABILIZE)
	{
		tmp_uri = ChordId2Uri(to,false);
		osip_message_set_to(request, tmp_uri);
		if (tmp_uri) osip_free(tmp_uri) ;

		tmp_uri = ChordId2Uri(chordId,false)  ;
		osip_message_set_from(request, tmp_uri );
		osip_from_param_add (request->from, osip_strdup ("user"), osip_strdup("stabilize"));	
		if (tmp_uri) osip_free(tmp_uri) ;
		
		//contact
		tmp_uri = ChordId2Uri(chordId,false);
		char * pre_uri = ChordId2Uri(getFingerTable()->getPredecessor(),false) ;

		char *ctt = (char *) osip_malloc(strlen(tmp_uri) + strlen(";predecessor=") + strlen(pre_uri) +1) ;
		if (ctt == NULL)
			return NULL;
		sprintf (ctt, "%s;predecessor=%s", tmp_uri,pre_uri);
		osip_free(tmp_uri) ;	osip_free(pre_uri) ;

		osip_message_set_contact(request, ctt );
		osip_free(ctt) ;
	}

	else if(type == LEAVE)
	{
		tmp_uri = ChordId2Uri(to,false) ;
		osip_message_set_to(request, tmp_uri );
		if (tmp_uri) osip_free(tmp_uri) ;

		tmp_uri = ChordId2Uri(chordId,false) ;
		osip_message_set_from(request, tmp_uri );
		if (tmp_uri) osip_free(tmp_uri) ;
		osip_from_param_add (request->from, osip_strdup ("user"), osip_strdup("leave"));
		
		//contact
		tmp_uri = ChordId2Uri(chordId,false);
		char * pre_uri = ChordId2Uri(getFingerTable()->getPredecessor(),false) ;

		char *ctt = (char *) osip_malloc(strlen(tmp_uri) + strlen(";predecessor=") + strlen(pre_uri) +1) ;
		if (ctt == NULL)
			return NULL;
		sprintf (ctt, "%s;predecessor=%s", tmp_uri,pre_uri);
		osip_free(tmp_uri) ;	osip_free(pre_uri) ;

		osip_message_set_contact(request, ctt );
		osip_free(ctt) ;
		
		//succlist
		if(IncludeSuccList)
		{
			for(i = 0  ; i < getFingerTable()->getSuccNum() ; i++)
			{
				tmp_uri = ChordId2Uri(getFingerTable()->getSuccessor(i),false) ;
				osip_message_set_contact(request, tmp_uri );
				osip_free(tmp_uri) ;
			}
		}
	}//type == LEAVE
	
	if(type == MULTICAST)
	{
		
		tmp_uri = ChordId2Uri(chordId,false);
		/* when JOIN , to and from are same */
		osip_message_set_to(request, tmp_uri );
		osip_message_set_from(request, tmp_uri);
		osip_from_param_add (request->from, osip_strdup ("user"), osip_strdup("multicast"));
		osip_free(tmp_uri) ;
		//no contact
	}//type == MULTIPL


	//---set call_id and cseq
	osip_call_id_t *callid;
	osip_cseq_t *cseq;
	char *num;
	char  *cidrand;
	char *register_callid_number ;

	/* call-id is always the same for REGISTRATIONS */
	i = osip_call_id_init(&callid);
	if (i!=0) 
		goto si2perror2;
	cidrand = osip_strdup("BF9598C48B184EBBAFADFE527EED8186") ;
	osip_call_id_set_number(callid, cidrand);
	register_callid_number = cidrand;

	osip_call_id_set_host(callid, osip_strdup("SI2P.COM"));
	request->call_id = callid;

	//cseq
	i = osip_cseq_init(&cseq);
	if (i!=0) 
		goto si2perror2 ;
	num = osip_strdup("1");
	osip_cseq_set_number(cseq, num);
	osip_cseq_set_method(cseq, osip_strdup("REGISTER"));
	request->cseq = cseq;
	 
	/*the Max-Forward header */
	osip_message_set_max_forwards(request, "5"); /* a UA should start a request with 70 */

	/* the via header */
	char tmp[200];
	unsigned int branch;
	branch=osip_build_random_number();
    snprintf(tmp, 200, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", "UDP",
	      localip,
	      localport,
	      branch );

    osip_message_set_via(request, tmp);

	/* the UA header */
	osip_message_set_user_agent(request, user_agent);

	/*  the expires header */
	char exp[10]; /* MUST never be ouside 1 and 3600 */
	snprintf(exp, 9, "%i", expires);
	osip_message_set_expires(request, exp);
	osip_message_set_content_length(request, "0");


	/*** then must wake up osip ***/
	i = osip_transaction_init(&transaction,
		       NICT,
		       adosip->j_osip,
		       request);
	if (i!=0)
		goto si2perror2 ;

	//jr->r_last_tr = transaction;

	/* send REGISTER */
	
	i = osip_message_to_str(request, &message1, &len);
	LogStream("SEND======================================>>\n") ;
	LogStream(message1) ;
	if(message1)	osip_free(message1) ;
//	printf("SEND======================================>>\n") ;
//	printf(message1) ;

	sipevent = osip_new_outgoing_sipmessage(request);
	sipevent->transactionid =  transaction->transactionid;
	osip_message_force_update(request);
  
	osip_transaction_add_event(transaction, sipevent);

	adosip->ThreadWakeUp();
	return 0;

si2perror1:
	if(request != NULL)osip_message_free(request);
	return -1 ;
si2perror2:
	if(request != NULL)osip_message_free(request);
	return -1;
}
コード例 #7
0
ファイル: Node.cpp プロジェクト: inuyasha1027/SI2P
int Node::SndUserRegisterRequest(char *aor ,const char *requri)
{
	char *message1;
	unsigned int len = 0;



	osip_transaction_t *transaction;
	osip_event_t *sipevent;
	osip_message_t *request;


	int i;

	i = osip_message_init(&request);
	if (i!=0) 
		goto si2perror1;
	/* prepare the request-line */
	osip_message_set_method(request, osip_strdup("REGISTER"));
	osip_message_set_version(request, osip_strdup("SIP/2.0"));
	osip_message_set_status_code(request, 0);
	osip_message_set_reason_phrase(request, NULL);

	//requset uri


	osip_uri_t *uri;

	i=osip_uri_init(&uri);
	if (i!=0) 
		goto si2perror2;
	i=osip_uri_parse(uri, requri);
	if (i!=0)
		goto si2perror2;

	osip_message_set_uri(request , uri) ;


	//to from ,no contact
	osip_message_set_to(request,aor);
	osip_message_set_from(request,aor);

	osip_from_param_add(request->from,osip_strdup("user"),osip_strdup("user_query"));

	//---set call_id and cseq
	osip_call_id_t *callid;
	osip_cseq_t *cseq;
	char *num;
	char  *cidrand;
	char *register_callid_number ;

	/* call-id is always the same for REGISTRATIONS */
	i = osip_call_id_init(&callid);
	if (i!=0) 
		goto si2perror2;
	cidrand = osip_strdup("BF9598C48B184EBBAFADFE527EED8186") ;
	osip_call_id_set_number(callid, cidrand);
	register_callid_number = cidrand;

	osip_call_id_set_host(callid, osip_strdup("SI2P.COM"));
	request->call_id = callid;

	//cseq
	i = osip_cseq_init(&cseq);
	if (i!=0) 
		goto si2perror2 ;
	num = osip_strdup("1");
	osip_cseq_set_number(cseq, num);
	osip_cseq_set_method(cseq, osip_strdup("REGISTER"));
	request->cseq = cseq;
	 
	/*the Max-Forward header */
	osip_message_set_max_forwards(request, "5"); /* a UA should start a request with 70 */

	/* the via header */
	char tmp[200];
	unsigned int branch;
	branch=osip_build_random_number();
    snprintf(tmp, 200, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", "UDP",
	      localip,
	      localport,
	      branch );

    osip_message_set_via(request, tmp);

	/* the UA header */
	osip_message_set_user_agent(request, user_agent);

	/*  the expires header */
	char exp[10]; /* MUST never be ouside 1 and 3600 */
	snprintf(exp, 9, "%i", expires);
	osip_message_set_expires(request, exp);
	osip_message_set_content_length(request, "0");


	/*** then must wake up osip ***/
	i = osip_transaction_init(&transaction,
		       NICT,
		       adosip->j_osip,
		       request);
	if (i!=0)
		goto si2perror2 ;

	/* send REGISTER */
	i = osip_message_to_str(request, &message1, &len);
	LogStream("SEND======================================>>\n") ;
	LogStream(message1) ;
	if(message1) osip_free(message1) ;

	sipevent = osip_new_outgoing_sipmessage(request);
	sipevent->transactionid =  transaction->transactionid;
	osip_message_force_update(request);
  
	osip_transaction_add_event(transaction, sipevent);

	adosip->ThreadWakeUp();
	return 0;

si2perror1:
	if(request != NULL)osip_message_free(request);
	return -1 ;
si2perror2:
	if(request != NULL)osip_message_free(request);
	return -1;
	return 0;
}
コード例 #8
0
ファイル: Node.cpp プロジェクト: inuyasha1027/SI2P
int
Node::SndUserRegisterRequest(REG_TYPE type,
				uinfo_t *user_info,
				const char *registrar,
				int expires)
{
	char *message1;
	unsigned int len = 0;

	osip_message_t *request;
	osip_event_t *sipevent;
	osip_transaction_t *transaction;
	osip_uri_t *uri;
	
	char *tmp_uri;
	int i;

	i=osip_message_init(&request);
	if(i!=0)
		goto si2perror1;
	osip_message_set_method(request,strdup("REGISTER"));
	osip_message_set_version(request,strdup("SIP/2.0"));
	osip_message_set_status_code(request,0);
	osip_message_set_reason_phrase(request,NULL);

	i=osip_uri_init(&uri);
	if(i!=0)
		goto si2perror2;
	i=osip_uri_parse(uri,osip_strdup(registrar));
	osip_message_set_uri(request,uri);

	//*set to,from and header
	if(type==USER_REGISTRATION)
	{	
		char *dest1;
		char *dest2;
		
		osip_uri_to_str(user_info->aor->uri,&dest1);
		i=osip_message_set_to(request,dest1);
		i=osip_message_set_from(request,dest1);
		if(dest1)	osip_free(dest1) ;
		osip_from_param_add (request->from, osip_strdup ("user"), osip_strdup("user_registration"));

		osip_contact_to_str(user_info->bindings->contact,&dest2);
		i=osip_message_set_contact(request,osip_strdup(dest2));
		if(dest2)	osip_free(dest2) ;
	}

	if(type == RED_REGISTER)
	{
		char *dest1;
		char *dest2;
		osip_uri_to_str(user_info->aor->uri,&dest1);
		i=osip_message_set_to(request,dest1);
		i=osip_message_set_from(request,dest1);
		if(dest1)	osip_free(dest1) ;
		osip_from_param_add (request->from, osip_strdup ("user"), osip_strdup("red_register"));

		osip_contact_to_str(user_info->bindings->contact,&dest2);
		i=osip_message_set_contact(request,osip_strdup(dest2));
		if(dest2)	osip_free(dest2) ;
	}

	if(type==TRANSFER_REGISTRATION)
	{
		char *dest1;
		char *dest2;
		//string tmp_uri;
		osip_uri_to_str(user_info->aor->uri,&dest1);
		osip_message_set_to(request,dest1);
		if(dest1)	osip_free(dest1) ;

		tmp_uri = ChordId2Uri(chordId,false);
		osip_message_set_from(request,tmp_uri);
		osip_from_param_add (request->from, osip_strdup ("user"), osip_strdup("transfer_registration"));
		if(tmp_uri)	osip_free(tmp_uri) ;

		osip_contact_to_str(user_info->bindings->contact,&dest2);
		osip_message_set_contact(request,dest2);
		if(dest2)	osip_free(dest2) ;
	}
	if(type==THIRD_PARTY)
	{
		//todo
	}
		//---set call_id and cseq
	osip_call_id_t *callid;
	osip_cseq_t *cseq;
	char *num;
	char  *cidrand;
	char *register_callid_number ;

	//* call-id is always the same for REGISTRATIONS 
	i = osip_call_id_init(&callid);
	if (i!=0) 
		goto si2perror2;
	cidrand = osip_strdup("BF9598C48B184EBBAFADFE527EED8186") ;
	osip_call_id_set_number(callid, cidrand);
	register_callid_number = cidrand;

	osip_call_id_set_host(callid, osip_strdup("SI2P.COM"));
	request->call_id = callid;

	//cseq
	i = osip_cseq_init(&cseq);
	if (i!=0) 
		goto si2perror2 ;
	num = osip_strdup("1");
	osip_cseq_set_number(cseq, num);
	osip_cseq_set_method(cseq, osip_strdup("REGISTER"));
	request->cseq = cseq;
	 
	//*the Max-Forward header 
	osip_message_set_max_forwards(request, "5"); //* a UA should start a request with 70 

	//* the via header 
	char tmp[200];
    snprintf(tmp, 200, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", "UDP",
	      localip,
	      localport,
	      via_branch_new_random() );

    osip_message_set_via(request, tmp);

	//* the UA header 
	osip_message_set_user_agent(request, user_agent);

	//*  the expires header 
	char exp[10]; //* MUST never be ouside 1 and 3600 
	snprintf(exp, 9, "%i", expires);
	osip_message_set_expires(request, exp);
	osip_message_set_content_length(request, "0");


	//*** then must wake up osip 
	i = osip_transaction_init(&transaction,
		       NICT,
		       adosip->j_osip,
		       request);
	if (i!=0)
		goto si2perror3 ;

	//* send REGISTER 
	i = osip_message_to_str(request, &message1, &len);
	LogStream("SEND======================================>>\n") ;
	LogStream(message1) ;
	if(message1) osip_free(message1) ;
//	printf("SEND======================================>>\n") ;
//	printf(message1) ;
	sipevent = osip_new_outgoing_sipmessage(request);
	sipevent->transactionid =  transaction->transactionid;
	osip_message_force_update(request);
  
	osip_transaction_add_event(transaction, sipevent);

	adosip->ThreadWakeUp();
	return 0;

si2perror1:
	
	return -1;

si2perror2:
	if(request!=NULL)
		osip_message_free(request);
	return -1;

si2perror3:
	if(transaction!=NULL)
		osip_message_free(request);
	return -1;


}
コード例 #9
0
/* 
   method is the type of request. ("INVITE", "REGISTER"...)
   to is the remote target URI
   transport is either "TCP" or "UDP" (by now, only UDP is implemented!)
*/
int
generating_request_out_of_dialog (osip_message_t ** dest, const char *method,
                                  const char *to, const char *transport,
                                  const char *from, const char *proxy)
{
  /* Section 8.1:
     A valid request contains at a minimum "To, From, Call-iD, Cseq,
     Max-Forwards and Via
   */
  int i;
  osip_message_t *request;
  char locip[65];
  int doing_register;
  char *register_callid_number = NULL;

  *dest = NULL;

  if (eXosip.eXtl == NULL)
    return OSIP_NO_NETWORK;

  /*guess the local ip since req uri is known */
  memset (locip, '\0', sizeof (locip));
  eXosip_guess_ip_for_via (eXosip.eXtl->proto_family, locip, 49);
  if (locip[0] == '\0')
    {
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: no default interface defined\n"));
      return OSIP_NO_NETWORK;
    }

  i = osip_message_init (&request);
  if (i != 0)
    return i;

  /* prepare the request-line */
  osip_message_set_method (request, osip_strdup (method));
  osip_message_set_version (request, osip_strdup ("SIP/2.0"));
  osip_message_set_status_code (request, 0);
  osip_message_set_reason_phrase (request, NULL);

  doing_register = 0 == strcmp ("REGISTER", method);

  if (doing_register)
    {
      osip_uri_init (&(request->req_uri));
      i = osip_uri_parse (request->req_uri, proxy);
      if (i != 0)
        {
          osip_message_free (request);
          return i;
        }
      i = osip_message_set_to (request, from);
      if (i != 0 || request->to == NULL)
        {
          if (i >= 0)
            i = OSIP_SYNTAXERROR;
          osip_message_free (request);
          return i;
        }
  } else
    {
      /* in any cases except REGISTER: */
      i = osip_message_set_to (request, to);
      if (i != 0 || request->to == NULL)
        {
          if (i >= 0)
            i = OSIP_SYNTAXERROR;
          OSIP_TRACE (osip_trace
                      (__FILE__, __LINE__, OSIP_ERROR, NULL,
                       "ERROR: callee address does not seems to be a sipurl: %s\n",
                       to));
          osip_message_free (request);
          return i;
        }

      /* REMOVE ALL URL PARAMETERS from to->url headers and add them as headers */
      if (request->to != NULL && request->to->url != NULL)
        {
          osip_uri_t *url = request->to->url;
          while (osip_list_size (&url->url_headers) > 0)
            {
              osip_uri_header_t *u_header;
              u_header = (osip_uri_param_t *) osip_list_get (&url->url_headers, 0);
              if (u_header == NULL)
                break;

              if (osip_strcasecmp (u_header->gname, "from") == 0)
                {
              } else if (osip_strcasecmp (u_header->gname, "to") == 0)
                {
              } else if (osip_strcasecmp (u_header->gname, "call-id") == 0)
                {
              } else if (osip_strcasecmp (u_header->gname, "cseq") == 0)
                {
              } else if (osip_strcasecmp (u_header->gname, "via") == 0)
                {
              } else if (osip_strcasecmp (u_header->gname, "contact") == 0)
                {
              } else
                osip_message_set_header (request, u_header->gname,
                                         u_header->gvalue);
              osip_list_remove (&url->url_headers, 0);
              osip_uri_param_free (u_header);
            }
        }

      if (proxy != NULL && proxy[0] != 0)
        {                       /* equal to a pre-existing route set */
          /* if the pre-existing route set contains a "lr" (compliance
             with bis-08) then the req_uri should contains the remote target
             URI */
          osip_uri_param_t *lr_param;
          osip_route_t *o_proxy;

          osip_route_init (&o_proxy);
          i = osip_route_parse (o_proxy, proxy);
          if (i != 0)
            {
              osip_route_free (o_proxy);
              osip_message_free (request);
              return i;
            }

          osip_uri_uparam_get_byname (o_proxy->url, "lr", &lr_param);
          if (lr_param != NULL) /* to is the remote target URI in this case! */
            {
              osip_uri_clone (request->to->url, &(request->req_uri));
              /* "[request] MUST includes a Route header field containing
                 the route set values in order." */
              osip_list_add (&request->routes, o_proxy, 0);
          } else
            /* if the first URI of route set does not contain "lr", the req_uri
               is set to the first uri of route set */
            {
              request->req_uri = o_proxy->url;
              o_proxy->url = NULL;
              osip_route_free (o_proxy);
              /* add the route set */
              /* "The UAC MUST add a route header field containing
                 the remainder of the route set values in order.
                 The UAC MUST then place the remote target URI into
                 the route header field as the last value
               */
              osip_message_set_route (request, to);
            }
      } else                    /* 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 (request->to->url, &(request->req_uri));
          if (i != 0)
            {
              osip_message_free (request);
              return i;
            }
        }
    }

  /* set To and From */
  i = osip_message_set_from (request, from);
  if (i != 0 || request->from == NULL)
    {
      if (i >= 0)
        i = OSIP_SYNTAXERROR;
      osip_message_free (request);
      return i;
    }

  /* add a tag */
  osip_from_set_tag (request->from, osip_from_tag_new_random ());

  /* set the cseq and call_id header */
  {
    osip_call_id_t *callid;
    osip_cseq_t *cseq;
    char *num;
    char *cidrand;

    /* call-id is always the same for REGISTRATIONS */
    i = osip_call_id_init (&callid);
    if (i != 0)
      {
        osip_message_free (request);
        return i;
      }
    cidrand = osip_call_id_new_random ();
    osip_call_id_set_number (callid, cidrand);
    if (doing_register)
      register_callid_number = cidrand;

    request->call_id = callid;

    i = osip_cseq_init (&cseq);
    if (i != 0)
      {
        osip_message_free (request);
        return i;
      }
    num = osip_strdup (doing_register ? "1" : "20");
    osip_cseq_set_number (cseq, num);
    osip_cseq_set_method (cseq, osip_strdup (method));
    request->cseq = cseq;

    if (cseq->method == NULL || cseq->number == NULL)
      {
        osip_message_free (request);
        return OSIP_NOMEM;
      }
  }

  i = _eXosip_request_add_via (request, transport, locip);
  if (i != 0)
    {
      osip_message_free (request);
      return i;
    }

  /* always add the Max-Forward header */
  osip_message_set_max_forwards (request, "70");        /* a UA should start a request with 70 */

  if (0 == strcmp ("REGISTER", method))
    {
  } else if (0 == strcmp ("INFO", method))
    {
  } else if (0 == strcmp ("OPTIONS", method))
    {
      osip_message_set_accept (request, "application/sdp");
    }

  osip_message_set_user_agent (request, eXosip.user_agent);
  /*  else if ... */
  *dest = request;
  return OSIP_SUCCESS;
}
コード例 #10
0
static int
__osip_message_startline_parsereq(osip_message_t * dest, const char *buf,
								  const char **headers)
{
	const char *p1;
	const char *p2;
	char *requesturi;
	int i;

	dest->sip_method = NULL;
	dest->status_code = 0;
	dest->reason_phrase = NULL;

	*headers = buf;

	/* The first token is the method name: */
	p2 = strchr(buf, ' ');
	if (p2 == NULL)
		return OSIP_SYNTAXERROR;
	if (*(p2 + 1) == '\0' || *(p2 + 2) == '\0')
		return OSIP_SYNTAXERROR;
	if (p2 - buf == 0) {
		OSIP_TRACE(osip_trace
				   (__FILE__, __LINE__, OSIP_ERROR, NULL,
					"No space allowed here\n"));
		return OSIP_SYNTAXERROR;
	}
	dest->sip_method = (char *) osip_malloc(p2 - buf + 1);
	if (dest->sip_method == NULL)
		return OSIP_NOMEM;
	osip_strncpy(dest->sip_method, buf, p2 - buf);

	/* The second token is a sip-url or a uri: */
	p1 = strchr(p2 + 2, ' ');	/* no space allowed inside sip-url */
	if (p1 == NULL) {
		OSIP_TRACE(osip_trace
				   (__FILE__, __LINE__, OSIP_ERROR, NULL,
					"Uncompliant request-uri\n"));
		osip_free(dest->sip_method);
		dest->sip_method = NULL;
		return OSIP_SYNTAXERROR;
	}
	if (p1 - p2 < 2) {
		osip_free(dest->sip_method);
		dest->sip_method = NULL;
		return OSIP_SYNTAXERROR;
	}

	requesturi = (char *) osip_malloc(p1 - p2);
	if (requesturi == NULL) {
		osip_free(dest->sip_method);
		dest->sip_method = NULL;
		return OSIP_NOMEM;
	}
	osip_clrncpy(requesturi, p2 + 1, (p1 - p2 - 1));

	i = osip_uri_init(&(dest->req_uri));
	if (i != 0) {
		osip_free(requesturi);
		requesturi = NULL;
		osip_free(dest->sip_method);
		dest->sip_method = NULL;
		return OSIP_NOMEM;
	}
	i = osip_uri_parse(dest->req_uri, requesturi);
	osip_free(requesturi);
	if (i != 0) {
		osip_free(dest->sip_method);
		dest->sip_method = NULL;
		osip_uri_free(dest->req_uri);
		dest->req_uri = NULL;
		return OSIP_SYNTAXERROR;
	}

	/* find the the version and the beginning of headers */
	{
		const char *hp = p1;

		while ((*hp != '\r') && (*hp != '\n')) {
			if (*hp)
				hp++;
			else {
				OSIP_TRACE(osip_trace
						   (__FILE__, __LINE__, OSIP_ERROR, NULL,
							"No crlf found\n"));
				osip_free(dest->sip_method);
				dest->sip_method = NULL;
				osip_uri_free(dest->req_uri);
				dest->req_uri = NULL;
				return OSIP_SYNTAXERROR;
			}
		}
		if (hp - p1 < 2) {
			osip_free(dest->sip_method);
			dest->sip_method = NULL;
			osip_uri_free(dest->req_uri);
			dest->req_uri = NULL;
			return OSIP_SYNTAXERROR;
		}

		dest->sip_version = (char *) osip_malloc(hp - p1);
		if (dest->sip_version == NULL) {
			osip_free(dest->sip_method);
			dest->sip_method = NULL;
			osip_uri_free(dest->req_uri);
			dest->req_uri = NULL;
			return OSIP_NOMEM;
		}

		osip_strncpy(dest->sip_version, p1 + 1, (hp - p1 - 1));

		if (0 != osip_strcasecmp(dest->sip_version, "SIP/2.0")) {
			OSIP_TRACE(osip_trace
					   (__FILE__, __LINE__, OSIP_ERROR, NULL,
						"Wrong version number\n"));
		}

		hp++;
		if ((*hp) && ('\r' == hp[-1]) && ('\n' == hp[0]))
			hp++;
		(*headers) = hp;
	}
	return OSIP_SUCCESS;
}
コード例 #11
0
/* returns -1 on error. */
int
osip_from_parse (osip_from_t * from, const char *hvalue)
{
  const char *displayname;
  const char *url;
  const char *url_end;
  const char *gen_params;

  /* How to parse:

     we'll place the pointers:
     displayname  =>  beginning of displayname
     url          =>  beginning of url
     url_end      =>  end       of url
     gen_params  =>  beginning of params

     examples:

     jack <sip:[email protected]>;tag=34erZ
     ^     ^                ^ ^

     sip:[email protected];tag=34erZ
     ^                ^^      
   */

  displayname = strchr (hvalue, '"');

  url = strchr (hvalue, '<');
  if (url != NULL)
    {
      url_end = strchr (url, '>');
      if (url_end == NULL)
        return -1;
    }

  /* SIPit day2: this case was not supported
     first '"' is placed after '<' and after '>'
     <sip:[email protected];method=INVITE>;description="OPEN";expires=28800
     if the fisrt quote is after '<' then
     this is not a quote for a displayname.
   */
  if (displayname != NULL)
    {
      if (displayname > url)
        displayname = NULL;
    }

  if ((displayname == NULL) && (url != NULL))
    {                           /* displayname IS A '*token' (not a quoted-string) */
      if (hvalue != url)        /* displayname exists */
        {
          if (url - hvalue + 1 < 2)
            return -1;
          from->displayname = (char *) osip_malloc (url - hvalue + 1);
          if (from->displayname == NULL)
            return -1;
          osip_clrncpy (from->displayname, hvalue, url - hvalue);
        }
      url++;                    /* place pointer on the beginning of url */
  } else
    {
      if ((displayname != NULL) && (url != NULL))
        {                       /* displayname IS A quoted-string (not a '*token') */
          const char *first;
          const char *second=NULL;

          /* search for quotes */
          first = __osip_quote_find (hvalue);
          if (first == NULL)
            return -1;          /* missing quote */
	  second = __osip_quote_find (first + 1);
          if (second == NULL)
            return -1;          /* missing quote */
          if ((first > url))
            return -1;

          if (second - first + 2 >= 2)
            {
              from->displayname = (char *) osip_malloc (second - first + 2);
              if (from->displayname == NULL)
                return -1;
              osip_strncpy (from->displayname, first, second - first + 1);
              /* osip_clrspace(from->displayname); *//*should we do that? */

              /* special case: "<sip:[email protected]>" <sip:[email protected]> */
            }                   /* else displayname is empty? */
          url = strchr (second + 1, '<');
          if (url == NULL)
            return -1;          /* '<' MUST exist */
          url++;
      } else
        url = hvalue;           /* field does not contains '<' and '>' */
    }

  /* DISPLAY-NAME SET   */
  /* START of URL KNOWN */

  url_end = strchr (url, '>');

  if (url_end == NULL)          /* sip:[email protected];tag=023 */
    {                           /* We are sure ';' is the delimiter for from-parameters */
      char *host = strchr (url, '@');

      if (host != NULL)
        gen_params = strchr (host, ';');
      else
        gen_params = strchr (url, ';');
      if (gen_params != NULL)
        url_end = gen_params - 1;
      else
        url_end = url + strlen (url);
  } else                        /* jack <sip:[email protected];user=phone>;tag=azer */
    {
      gen_params = strchr (url_end, ';');
      url_end--;                /* place pointer on the beginning of url */
    }

  if (gen_params != NULL)       /* now we are sure a param exist */
    if (__osip_generic_param_parseall (&from->gen_params, gen_params) == -1)
      {
        return -1;
      }

  /* set the url */
  {
    char *tmp;
    int i;

    if (url_end - url + 2 < 7)
      return -1;
    i = osip_uri_init (&(from->url));
    if (i != 0)
      return -1;
    tmp = (char *) osip_malloc (url_end - url + 2);
    if (tmp == NULL)
      return -1;
    osip_strncpy (tmp, url, url_end - url + 1);
    i = osip_uri_parse (from->url, tmp);
    osip_free (tmp);
    if (i != 0)
      return -1;
  }
  return 0;
}
コード例 #12
0
ファイル: groups.c プロジェクト: gozfree/src
/*
  This method returns:
  -2 if plugin consider this request should be totally discarded!
  -1 on error
  0  nothing has been done
  1  things has been done on psp_req element
*/
int cb_groups_search_location(psp_request_t *psp_req)
{
    location_t *loc;
    osip_route_t *route;
    int i;
    int index;
    int match;
    grp_t *grp=NULL;

    osip_uri_param_t *psp_param;
    osip_message_t *request;
    request = psp_request_get_request(psp_req);

    OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,
                          "groups plugin: entering cb_groups_search_location\n"));

    /* default OUTPUT */
    if (ISSET_R_ROUTE_MODE(groups_context->flag))
        psp_request_set_property(psp_req, PSP_STAY_ON_PATH);
    else
        psp_request_set_property(psp_req, 0);

    psp_request_set_mode(psp_req, PSP_SFULL_MODE);

    i=0;
    for (; !osip_list_eol(&request->routes, i); i++)
    {
        osip_message_get_route (request, i, &route);
        if (0 != psp_core_is_responsible_for_this_route(route->url))
        {
            psp_request_set_mode (psp_req, PSP_SFULL_MODE);
            psp_request_set_state (psp_req, PSP_MANDATE);
            OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
                                    "groups plugin: mandate statefull handling for route.\n"));
            return 0;
        }
    }

    psp_request_set_state(psp_req, PSP_MANDATE);

    if (i>1)
    {
        psp_request_set_uas_status(psp_req, 482); /* loop? */
        psp_request_set_mode(psp_req, PSP_UAS_MODE);
        return 0;
    }
    if (i==1)
    {
        osip_message_get_route(request, 0, &route); /* should be the first one */
        /* if this route header contains the "psp" parameter, it means
        the element does not come from a pre-route-set header (in this
         last case, we want to execute the plugin for the initial request) */
        /* NON compliant UAs (not returning this parameter) are guilty. */
        osip_uri_uparam_get_byname (route->url, "psp", &psp_param);
        if (psp_param!=NULL)
        {
            psp_request_set_state(psp_req, PSP_MANDATE);
            psp_request_set_mode (psp_req, PSP_SFULL_MODE);
            /* got it, leave this plugin. */
            return 0;
        }
    }

    if (request->req_uri->username==NULL
            || request->req_uri->host==NULL)
    {
        OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
                                "groups plugin: No username in uri.\n"));
        psp_request_set_state(psp_req, PSP_PROPOSE);
        psp_request_set_uas_status(psp_req, 404);
        psp_request_set_mode(psp_req, PSP_UAS_MODE);
        return 0;
    }

    /* search for a group */
    match=0;
    for (index=0; index<MAX_GROUPS; index++)
    {
        grp = &(groups_context->grps[index]);
        if (grp->group[0]!='\0')
        {
            if (osip_strcasecmp(grp->group, request->req_uri->username)==0)
            {
                if (grp->domain[0]=='\0')
                {
                    match=1;
                    break;
                }
                else if (osip_strcasecmp(grp->domain, request->req_uri->host)==0)
                {
                    match=1;
                    break;
                }
            }
        }
        grp=NULL;
    }

    if (match==1 && grp!=NULL)
    {
        OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
                                "groups plugin: A group match this call (%s).\n",
                                grp->group));

        for (index=0; index<MAX_MEMBERS; index++)
        {
            osip_uri_t *uri;
            int i;
            char *dest;

            dest = grp->members[index];
            if (dest[0]=='\0')
                break;
            OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO3,NULL,
                                  "groups plugin: members of %s: %s\n",
                                  grp->group,
                                  dest));

            osip_uri_init(&uri);
            i = osip_uri_parse(uri, dest);

            if (i==0)
            {
                i = location_init(&loc, uri, 3600);
                if (i!=0)
                {   /* This can only happen in case we don't have enough memory */
                    osip_uri_free(uri);
                    OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,
                                          "groups plugin: Could not create location info!\n"));
                }
                else
                {
                    ADD_ELEMENT(psp_req->locations, loc);
                }
            }
        }
        return 0;
    }

    OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,
                          "groups plugin: Didn't do anything with this request?\n"));
    psp_request_set_state(psp_req, PSP_PROPOSE);
    psp_request_set_uas_status(psp_req, 404);
    psp_request_set_mode(psp_req, PSP_UAS_MODE);

    return 0;

}
コード例 #13
0
ファイル: plugin_regex.c プロジェクト: NieHao/Tomato-RAF
/* private plugin code */
static int plugin_regex_redirect(sip_ticket_t *ticket) {
   osip_uri_t *to_url=ticket->sipmsg->to->url;
   char *url_string=NULL;
   osip_uri_t *new_to_url;
   int  i, sts;
   osip_contact_t *contact = NULL;
   /* character workspaces for regex */
   #define WORKSPACE_SIZE 128
   static char in[WORKSPACE_SIZE+1], rp[WORKSPACE_SIZE+1];

   /* do apply to full To URI... */
   sts = osip_uri_to_str(to_url, &url_string);
   if (sts != 0) {
      ERROR("osip_uri_to_str() failed");
      return STS_FAILURE;
   }
   DEBUGC(DBCLASS_BABBLE, "To URI string: [%s]", url_string);

   /* perform search and replace of the regexes, first match hits */
   for (i = 0; i < plugin_cfg.regex_pattern.used; i++) {
      regmatch_t *pmatch = NULL;
      pmatch = rmatch(url_string, WORKSPACE_SIZE, &re[i]);
      if (pmatch == NULL) continue; /* no match, next */

      /* have a match, do the replacement */
      INFO("Matched rexec rule: %s",plugin_cfg.regex_desc.string[i] );
      strncpy (in, url_string, WORKSPACE_SIZE);
      in[WORKSPACE_SIZE]='\0';
      strncpy (rp, plugin_cfg.regex_replace.string[i], WORKSPACE_SIZE);
      rp[WORKSPACE_SIZE]='\0';

      sts = rreplace(in, WORKSPACE_SIZE, &re[i], pmatch, rp);
      if (sts != STS_SUCCESS) {
         ERROR("regex replace failed: pattern:[%s] replace:[%s]",
               plugin_cfg.regex_pattern.string[i],
               plugin_cfg.regex_replace.string[i]);
         osip_free(url_string);
         return STS_FAILURE;
      }
      /* only do first match */
      break;
   }
   if (i >= plugin_cfg.regex_pattern.used) {
      /* no match */
      osip_free(url_string);
      return STS_SUCCESS;
   }
   /* in: contains the new string */

   sts = osip_uri_init(&new_to_url);
   if (sts != 0) {
      ERROR("Unable to initialize URI");
      osip_free(url_string);
      return STS_FAILURE;
   }

   sts = osip_uri_parse(new_to_url, in);
   if (sts != 0) {
      ERROR("Unable to parse To URI: %s", in);
      osip_uri_free(new_to_url);
      osip_free(url_string);
      return STS_FAILURE;
   }

   /* use a "302 Moved temporarily" response back to the client */
   /* new target is within the Contact Header */

   /* remove all Contact headers in message */
   for (i=0; (contact != NULL) || (i == 0); i++) {
      osip_message_get_contact(ticket->sipmsg, 0, &contact);
      if (contact) {
         osip_list_remove(&(ticket->sipmsg->contacts),0);
         osip_contact_free(contact);
      }
   } /* for i */

   /* insert one new Contact header containing the new target address */
   osip_contact_init(&contact);
   osip_list_add(&(ticket->sipmsg->contacts),contact,0);
   
   /* link the new_to_url into the Contact list */
   contact->url = new_to_url;
   new_to_url = NULL;

   /*
    * Add the 'REDIRECTED_TAG=REDIRECTED_VAL' parameter to URI. Required to figure out
    * if this INVITE has already been processed (redirected) and
    * does not need further attention by this plugin.
    * THIS IS REQUIRED TO AVOID A LOOP
    */
   osip_uri_param_add(&(contact->url->url_params), osip_strdup(REDIRECTED_TAG), 
                      osip_strdup(REDIRECTED_VAL));

   INFO("redirecting %s -> %s", url_string, in);

   /* sent redirect message back to local client */
   add_to_redirected_cache(&redirected_cache, ticket);
   sip_gen_response(ticket, 302 /*Moved temporarily*/);

   /* release resources and return */
   osip_free(url_string);
   return STS_SIP_SENT;
}
コード例 #14
0
ファイル: main.c プロジェクト: usamaaftab80/multi-p2p
int bSipRegisterBuild(osip_message_t **regMsgPtrPtr)
{
	static int gSeqNum = 1;
	int status;
	char *callidNumberStr = NULL;
	char *seqNumStr = NULL;
	osip_call_id_t *callidPtr;
	char temp[MESSAGE_ENTRY_MAX_LENGTH];
	char sipPort[MESSAGE_ENTRY_MAX_LENGTH];
	osip_cseq_t *cseqPtr;
	unsigned int number;
	osip_message_t     *regMsgPtr;
	char expires[10];

	if((status = osip_message_init(&regMsgPtr)) != 0){
		OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"Can't init message!\n"));
		return -1;
	}
	osip_message_set_method(regMsgPtr, osip_strdup("OPTIONS"));

	osip_uri_init(&(regMsgPtr->req_uri));
	if ( ( status = osip_uri_parse(regMsgPtr->req_uri, SIP_PROXY) ) != 0)
	{
		OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"uri parse failed!\n"));
		osip_message_free(regMsgPtr);
		return -1;
	}
	osip_message_set_version(regMsgPtr, osip_strdup("SIP/2.0"));
	osip_message_set_status_code(regMsgPtr, 0);
	osip_message_set_reason_phrase(regMsgPtr, NULL);

	osip_message_set_to(regMsgPtr, SIP_TO);
	osip_message_set_from(regMsgPtr, SIP_FROM);

	if((status = osip_call_id_init(&callidPtr)) != 0 ){
		OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"call id failed!\n"));
		osip_message_free(regMsgPtr);
		return -1;
	}
	callidNumberStr = (char *)osip_malloc(MAX_ADDR_STR);
	number = osip_build_random_number();
	sprintf(callidNumberStr,"%u",number);
	osip_call_id_set_number(callidPtr, callidNumberStr);

	osip_call_id_set_host(callidPtr, osip_strdup("10.1.1.63"));

	regMsgPtr->call_id = callidPtr;

	if((status = osip_cseq_init(&cseqPtr)) != 0 ){
		OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"seq init failed!\n"));
		osip_message_free(regMsgPtr);
		return -1;
	}
	gSeqNum++;
	seqNumStr = (char *)osip_malloc(MAX_ADDR_STR);
	sprintf(seqNumStr,"%i", gSeqNum);
	osip_cseq_set_number(cseqPtr, seqNumStr);
	osip_cseq_set_method(cseqPtr, osip_strdup("OPTIONS"));
	regMsgPtr->cseq = cseqPtr;

	osip_message_set_max_forwards(regMsgPtr, "70");

	sprintf(sipPort, "%i", SIP_PORT);
	sprintf(temp, "SIP/2.0/%s %s;branch=z9hG4bK%u", "UDP",LOCAL_IP,osip_build_random_number() );
	osip_message_set_via(regMsgPtr, temp);

	osip_message_set_contact(regMsgPtr, SIP_CONTACT);
	sprintf(expires, "%i", EXPIRES_TIME_INSECS);
	osip_message_set_expires(regMsgPtr, expires);

	osip_message_set_content_length(regMsgPtr, "0");

	osip_message_set_user_agent(regMsgPtr, "TotalView 1.0");

	AddSupportedMethods(regMsgPtr);
	*regMsgPtrPtr = regMsgPtr;
	return 0;
}