exchange.h
资源名称:h323.zip [点击查看]
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:8k
源码类别:
IP电话/视频会议
开发平台:
WINDOWS
- /*
- * $Revision: 1.17 $
- * $Date: 1999/03/15 22:49:36 $
- */
- ////////////////////////////////////////////////////////////////
- // Copyright (c) 1996,97 Lucent Technologies //
- // All Rights Reserved //
- // //
- // THIS IS UNPUBLISHED //
- // PROPRIETARY SOURCE //
- // CODE OF Lucent Technologies //
- // AND elemedia //
- // //
- ////////////////////////////////////////////////////////////////
- //
- ////////////////////////////////////////////////////////////////
- // Example programs are provided soley to demonstrate one //
- // possible use of the stack libraries and are included for //
- // instructional purposes only. You are free to use, modify //
- // and/or redistribute any portion of code in the example //
- // programs. However, such examples are not intended to //
- // represent production quality code. //
- // //
- // THE COPYRIGHT HOLDERS PROVIDE THESE EXAMPLE PROGRAMS //
- // "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED //
- // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED //
- // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A //
- // PARTICULAR PURPOSE. //
- ////////////////////////////////////////////////////////////////
- #if (!defined(__EXCHANGE_H__))
- #define __EXCHANGE_H__
- #include <stdio.h>
- #include <ctype.h>
- #if (defined(WIN32))
- #include <windows.h>
- #include <process.h>
- extern char *optarg;
- extern int getopt (int argc, char ** argv, const char * optstring);
- #elif defined(VXWORKS)
- #include "vxWorks.h"
- #include "taskLib.h"
- #include "semLib.h"
- #include "selectLib.h"
- #include "fcntl.h"
- #include "sockLib.h"
- #include "inetLib.h"
- #include "hostLib.h"
- #include "sysLib.h"
- #else
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netdb.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #if defined(__hpux)
- #include <pthread.h>
- #else
- #include <thread.h>
- #endif
- #endif
- #include "api/connmgrerr.h"
- #include "api/connmgr.h"
- #include "api/h225types.h"
- #if defined(USE_RAS)
- #include "api/h225ras.h"
- #endif
- #include "mq.h"
- #include "h450msgs.h"
- // Because of the dummy scheme of E.164 alias registration
- // in this sample we use only 200 lines.
- #if defined(USE_RAS)
- #define NUM_LINES 200
- #else
- #define NUM_LINES 1024
- #endif
- #define H323_ID_ALIAS "elemedia"
- #define E164_ALIAS "555"
- #define Q931PORT 1720
- #if defined(USE_RAS)
- #define LOCAL_RAS_PORT 1719
- #define GK_ADDR_STR "135.17.7.8"
- class RASSession
- {
- public:
- int last_seqno;
- int ARQsent;
- int ACFrecd;
- boolean direction;
- };
- #endif
- class config_data
- {
- public:
- char e164src[32];
- char h323IDsrc[32];
- char endpointType[32];
- unsigned int q931port;
- #if defined(USE_RAS)
- char gkaddrstr[20];
- unsigned int localrasport;
- int discoverGK;
- #endif
- int verbose;
- config_data()
- {
- strcpy(e164src, E164_ALIAS);
- strcpy(h323IDsrc, H323_ID_ALIAS);
- strcpy(endpointType, "A");
- verbose = FALSE;
- q931port = Q931PORT;
- #if defined(USE_RAS)
- discoverGK = FALSE;
- strcpy(gkaddrstr, GK_ADDR_STR);
- localrasport = LOCAL_RAS_PORT;
- #endif
- }
- };
- extern config_data *config;
- #if 0
- #if (defined(_DEBUG))
- #define LOG printf
- #define LOG_ERROR printf
- #else
- #define LOG
- #define LOG_ERROR
- #endif
- #else
- #define LOG if (config->verbose) printf
- #define LOG_ERROR if (config->verbose) printf
- #endif
- class H323Call;
- // A H.323 Phone that with NUM_LINES simultaneous lines.
- #if defined(USE_RAS)
- class Exchange : public ConnectionManager, public H225RASProtocol,
- public MessageQueue
- {
- public:
- Exchange(H225CSEndpointType& endpoint_type,
- H225CSVendorID& vendor_id, int ras_endpoint,
- ProtReturnCode &result);
- RASSession ras_sess[NUM_LINES];
- #else
- class Exchange : public ConnectionManager, public MessageQueue
- {
- public:
- Exchange(ProtReturnCode &result);
- #endif
- ~Exchange();
- void UserInterface();
- void ShutDown();
- void PlaceTransferedToCall(int parent_index, unsigned int ip,
- char *phone, int invokeID, char *callID);
- void PlaceCall(unsigned int ip_address,char *phone=NULL,
- int faststart = 0);
- void DropTranferringCall(int line_no);
- void DropCall(int line_no);
- void SendFacility(int line_no, H450SSseq *ssSeq);
- void SendToExchange(int message, unsigned int wparam,
- unsigned int lparam);
- // Connection Manager Callbacks.
- void NotifyNewConnection(int identifier,
- int conn_ref, sockaddr *new_addr);
- void NotifyConnectionStatus(ConnectionEntity *conn,
- ProtReturnCode connection_status);
- void NotifyConnectionClosed(ConnectionEntity *conn,
- ProtReturnCode reason);
- // Error occured while trying to accept an incoming
- // connection (as a result of a earlier Listen call.)
- void NotifyListenError(int identifier,
- ProtReturnCode status);
- #if defined(USE_RAS)
- void NotifyRASMessage(H225RASMessage& ras_message,
- struct sockaddr *origin, struct sockaddr *destination,
- struct H225RASTransmitterInfo& info);
- // RAS message request timed-out without reply back.
- void NotifyRASTimeout(H225RASMessage& ras_message,
- struct sockaddr *destination,
- H225RASTransmitterInfo& info);
- struct sockaddr *GetLocalRASAddr();
- struct sockaddr *GetLocalSigAddr();
- void SetLastSeqno(unsigned int);
- void DiscoverGK();
- void RegisterWithGK();
- void UnRegisterWithGK();
- int GetLastSeqno();
- // Are we registered with a gatekeeper
- void SetIsGKRegistered(boolean flag);
- boolean IsGKRegistered();
- ProtReturnCode SendGRQ(int seq, struct sockaddr *);
- ProtReturnCode SendGCF(int seq, struct sockaddr *);
- ProtReturnCode SendGRJ(int seq, struct sockaddr *);
- ProtReturnCode SendRRQ(int seq, struct sockaddr *);
- ProtReturnCode SendRCF(int seq, struct sockaddr *);
- ProtReturnCode SendRRJ(int seq, struct sockaddr *);
- ProtReturnCode SendURQ(int seq, struct sockaddr *);
- ProtReturnCode SendUCF(int seq, struct sockaddr *);
- ProtReturnCode SendURJ(int seq, struct sockaddr *);
- ProtReturnCode SendARQ(int seq, struct sockaddr *, class SendARQdata *);
- ProtReturnCode SendACF(int seq, struct sockaddr *);
- ProtReturnCode SendARJ(int seq, struct sockaddr *);
- ProtReturnCode SendBRQ(int seq, struct sockaddr *);
- ProtReturnCode SendBCF(int seq, struct sockaddr *);
- ProtReturnCode SendBRJ(int seq, struct sockaddr *);
- ProtReturnCode SendDRQ(int seq, struct sockaddr *, int);
- ProtReturnCode SendDCF(int seq, struct sockaddr *);
- ProtReturnCode SendDRJ(int seq, struct sockaddr *);
- ProtReturnCode SendLRQ(int seq, struct sockaddr *);
- ProtReturnCode SendLCF(int seq, struct sockaddr *);
- ProtReturnCode SendLRJ(int seq, struct sockaddr *);
- ProtReturnCode SendIRQ(int seq, struct sockaddr *);
- ProtReturnCode SendIRR(int seq, struct sockaddr *);
- #endif
- unsigned int get_local_ip();
- // the following is used for generating conf_ids based on ip and index
- unsigned int confid_prefix;
- // flags that determine the current options that are to be
- // used by the call procedures.
- int use_faststart;
- int use_overlapsend;
- int use_tunneling;
- int use_alerting;
- int use_callproc;
- private:
- H323Call *calls[NUM_LINES];
- int num_active_calls;
- H225CSEndpointType endpoint_type;
- int terminal_type;
- void NotifyMessage(USER_MESSAGE&);
- int create_call(int direction);
- void destroy_call(int index);
- #if defined(USE_RAS)
- boolean isGKRegistered;
- boolean gkdiscovered;
- unsigned int local_ip;
- sockaddr local_ras;
- sockaddr local_sig;
- unsigned short ep_id[128];
- int ep_id_len;
- int seqno;
- #endif
- };
- unsigned int HostNameToIP(char *hostname);
- #endif