From: <do...@us...> - 2007-12-21 14:52:44
|
Revision: 1325 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1325&view=rev Author: dohpaz Date: 2007-12-21 06:52:48 -0800 (Fri, 21 Dec 2007) Log Message: ----------- Merge up to trunk of r1324. Modified Paths: -------------- branches/team/elbunce/iaxclient/Doxyfile branches/team/elbunce/iaxclient/doc/src/mainpage.dox branches/team/elbunce/iaxclient/lib/iaxclient_lib.c branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c branches/team/elbunce/iaxclient/lib/libiax2/src/iax2-parser.c Modified: branches/team/elbunce/iaxclient/Doxyfile =================================================================== --- branches/team/elbunce/iaxclient/Doxyfile 2007-12-20 17:45:11 UTC (rev 1324) +++ branches/team/elbunce/iaxclient/Doxyfile 2007-12-21 14:52:48 UTC (rev 1325) @@ -200,7 +200,7 @@ ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES -SEARCH_INCLUDES = YES +SEARCH_INCLUDES = NO INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ Modified: branches/team/elbunce/iaxclient/doc/src/mainpage.dox =================================================================== --- branches/team/elbunce/iaxclient/doc/src/mainpage.dox 2007-12-20 17:45:11 UTC (rev 1324) +++ branches/team/elbunce/iaxclient/doc/src/mainpage.dox 2007-12-21 14:52:48 UTC (rev 1325) @@ -1,8 +1,7 @@ /*! \mainpage <A href="http://iaxclient.sourceforge.net/">IAXClient</A> is an Open Source library to implement the IAX protocol used by -<A href="http://www.asterisk.org/">The Asterisk Software PBX</A>. -It is licensed under the the LGPL \ref License.<BR> +<A href="http://www.asterisk.org/">The Asterisk Software PBX</A> and is licensed under the the LGPL \ref License.<BR> Although asterisk supports other VOIP protocols (including SIP, and with patches, H.323), IAX's simple, lightweight nature gives it several advantages, particularly in that it can operate easily through NAT and packet firewalls, and it is easily extensible and simple to understand. Modified: branches/team/elbunce/iaxclient/lib/iaxclient_lib.c =================================================================== --- branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-20 17:45:11 UTC (rev 1324) +++ branches/team/elbunce/iaxclient/lib/iaxclient_lib.c 2007-12-21 14:52:48 UTC (rev 1325) @@ -1795,6 +1795,7 @@ iaxci_usermsg(IAXC_ERROR, "Registration requested by someone, but we don't understand!"); } else if ( e->etype == IAX_EVENT_CONNECT ) + { iaxc_handle_connect(e); } else if ( e->etype == IAX_EVENT_TIMEOUT ) Modified: branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h =================================================================== --- branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h 2007-12-20 17:45:11 UTC (rev 1324) +++ branches/team/elbunce/iaxclient/lib/libiax2/src/iax-client.h 2007-12-21 14:52:48 UTC (rev 1325) @@ -184,6 +184,7 @@ extern int iax_ring_announce(struct iax_session *session); extern struct sockaddr_in iax_get_peer_addr(struct iax_session *session); extern int iax_register(struct iax_session *session, const char *hostname, const char *peer, const char *secret, int refresh); +extern int iax_unregister(struct iax_session *session, const char *hostname, const char *peer, const char *secret, const char *reason); extern int iax_lag_request(struct iax_session *session); extern int iax_dial(struct iax_session *session, char *number); /* Dial on a TBD call */ extern int iax_dialplan_request(struct iax_session *session, char *number); /* Request dialplan status for number */ @@ -246,8 +247,8 @@ extern void iax_set_jb_target_extra( long value ); /* Portable 'decent' random number generation */ -void iax_seed_random(); -int iax_random(); +extern void iax_seed_random(void); +extern int iax_random(void); #if defined(__cplusplus) } Modified: branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c =================================================================== --- branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-20 17:45:11 UTC (rev 1324) +++ branches/team/elbunce/iaxclient/lib/libiax2/src/iax.c 2007-12-21 14:52:48 UTC (rev 1325) @@ -202,6 +202,8 @@ struct timeval rxcore; /* Current link state */ int state; + /* Unregister reason */ + char unregreason[MAXSTRLEN]; /* Expected Username */ char username[MAXSTRLEN]; /* Expected Secret */ @@ -282,7 +284,7 @@ srandomdev(); #elif defined(HAVE_SRANDOM) srandom((unsigned int)time(0)); -#elif define(HAVE_SRAND48) +#elif defined(HAVE_SRAND48) srand48((long int)time(0)); #else srand((unsigned int)time(0)); @@ -1756,6 +1758,8 @@ else strcpy(session->secret, ""); + memset(&session->unregreason, 0, sizeof(session->unregreason)); + /* Connect first */ hp = gethostbyname(tmp); if (!hp) { @@ -1773,6 +1777,49 @@ return res; } +int iax_unregister(struct iax_session *session, const char *server, const char *peer, const char *secret, const char *reason) +{ + /* Send an unregistration request */ + char tmp[256]; + char *p; + int portno = IAX_DEFAULT_PORTNO; + struct iax_ie_data ied; + struct hostent *hp; + + tmp[255] = '\0'; + strncpy(tmp, server, sizeof(tmp) - 1); + p = strchr(tmp, ':'); + if (p) { + *p = '\0'; + portno = atoi(p+1); + } + + memset(&ied, 0, sizeof(ied)); + if (secret) + strncpy(session->secret, secret, sizeof(session->secret) - 1); + else + strcpy(session->secret, ""); + + if (reason && strlen(reason)) + strncpy(session->unregreason, reason, sizeof(session->unregreason) - 1); + else + strcpy(session->unregreason, "Unspecified"); + + /* Connect first */ + hp = gethostbyname(tmp); + if (!hp) { + snprintf(iax_errstr, sizeof(iax_errstr), "Invalid hostname: %s", tmp); + return -1; + } + memcpy(&session->peeraddr.sin_addr, hp->h_addr, sizeof(session->peeraddr.sin_addr)); + session->peeraddr.sin_port = htons(portno); + session->peeraddr.sin_family = AF_INET; + strncpy(session->username, peer, sizeof(session->username) - 1); + iax_ie_append_str(&ied, IAX_IE_USERNAME, peer); + iax_ie_append_str(&ied, IAX_IE_CAUSE, session->unregreason); + return send_command(session, AST_FRAME_IAX, IAX_COMMAND_REGREL, 0, ied.buf, ied.pos, -1); +} + int iax_reject(struct iax_session *session, char *reason) { struct iax_ie_data ied; @@ -1970,7 +2017,6 @@ struct iax_ie_data ied; memset(&ied, 0, sizeof(ied)); iax_ie_append_str(&ied, IAX_IE_USERNAME, session->username); - iax_ie_append_short(&ied, IAX_IE_REFRESH, session->refresh); if ((methods & IAX_AUTHMETHOD_MD5) && challenge) { MD5Init(&md5); MD5Update(&md5, (const unsigned char *) challenge, @@ -1984,7 +2030,13 @@ } else { iax_ie_append_str(&ied, IAX_IE_PASSWORD, password); } - return send_command(session, AST_FRAME_IAX, IAX_COMMAND_REGREQ, 0, ied.buf, ied.pos, -1); + if (strlen(session->unregreason)) { /* Non-zero unregreason length indicates REGREL */ + iax_ie_append_str(&ied, IAX_IE_CAUSE, session->unregreason); + return send_command(session, AST_FRAME_IAX, IAX_COMMAND_REGREL, 0, ied.buf, ied.pos, -1); + } else { + iax_ie_append_short(&ied, IAX_IE_REFRESH, session->refresh); + return send_command(session, AST_FRAME_IAX, IAX_COMMAND_REGREQ, 0, ied.buf, ied.pos, -1); + } } Modified: branches/team/elbunce/iaxclient/lib/libiax2/src/iax2-parser.c =================================================================== --- branches/team/elbunce/iaxclient/lib/libiax2/src/iax2-parser.c 2007-12-20 17:45:11 UTC (rev 1324) +++ branches/team/elbunce/iaxclient/lib/libiax2/src/iax2-parser.c 2007-12-21 14:52:48 UTC (rev 1325) @@ -345,7 +345,12 @@ "ANSWER ", "BUSY ", "TKOFFHK ", - "OFFHOOK" }; + "OFFHOOK ", + "CONGESTION ", + "FLASH ", + "WINK ", + "OPTION " + }; struct ast_iax2_full_hdr *fh; char retries[20]; char class2[20]; @@ -368,7 +373,7 @@ /* Don't mess with mini-frames */ return; } - if (fh->type > (int)sizeof(frames)/(int)sizeof(char *)) { + if (fh->type >= (int)(sizeof(frames)/sizeof(char *))) { snprintf(class2, (int)sizeof(class2), "(%d?)", fh->type); clas = class2; } else { @@ -385,7 +390,7 @@ subclass = iaxs[(int)fh->csub]; } } else if (fh->type == AST_FRAME_CONTROL) { - if (fh->csub > (int)sizeof(cmds)/(int)sizeof(char *)) { + if (fh->csub >= (int)(sizeof(cmds)/sizeof(char *))) { snprintf(subclass2, (int)sizeof(subclass2), "(%d?)", fh->csub); subclass = subclass2; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |