int main ( int argc, char *argv[] ) { int i, port = 5060; osip_trace_initialize_func(END_TRACE_LEVEL, &android_trace_func); i=eXosip_init(); if (i!=0) return -1; i = eXosip_listen_addr (IPPROTO_UDP, NULL, port, AF_INET, 0); if (i!=0) { eXosip_quit(); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "%s", "could not initialize transport layer\n"); return -1; } eXosip_event_t *je; for (;;) { je = eXosip_event_wait (0, 24*60*60*1000); eXosip_lock(); eXosip_automatic_action (); eXosip_unlock(); if (je == NULL) break; if (je->type == EXOSIP_CALL_INVITE) { __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "%s", "incoming call\n"); std::cout << "incoming call" << std::endl; } } return 0; } // ---------- end of function main ----------
int csenn_eXosip_init(void) { g_register_id = 0;/*注册ID/用来更新注册或取消注册*/ g_call_id = 0;/*INVITE连接ID/用来分辨不同的INVITE连接,每个时刻只允许有一个INVITE连接*/ g_did_realPlay = 0;/*会话ID/用来分辨不同的会话:实时视音频点播*/ g_did_backPlay = 0;/*会话ID/用来分辨不同的会话:历史视音频回放*/ g_did_fileDown = 0;/*会话ID/用来分辨不同的会话:视音频文件下载*/ int ret = 0; ret = eXosip_init();/*初始化osip和eXosip协议栈*/ if (0 != ret) { printf("Couldn't initialize eXosip!\r\n"); return -1; } printf("eXosip_init success!\r\n"); ret = eXosip_listen_addr(IPPROTO_UDP, NULL, atoi(device_info.ipc_port), AF_INET, 0); if (0 != ret)/*传输层初始化失败*/ { eXosip_quit(); printf("eXosip_listen_addr error!\r\n"); return -1; } printf("eXosip_listen_addr success!\r\n"); return 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); }
int initialise_eXosip() { int port = 5060; int i = eXosip_init(); if (i != 0) { fprintf(stderr, "Could not start exosip\n"); return -1; } while(eXosip_listen_addr (IPPROTO_UDP, NULL, port, AF_INET, 0) != 0) { port++; } printf("UCT IMS Client - SIP port %d - Audio Port: %d - Video Port: %d\n\n", port, pref->local_audio_port, pref->local_video_port); return 0; }
int main (int argc, char *argv[]) { int port = 5060; eXosip_event_t *event = NULL; succeed_type flag; #if !defined(__arc__) struct servent *service = NULL; #endif struct regparam_t regparam = { 0, 3600, 0 }; int debug = 1; port = 5060; #if 0 if (debug > 0) TRACE_INITIALIZE (6, NULL); #endif context_eXosip = eXosip_malloc (); if (eXosip_init (context_eXosip)) { printf("eXosip_init failed\r\n"); exit (1); } if (eXosip_listen_addr (context_eXosip, IPPROTO_UDP, "192.168.5.118", port, AF_INET, 0)) { printf("eXosip_listen_addr failed\r\n"); exit (1); } /*start the notify thread */ #ifndef OSIP_MONOTHREAD notify_thread = osip_thread_create(20000, notify_proc, ®param); #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; } eXosip_lock(context_eXosip); #ifdef OSIP_MONOTHREAD eXosip_execute (context_eXosip); #endif // eXosip_automatic_action (context_eXosip); eXosip_unlock(context_eXosip); eXosip_automatic_action(context_eXosip); switch (event->type) { case EXOSIP_CALL_INVITE: if(MSG_IS_INVITE(event->request)) { flag = handle_request_invite(context_eXosip, event); if(flag == succeed_type_failed) { printf("handle invite request failed\r\n"); }else{ printf("handle invite request succeed\r\n"); } continue; } break; case EXOSIP_CALL_REINVITE: break; case EXOSIP_CALL_NOANSWER: break; case EXOSIP_CALL_PROCEEDING: break; case EXOSIP_CALL_RINGING: break; case EXOSIP_CALL_ANSWERED: break; case EXOSIP_CALL_REDIRECTED: break; case EXOSIP_CALL_REQUESTFAILURE: break; case EXOSIP_CALL_SERVERFAILURE: break; case EXOSIP_CALL_GLOBALFAILURE: break; case EXOSIP_CALL_ACK: break; case EXOSIP_CALL_CANCELLED: break; case EXOSIP_CALL_MESSAGE_NEW: break; case EXOSIP_CALL_MESSAGE_PROCEEDING: printf("EXOSIP_CALL_MESSAGE_PROCEEDING\r\n"); break; case EXOSIP_CALL_MESSAGE_ANSWERED: break; case EXOSIP_CALL_MESSAGE_REDIRECTED: break; case EXOSIP_CALL_MESSAGE_REQUESTFAILURE: break; case EXOSIP_CALL_MESSAGE_SERVERFAILURE: break; case EXOSIP_CALL_MESSAGE_GLOBALFAILURE: break; case EXOSIP_CALL_CLOSED: break; case EXOSIP_CALL_RELEASED: break; case EXOSIP_MESSAGE_NEW: printf("answer EXOSIP_MESSAGE_NEW\r\n"); if(MSG_IS_MESSAGE(event->request)) { flag = handle_request_message(context_eXosip, event); if(flag == succeed_type_failed) { printf("handle message request failed\r\n"); }else{ printf("handle message request succeed\r\n"); } continue; } if(MSG_IS_REGISTER(event->request)) { flag = handle_request_register(context_eXosip, event); if(flag == succeed_type_failed) { printf("handle register request failed\r\n"); }else{ printf("handle register request succeed\r\n"); } continue; } break; case EXOSIP_MESSAGE_PROCEEDING: break; case EXOSIP_MESSAGE_ANSWERED: break; case EXOSIP_MESSAGE_REDIRECTED: break; case EXOSIP_MESSAGE_REQUESTFAILURE: break; case EXOSIP_MESSAGE_SERVERFAILURE: break; case EXOSIP_MESSAGE_GLOBALFAILURE: break; case EXOSIP_SUBSCRIPTION_NOANSWER: break; case EXOSIP_SUBSCRIPTION_PROCEEDING: break; case EXOSIP_SUBSCRIPTION_ANSWERED: break; case EXOSIP_SUBSCRIPTION_REDIRECTED: break; case EXOSIP_SUBSCRIPTION_REQUESTFAILURE: break; case EXOSIP_SUBSCRIPTION_SERVERFAILURE: break; case EXOSIP_SUBSCRIPTION_GLOBALFAILURE: break; case EXOSIP_SUBSCRIPTION_NOTIFY: break; case EXOSIP_IN_SUBSCRIPTION_NEW: //subscribe event if(MSG_IS_SUBSCRIBE(event->request)) { flag = handle_request_subscribe(context_eXosip, event); if(flag == succeed_type_failed) { printf("handle subscribe request failed\r\n"); }else{ printf("handle subscribe request succeed\r\n"); } continue; } break; case EXOSIP_NOTIFICATION_NOANSWER: break; case EXOSIP_NOTIFICATION_PROCEEDING: break; case EXOSIP_NOTIFICATION_ANSWERED: break; case EXOSIP_NOTIFICATION_REDIRECTED: break; case EXOSIP_NOTIFICATION_REQUESTFAILURE: break; case EXOSIP_NOTIFICATION_SERVERFAILURE: break; case EXOSIP_NOTIFICATION_GLOBALFAILURE: break; case EXOSIP_EVENT_COUNT: break; default: printf( "recieved unknown eXosip event (type, did, cid) = (%d, %d, %d)", event->type, event->did, event->cid); } eXosip_event_free (event); } }
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; }
int main (int argc, char *argv[]) { eXosip_event_t *je; osip_message_t *reg = NULL; osip_message_t *invite = NULL; osip_message_t *ack = NULL; osip_message_t *info = NULL; osip_message_t *message = NULL; int call_id, dialog_id; int i,flag; int flag1 = 1; int id; char *identity = "sip:[email protected]"; char *registerer = "sip:192.168.44.100:5060"; char *source_call = "sip:[email protected]"; char *dest_call = "sip:[email protected]:5060"; char command; char tmp[4096]; char localip[128]; printf("r 向服务器注册\n\n"); printf("c 取消注册\n\n"); printf("i 发起呼叫请求\n\n"); printf("h 挂断\n\n"); printf("q 退出程序\n\n"); printf("s 执行方法INFO\n\n"); printf("m 执行方法MESSAGE\n\n"); //初始化 i = eXosip_init (); if (i != 0) { printf ("Couldn't initialize eXosip!\n"); return -1; } else { printf ("eXosip_init successfully!\n"); } i = eXosip_listen_addr (IPPROTO_UDP, NULL, 5060, AF_INET, 0); if (i != 0) { eXosip_quit (); fprintf (stderr, "Couldn't initialize transport layer!\n"); return -1; } flag = 1; while (flag) { printf ("please input the comand:\n"); scanf ("%c", &command); getchar (); switch (command) { case 'r': printf ("This modal isn't commpleted!\n"); break; case 'i':/* INVITE */ i = eXosip_call_build_initial_invite (&invite, dest_call, source_call, NULL, "This si a call for a conversation"); if (i != 0) { printf ("Intial INVITE failed!\n"); break; } //符合SDP格式,其中属性a是自定义格式,也就是说可以存放自己的信息,但是只能是两列,比如帐户信息 //但是经测试,格式:v o t必不可少,原因未知,估计是协议栈在传输时需要检查的 snprintf (tmp, 4096, "v=0\r\n" "o=anonymous 0 0 IN IP4 0.0.0.0\r\n" "t=1 10\r\n" "a=username:rainfish\r\n" "a=password:123\r\n"); osip_message_set_body (invite, tmp, strlen(tmp)); osip_message_set_content_type (invite, "application/sdp"); eXosip_lock (); i = eXosip_call_send_initial_invite (invite); eXosip_unlock (); flag1 = 1; while (flag1) { je = eXosip_event_wait (0, 200); if (je == NULL) { printf ("No response or the time is over!\n"); break; } switch (je->type) { case EXOSIP_CALL_INVITE: printf ("a new invite reveived!\n"); break; case EXOSIP_CALL_PROCEEDING: printf ("proceeding!\n"); break; case EXOSIP_CALL_RINGING: printf ("ringing!\n"); // call_id = je->cid; // dialog_id = je->did; printf ("call_id is %d, dialog_id is %d \n", je->cid, je->did); break; case EXOSIP_CALL_ANSWERED: printf ("ok! connected!\n"); call_id = je->cid; dialog_id = je->did; printf ("call_id is %d, dialog_id is %d \n", je->cid, je->did); eXosip_call_build_ack (je->did, &ack); eXosip_call_send_ack (je->did, ack); flag1 = 0; break; case EXOSIP_CALL_CLOSED: printf ("the other sid closed!\n"); break; case EXOSIP_CALL_ACK: printf ("ACK received!\n"); break; default: printf ("other response!\n"); break; } eXosip_event_free (je); } break; case 'h': printf ("Holded !\n"); eXosip_lock (); eXosip_call_terminate (call_id, dialog_id); eXosip_unlock (); break; case 'c': printf ("This modal isn't commpleted!\n"); break; case 's': //传输INFO方法 eXosip_call_build_info (dialog_id, &info); snprintf (tmp , 4096, "hello,rainfish"); osip_message_set_body (info, tmp, strlen(tmp)); //格式可以任意设定,text/plain代表文本信息 osip_message_set_content_type (info, "text/plain"); eXosip_call_send_request (dialog_id, info); break; case 'm': //传输MESSAGE方法,也就是即时消息,和INFO方法相比,我认为主要区别,是MESSAGE不用建立连接,直接传输信息,而INFO必须 //在建立INVITE的基础上传输。 printf ("the mothed :MESSAGE\n"); eXosip_message_build_request (&message, "MESSAGE", dest_call, source_call, NULL); snprintf (tmp, 4096, "hellor rainfish"); osip_message_set_body (message, tmp, strlen(tmp)); //假设格式是xml osip_message_set_content_type (message, "text/xml"); eXosip_message_send_request (message); break; case 'q': eXosip_quit (); printf ("Exit the setup!\n"); flag = 0; break; } } return (0); }
int main(int argc, char* argv[]) { int i; expires = 3600; memset( &call, 0, sizeof(call) ); cout<<"Please Enter Your Username:"******"Please Enter Your Password:"******"Usage:"<< endl; cout << "a - answering call"<< endl; cout << "h - hangup"<< endl; cout << "z - zhuxiao"<< endl; cout << "c - call"<< endl; cout << "q - quit"<< endl; FILE* logfile = fopen( "logfile.txt", "w"); i = eXosip_init(NULL, NULL, 6060); if (i!=0) { fprintf (stderr, "test: could not initialize eXosip\n"); __exit(0); } eXosip_sdp_negotiation_remove_audio_payloads(); reg_id = eXosip_register_init(identity, registrar, contact); j = eXosip_register(reg_id, 3600); cout<<"init"<<endl; // eXosip_sdp_negotiation_add_codec(osip_strdup("0"), // NULL, // osip_strdup("RTP/AVP"), // NULL, NULL, NULL, // NULL,NULL, // osip_strdup("0 PCMU/8000")); eXosip_sdp_negotiation_add_codec(osip_strdup("8"), NULL, osip_strdup("RTP/AVP"), NULL, NULL, NULL, NULL,NULL, osip_strdup("8 PCMA/8000")); // eXosip_sdp_negotiation_add_codec(osip_strdup("18"), // NULL, // osip_strdup("RTP/AVP"), // NULL, NULL, NULL, // NULL,NULL, // osip_strdup("18 G729a/8000")); // eXosip_set_mode(EVENT_MODE); eXosip_set_mode(EVENT_MODE); osip_message_t *invite; cout << "oSIP>"<<endl; while( run ) { josua_event_get(); if ( _kbhit() ) { switch ( _getch() ) { case 'a': cout << "answer"<< endl; eXosip_lock(); eXosip_answer_call(call.did, 200, 0); eXosip_unlock(); break; case 'h': cout << "hangup"<< endl; eXosip_lock(); eXosip_terminate_call( call.cid, call.did ); eXosip_unlock(); break; case 'z': cout << "zhuxiao"<< endl; expires = 0; reg_id = eXosip_register_init(identity, registrar, contact); j = eXosip_register(reg_id, 0); break; case 'c': cout << "call"<< endl; i = eXosip_build_initial_invite(&invite, destip, //掩請 identity, //翋請 NULL, "oSIP phone"); if (i!=0) { fprintf (stderr, "eXosip_build_initial_invite failed\n"); __exit(0); } eXosip_lock(); eXosip_initiate_call(invite, NULL, NULL, "10500"); eXosip_unlock(); break; case 'q': eXosip_quit(); cout << "quit"<< endl; run = false; break; } } } return 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; }
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; }
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, ®); 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, ®param); 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); } }