Exemple #1
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);
}
Exemple #2
0
MY_DLLEXPORT OWPL_RESULT
owplInit(	const int asyncCallbackMode,
			const int udpPort, 
			const int tcpPort, 
			const int tlsPort, 
			const char* szBindToAddr,
			const int bUserSequentialPorts)
{
	int i;

	phcb = (phCallbacks_t * ) malloc(sizeof(phCallbacks_t));
	memset(phcb, 0, sizeof(phCallbacks_t));

	phcfg.asyncmode = asyncCallbackMode;

	ph_avcodec_init();
	ph_calls_init();

	if (udpPort > 0) {
		snprintf(phcfg.sipport, sizeof(phcfg.sipport), "%d", udpPort);
	}

	if (phcfg.use_tunnel)
	{
		i = ph_tunnel_init();
		if (i)
		{
			return i;
		}
	}

#ifdef FORCE_VAD
/* HACK for test */
#ifdef EMBED
	phcfg.vad = VAD_VALID_MASK | (500 & VAD_THRESHOLD_MASK);
#else
	phcfg.vad = VAD_VALID_MASK | (1000 & VAD_THRESHOLD_MASK);
#endif
#endif

#ifdef FORCE_CNG
  /* HACK for test */
  phcfg.cng = 1;
#endif

	ph_media_init(phcfg.use_tunnel, phcfg.plugin_path);

	i = eXosip_init(0, 0, atoi(phcfg.sipport), phTunnel);

	if (i)
	{
		return OWPL_RESULT_FAILURE;
	}

	{
		/* <UOLFONE> */
		/*
		const char * ua  = WENGOPHONE_UA;
		eXosip_set_user_agent(ua);
		*/
		if (phcfg.user_agent[0])
		{
			eXosip_set_user_agent(phcfg.user_agent);
		}
		else
		{
			const char * ua  = UOLFONECLIENT_UA;
			eXosip_set_user_agent(ua);
		}
		/* <UOLFONE> */
	}

	ph_nat_init();

/* This should be done in the setter of phcfg.proxy
	if (phcfg.force_proxy)
	{
		eXosip_force_proxy(phcfg.proxy);
	}
*/

	{
		char contact[512];

		eXosip_guess_contact_uri(phcfg.identity, contact, sizeof(contact), 1);
		eXosip_set_answer_contact(contact);
	}

	ph_vlines_init();

	ph_payloads_init();

	if (!phcfg.audio_dev || phcfg.audio_dev[0] == '\0')
	{
		// Set default audio device if no one has been set before
		owplAudioSetConfigString(0);
	}

	/* register callbacks? */
	eXosip_set_mode(EVENT_MODE);

	if (!phcfg.asyncmode)
	{
		phWaitTimeout = 1;
	}
	else 
	{
		phWaitTimeout = 500;
	}

	if (phcfg.asyncmode)
	{
		osip_thread_create(20000, ph_api_thread, 0);
	}

	ph_media_stop_mutex = g_mutex_new();

	phIsInitialized = 1;

	DEBUGTRACE("PhInit finished\n");

	return OWPL_RESULT_SUCCESS;
}
Exemple #3
0
int main( int argc, char *argv[] )
{

	/* Set default preferences and retrieve existing preferences */
	preferences_set_default_preferences();
	preferences_get_preferences_from_xml_file("preferences.xml");

	state = IDLE;

	/* Initialize libraries */
	gtk_init (&argc, &argv);
	gst_init(NULL, NULL);
	if(msrp_init(events_msrp) < 0) {
		printf("Error initializing the MSRP library...\n");
	}

	/* Display the main GUI */
	imsUA = create_imsUA ();
	gtk_widget_show (imsUA);

	/* Setup our IPTV window */
	videoWin = create_videoWin();
	gtk_window_set_decorated(GTK_WINDOW(videoWin),FALSE);

	/* Prepare a GST pipeline for the background video */
	backgroundVideoPipeline = NULL;




	if (initialise_eXosip() < 0)
	{
		fprintf(stderr, "Could not initialise - Is port 5060 in use?\n");
	}
	else
	{
		eXosip_set_user_agent("UCT IMS Client");

		presence_get_buddy_list_from_file("buddylist");

		/* Check for incoming eXosip events every 200 ms */
		g_timeout_add (200, get_exosip_events, imsUA);

		/* run the main GUI */
		gtk_main ();

		/* if registered to a proxy deregister on exit*/
		if(registered == REGISTERED)//if client is registered
		{
			ims_send_deregister_message ();

			sleep(1);

			eXosip_event_t *je;

			while((je = eXosip_event_wait(0,50)) != NULL)
			{
				if((je->type == EXOSIP_REGISTRATION_FAILURE) && ((je->response)->status_code == 401))
					ims_process_401(je);
			}

		}

		presence_write_buddy_list_to_file("buddylist");

		preferences_write_preferences_to_xml_file("preferences.xml");

		msrp_quit();
		eXosip_quit();
		return 0;
	}
}
Exemple #4
0
int uas_init(sipua_uas_t* uas, int sip_port, const char* nettype, const char* addrtype, const char* firewall, const char* proxy)
{
	int ip_family;

	if(strcmp(nettype, "IN") != 0)
	{
		jua_log(("sipua_uas: Current, Only IP networking supported\n"));

		return UA_FAIL;
	}

	if(strcmp(addrtype, "IP4") != 0)
	{
		jua_log(("sipua_uas: Current, Only IPv4 networking supported\n"));
		return UA_FAIL;
	}
		
	ip_family = AF_INET;

	if (eXosip_init(stdin, stdout, sip_port) != 0)
    {
		jua_log(("sipua_uas: could not initialize eXosip\n"));
		return UA_FAIL;
    }
  
	/* detect local address */
	eXosip_guess_ip_for_via(ip_family, uas->netaddr, 63);
   
	if (uas->netaddr[0]=='\0')
   {
		jua_log(("sipua_uas: No ethernet interface found!\n"));

		jua_log(("sipua_uas: using ip[127.0.0.1] (debug mode)!\n"));

      strcpy(uas->netaddr, "127.0.0.1");
   }
	else
	{
		jua_log(("sipua_uas: local address[%s]\n", uas->netaddr));
	}

	strcpy(uas->nettype, nettype);
	strcpy(uas->addrtype, addrtype);

	if(firewall)
   {
		strcpy(uas->firewall, firewall);
      eXosip_set_firewallip(firewall);
		jua_log(("sipua_uas: firewall[%s]\n", firewall));
   }
   
	if(proxy)
   {
		strcpy(uas->proxy, proxy);
		jua_log(("sipua_uas: proxy[%s]\n", proxy));
   }
   else
   {
		jua_log(("sipua_uas: proxy depend on user profile\n"));
   }

	uas->portno = sip_port;
	
	eXosip_set_user_agent("Ogmp/eXosip");
	jua_log(("sipua_uas: uas ready\n"));

	return UA_OK;
}
Exemple #5
0
OWPL_RESULT
owplInit
(
	const int asyncCallbackMode,
	short udpPort,
	short tcpPort,
	short tlsPort,
	const char* szBindToAddr,
	const int bUserSequentialPorts
)
{
	int return_code;
	short useUdp = (udpPort == -1 ? 0 : 1);
	short useTcp = (tcpPort == -1 ? 0 : 1);
	short useTls = (tlsPort == -1 ? 0 : 1);
	const char* ptime;

	return_code = owplAdapterInitialize();
	if (return_code != 0)
	{
		owplLogError("owplAdapterInitialize failed");
		return OWPL_RESULT_FAILURE;
	}
	return_code = owplAdapterNortelInitialize("nortel");
	if (return_code != 0)
	{
		owplLogError("owplAdapterNortelInitialize failed");
		return OWPL_RESULT_FAILURE;
	}

	phcb = (phCallbacks_t * ) malloc(sizeof(phCallbacks_t));
	memset(phcb, 0, sizeof(phCallbacks_t));

	phcfg.asyncmode = asyncCallbackMode;

	return_code = owplInitOwsl(useUdp, useTcp, useTls);
	if (return_code != 0)
	{
		owplLogError("owplInitOwsl failed");
		return OWPL_RESULT_FAILURE;
	}

	osip_trace_initialize_func(OSIP_INFO3, owplOsipLogFunction);

	return_code = eXosip_init(0, 0, udpPort, tcpPort, tlsPort);
	if (return_code != 0)
	{
		owplLogError("eXosip_init failed");
		return OWPL_RESULT_FAILURE;
	}

	{

		const char version[] = stringize(VOXOXVERSION);//VOXOX - CJC - 2009.06.27 
		// VOXOX CHANGE by ASV 06-27-2009: modified the code to be compatible with GCC
		char ua[50] = "VoxOx "; // We need to define he size to make sure strcat has enough space to copy version in ua
		strcat(ua, version);//VOXOX - CJC - 2009.06.27 
		// VOXOX CHANGE by ASV - end
		eXosip_set_user_agent(ua);
	}

	ph_avcodec_init();
	ph_calls_init();

#ifdef FORCE_VAD
/* HACK for test */
#ifdef EMBED
	phcfg.vad = VAD_VALID_MASK | (500 & VAD_THRESHOLD_MASK);
#else
	phcfg.vad = VAD_VALID_MASK | (1000 & VAD_THRESHOLD_MASK);
#endif
#endif

#ifdef FORCE_CNG
  /* HACK for test */
  phcfg.cng = 1;
#endif

	ph_media_init(phcfg.plugin_path);

	ph_vlines_init();

	ph_payloads_init();

	if (!phcfg.audio_dev || phcfg.audio_dev[0] == '\0')
	{
		// Set default audio device if no one has been set before
		owplAudioSetConfigString(0);
	}
#if 0	
	ptime = getenv("EXOSIP_FORCE_PTIME");
	if (!ptime || !*ptime)
	{
		putenv("EXOSIP_FORCE_PTIME=20");
	}
#endif	
	/* register callbacks? */
	eXosip_set_mode(EVENT_MODE);

	if (!phcfg.asyncmode)
	{
		phWaitTimeout = 1;
	}
	else 
	{
		phWaitTimeout = 500;
	}

	if (phcfg.asyncmode)
	{
		osip_thread_create(20000, ph_api_thread, 0);
	}

	pthread_mutex_init(&ph_media_stop_mutex, NULL);

	phIsInitialized = 1;

	owplLogDebug("owplInit finished");

	return OWPL_RESULT_SUCCESS;
}
Exemple #6
0
int
main (int argc, char *argv[])
#endif
{
  int c;
  int port = 5060;
  char *contact = NULL;
  char *fromuser = NULL;
  const char *localip = NULL;
  const char *firewallip = NULL;
  char *proxy = NULL;

#if !defined(__arc__)
  struct servent *service;
#endif
  char *username = NULL;
  char *password = NULL;
  struct regparam_t regparam = { 0, 3600, 0 };
#ifndef OSIP_MONOTHREAD
  struct osip_thread *register_thread;
#endif
  int debug = 0;
  int nofork = 0;

#ifdef _WIN32_WCE
  proxy = osip_strdup ("sip:sip.antisip.com");
  fromuser = osip_strdup ("sip:[email protected]");

#else
  for (;;) {
#define short_options "c:de:f:hl:p:r:u:U:P:"
#ifdef _GNU_SOURCE
    int option_index = 0;

    static struct option long_options[] = {
      {"contact", required_argument, NULL, 'c'},
      {"debug", no_argument, NULL, 'd'},
      {"expiry", required_argument, NULL, 'e'},
      {"firewallip", required_argument, NULL, 'f'},
      {"from", required_argument, NULL, 'u'},
      {"help", no_argument, NULL, 'h'},
      {"localip", required_argument, NULL, 'l'},
      {"port", required_argument, NULL, 'p'},
      {"proxy", required_argument, NULL, 'r'},
      {"username", required_argument, NULL, 'U'},
      {"password", required_argument, NULL, 'P'},
      {NULL, 0, NULL, 0}
    };

    c = getopt_long (argc, argv, short_options, long_options, &option_index);
#else
    c = getopt (argc, argv, short_options);
#endif
    if (c == -1)
      break;

    switch (c) {
    case 'c':
      contact = optarg;
      break;
    case 'd':
      nofork = 1;
#ifdef LOG_PERROR
      debug = LOG_PERROR;
#endif
      break;
    case 'e':
      regparam.expiry = atoi (optarg);
      break;
    case 'f':
      firewallip = optarg;
      break;
    case 'h':
      usage ();
      exit (0);
    case 'l':
      localip = optarg;
      break;
    case 'p':
#if !defined(__arc__)
      service = getservbyname (optarg, "udp");
      if (service)
        port = ntohs (service->s_port);
      else
        port = atoi (optarg);
#else
      port = atoi (optarg);
#endif
      break;
    case 'r':
      proxy = optarg;
      break;
    case 'u':
      fromuser = optarg;
      break;
    case 'U':
      username = optarg;
      break;
    case 'P':
      password = optarg;
      break;
    default:
      break;
    }
  }
#endif


  if (!proxy || !fromuser) {
    usage ();
    exit (1);
  }
#ifndef _WIN32_WCE
  if (!nofork) {
    daemon (1, 0);
  }
#endif

#if 0
  openlog (PROG_NAME, LOG_PID | debug, SYSLOG_FACILITY);
#endif

  syslog_wrapper (LOG_INFO, UA_STRING " up and running");
  syslog_wrapper (LOG_INFO, "proxy: %s", proxy);
  syslog_wrapper (LOG_INFO, "fromuser: %s", fromuser);
  syslog_wrapper (LOG_INFO, "contact: %s", contact);
  syslog_wrapper (LOG_INFO, "expiry: %d", regparam.expiry);
  syslog_wrapper (LOG_INFO, "local port: %d", port);

  if (debug > 0)
    TRACE_INITIALIZE (6, NULL);

  context_eXosip = eXosip_malloc ();
  if (eXosip_init (context_eXosip)) {
    syslog_wrapper (LOG_ERR, "eXosip_init failed");
    exit (1);
  }
  if (eXosip_listen_addr (context_eXosip, IPPROTO_UDP, NULL, port, AF_INET, 0)) {
    syslog_wrapper (LOG_ERR, "eXosip_listen_addr failed");
    exit (1);
  }

  if (localip) {
    syslog_wrapper (LOG_INFO, "local address: %s", localip);
    eXosip_masquerade_contact (context_eXosip, localip, port);
  }

  if (firewallip) {
    syslog_wrapper (LOG_INFO, "firewall address: %s:%i", firewallip, port);
    eXosip_masquerade_contact (context_eXosip, firewallip, port);
  }

  eXosip_set_user_agent (context_eXosip, UA_STRING);

  if (username && password) {
    syslog_wrapper (LOG_INFO, "username: %s", username);
    syslog_wrapper (LOG_INFO, "password: [removed]");
    if (eXosip_add_authentication_info (context_eXosip, username, username, password, NULL, NULL)) {
      syslog_wrapper (LOG_ERR, "eXosip_add_authentication_info failed");
      exit (1);
    }
  }

  {
    osip_message_t *reg = NULL;
    int i;

    regparam.regid = eXosip_register_build_initial_register (context_eXosip, fromuser, proxy, contact, regparam.expiry * 2, &reg);
    if (regparam.regid < 1) {
      syslog_wrapper (LOG_ERR, "eXosip_register_build_initial_register failed");
      exit (1);
    }
    i = eXosip_register_send_register (context_eXosip, regparam.regid, reg);
    if (i != 0) {
      syslog_wrapper (LOG_ERR, "eXosip_register_send_register failed");
      exit (1);
    }
  }

#ifndef OSIP_MONOTHREAD
  register_thread = osip_thread_create (20000, register_proc, &regparam);
  if (register_thread == NULL) {
    syslog_wrapper (LOG_ERR, "pthread_create failed");
    exit (1);
  }
#endif

  for (;;) {
    eXosip_event_t *event;

    if (!(event = eXosip_event_wait (context_eXosip, 0, 1))) {
#ifdef OSIP_MONOTHREAD
      eXosip_execute (context_eXosip);
      eXosip_automatic_action (context_eXosip);
#endif
      osip_usleep (10000);
      continue;
    }
#ifdef OSIP_MONOTHREAD
    eXosip_execute (context_eXosip);
#endif

    eXosip_automatic_action (context_eXosip);
    switch (event->type) {
    case EXOSIP_REGISTRATION_SUCCESS:
      syslog_wrapper (LOG_INFO, "registrered successfully");
      break;
    case EXOSIP_REGISTRATION_FAILURE:
      regparam.auth = 1;
      break;
    default:
      syslog_wrapper (LOG_DEBUG, "recieved unknown eXosip event (type, did, cid) = (%d, %d, %d)", event->type, event->did, event->cid);

    }
    eXosip_event_free (event);
  }
}