From: <do...@us...> - 2007-12-06 06:05:29
|
Revision: 1302 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1302&view=rev Author: dohpaz Date: 2007-12-05 22:05:28 -0800 (Wed, 05 Dec 2007) Log Message: ----------- Add iaxc_register_ex() API to support passing a registration refresh time. Tweak transfer diagnostics. Modified Paths: -------------- branches/team/elbunce/iaxclient/lib/iaxclient.h branches/team/elbunce/iaxclient/lib/iaxclient_lib.c branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c Modified: branches/team/elbunce/iaxclient/lib/iaxclient.h =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient.h 2007-12-05 23:36:59 UTC (rev 1301) +++ branches/team/elbunce/iaxclient/lib/iaxclient.h 2007-12-06 06:05:28 UTC (rev 1302) @@ -793,6 +793,17 @@ EXPORT int iaxc_register(const char * user, const char * pass, const char * host); /*! + Registers the IAXClient instance with an IAX server + \param user The username to register as + \param pass The password to register with + \param host The address of the host/peer to register with + \param refresh The registration refresh period + + \return The registration id number upon success; -1 otherwise. +*/ +EXPORT int iaxc_register_ex(const char * user, const char * pass, const char * host, int refresh); + +/*! Respond to incoming call \a callNo as busy. */ EXPORT void iaxc_send_busy_on_incoming_call(int callNo); Modified: branches/team/elbunce/iaxclient/lib/iaxclient_lib.c =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-05 23:36:59 UTC (rev 1301) +++ branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-06 06:05:28 UTC (rev 1302) @@ -80,8 +80,6 @@ struct iaxc_registration *next; }; -static int registration_timeout = 60; - static int next_registration_id = 0; static struct iaxc_registration *registrations = NULL; @@ -753,7 +751,7 @@ { // If there is less than one second before the registration is about // to expire, renew it. - if ( iaxci_usecdiff(&now, &cur->last) > cur->refresh - 1 * 1000 *1000 ) + if ( iaxci_usecdiff(&now, &cur->last) > (cur->refresh - 1) * 1000 *1000 ) { if ( cur->session != NULL ) { @@ -765,7 +763,7 @@ iaxci_usermsg(IAXC_ERROR, "Can't make new registration session"); return; } - iax_register(cur->session, cur->host, cur->user, cur->pass, registration_timeout); + iax_register(cur->session, cur->host, cur->user, cur->pass, cur->refresh); cur->last = now; } } @@ -1247,6 +1245,11 @@ EXPORT int iaxc_register(const char * user, const char * pass, const char * host) { + iaxc_register_ex(user, pass, host, 60); +} + +EXPORT int iaxc_register_ex(const char * user, const char * pass, const char * host, int refresh) +{ struct iaxc_registration *newreg; newreg = (struct iaxc_registration *)malloc(sizeof (struct iaxc_registration)); @@ -1266,14 +1269,14 @@ } gettimeofday(&newreg->last,NULL); - newreg->refresh = (registration_timeout - 2) *1000*1000; /* 2 seconds before registration timeout, in usecs */ + newreg->refresh = refresh; strncpy(newreg->host, host, 256); strncpy(newreg->user, user, 256); strncpy(newreg->pass, pass, 256); - /* send out the initial registration with registration_timeout seconds */ - iax_register(newreg->session, host, user, pass, registration_timeout); + /* send out the initial registration with refresh seconds */ + iax_register(newreg->session, host, user, pass, refresh); /* add it to the list; */ newreg->id = ++next_registration_id; Modified: branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c =================================================================== --- branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-05 23:36:59 UTC (rev 1301) +++ branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-06 06:05:28 UTC (rev 1302) @@ -1429,8 +1429,8 @@ s1->transferpeer = s0->callno; DEBU(G "iax_setup_transfer(%d, %d) transfer_id=%d\n", s0->callno, s1->callno, transfer_id); - DEBU(G "\torg: callno=%d peercallno=%d peeraddr=%s\n", s0->callno, s0->peercallno, inet_ntoa(s0->peeraddr.sin_addr)); - DEBU(G "\tnew: callno=%d peercallno=%d peeraddr=%s\n", s1->callno, s1->peercallno, inet_ntoa(s1->peeraddr.sin_addr)); + DEBU(G "\torg: callno=%d peercallno=%d peeraddr=%s peerport=%d\n", s0->callno, s0->peercallno, inet_ntoa(s0->peeraddr.sin_addr), ntohs(s0->peeraddr.sin_port)); + DEBU(G "\tnew: callno=%d peercallno=%d peeraddr=%s peerport=%d\n", s1->callno, s1->peercallno, inet_ntoa(s1->peeraddr.sin_addr), ntohs(s1->peeraddr.sin_port)); res = send_command(s0, AST_FRAME_IAX, IAX_COMMAND_TXREQ, 0, ied0.buf, ied0.pos, -1); if (res < 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |