A [possibly] better solution to the CalledPartyAddress problem. Test and report please
authorJeremy McNamara <jj@nufone.net>
Thu, 11 Nov 2004 21:30:30 +0000 (21:30 +0000)
committerJeremy McNamara <jj@nufone.net>
Thu, 11 Nov 2004 21:30:30 +0000 (21:30 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4214 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_h323.c
channels/h323/ast_h323.cpp
channels/h323/ast_h323.h
channels/h323/chan_h323.h

index 6157487..fd50d52 100755 (executable)
@@ -128,7 +128,6 @@ struct oh323_pvt {
        int bridge;                                             /* Determine of we should native bridge or not*/
        char exten[AST_MAX_EXTENSION];                          /* Requested extension */
        char context[AST_MAX_EXTENSION];                        /* Context where to start */
-       char username[81];                                      /* H.323 alias using this channel */
        char accountcode[256];                                  /* Account code */
        char cid_num[256];                                      /* Caller*id number, if available */
        char cid_name[256];                                     /* Caller*id name, if available */
@@ -448,7 +447,7 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
         /* Clear and then set the address to call */
         memset(addr, 0, sizeof(addr));
         if (usingGk) {
-                memcpy(called_addr, dest, strlen(called_addr));
+                memcpy(addr, dest, strlen(addr));
                 pvt->options.noFastStart = noFastStart;
                 pvt->options.noH245Tunneling = noH245Tunneling;
                 pvt->options.noSilenceSuppression = noSilenceSuppression;
@@ -456,14 +455,17 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
         } else {
                 ast_inet_ntoa(addr, sizeof(addr), pvt->sa.sin_addr);
                 pvt->options.port = htons(pvt->sa.sin_port);
-               if (pvt->username) {
-                       sprintf(called_addr, "%s@%s", pvt->username, addr);
-
-               }
        }       
+       /* indicate that this is an outgoing call */
        pvt->outgoing = 1;
-       ast_log(LOG_DEBUG, "Placing outgoing call to %s:%d\n", dest, pvt->options.port);
-       res = h323_make_call(dest, &(pvt->cd), pvt->options);
+
+       if (pvt->exten) {
+               sprintf(called_addr, "%s@%s:%d", pvt->exten, addr, pvt->options.port);
+       } else {
+               sprintf(called_addr, "%s:%d",addr, pvt->options.port);
+       }
+       ast_log(LOG_DEBUG, "Placing outgoing call to %s\n", called_addr);
+       res = h323_make_call(called_addr, &(pvt->cd), pvt->options);
        if (res) {
                ast_log(LOG_NOTICE, "h323_make_call failed(%s)\n", c->name);
                return -1;
@@ -989,9 +991,9 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
                h323_set_id(h323id);
        }
        if (ext) {
-               strncpy(pvt->username, ext, sizeof(pvt->username) - 1);
+               strncpy(pvt->exten, ext, sizeof(pvt->exten) - 1);
        }
-       ast_log(LOG_DEBUG, "Host: %s\tUsername: %s\n", host, pvt->username);
+       ast_log(LOG_DEBUG, "Extension: %s Host: %s\n",  pvt->exten, host);
        if (!usingGk) {
                if (create_addr(pvt, host)) {
                        oh323_destroy(pvt);
index 6af7b0d..6abfff9 100755 (executable)
@@ -213,7 +213,7 @@ H323Codec * AST_G729ACapability::CreateCodec(H323Codec::Direction direction) con
   *                                    transport = ip.
   *                                    port = 1720.
   */
-int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int *callReference, unsigned int port, char *cid_name, char *cid_num)
+int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int *callReference, char *cid_name, char *cid_num)
 {
        PString fullAddress;
        MyH323Connection * connection;
@@ -227,7 +227,7 @@ int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int
        } else {
                fullAddress = dest; 
                if (h323debug) {
-                       cout << " -- Making call to " << fullAddress << "." << endl;
+                       cout << " -- Making call to " << fullAddress << " without gatekeeper." << endl;
                }
        }
        if (!(connection = (MyH323Connection *)H323EndPoint::MakeCallLocked(fullAddress, token))) {
@@ -1086,16 +1086,17 @@ void h323_send_tone(const char *call_token, char tone)
 
 /** Make a call to the remote endpoint.
   */
-int h323_make_call(char *host, call_details_t *cd, call_options_t call_options)
+int h323_make_call(char *dest, call_details_t *cd, call_options_t call_options)
 {
        int res;
        PString token;
-       PString dest(host);
+       PString host(dest);
 
        if (!h323_end_point_exist()) {
                return 1;
        }
-       res = endPoint->MakeCall(dest, token, &cd->call_reference, call_options.port, call_options.cid_num, call_options.cid_name);
+
+       res = endPoint->MakeCall(host, token, &cd->call_reference, call_options.cid_name, call_options.cid_num);
        memcpy((char *)(cd->call_token), (const unsigned char *)token, token.GetLength());
        return res;
 };
index 564d942..f9a454b 100755 (executable)
@@ -128,7 +128,7 @@ class MyH323EndPoint : public H323EndPoint {
        PCLASSINFO(MyH323EndPoint, H323EndPoint);
 
        public:
-       int MakeCall(const PString &, PString &, unsigned int *, unsigned int, char *, char *);
+       int MakeCall(const PString &, PString &, unsigned int *, char *, char *);
        BOOL ClearCall(const PString &);
 
        void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
index 2ea6efc..1f84610 100755 (executable)
@@ -196,7 +196,7 @@ extern "C" {
        void h323_send_tone(const char *call_token, char tone);
 
        /* H323 create and destroy sessions */
-       int h323_make_call(char *host, call_details_t *cd, call_options_t);
+       int h323_make_call(char* dest, call_details_t *cd, call_options_t);
        int h323_clear_call(const char *);
        
        /* H.323 alerting and progress */